Added a super guide function

This commit is contained in:
Devine Lu Linvega 2019-07-25 13:33:57 +09:00
parent 7f3a8cef52
commit 11c81aed6f
3 changed files with 11 additions and 4 deletions

View File

@ -51,6 +51,8 @@ Additional functions can be found in the [includes](https://github.com/hundredra
- `(svg x y d)` Returns a svg shape.
- `(stroke ~shape)` Strokes a shape.
- `(fill ~rect)` Fills a shape.
- `(gradient line ~colors 'black'])` Defines a gradient color.
- `(guide shape)` Draws a shape on the guide layer.
- `(clear ~rect)` Clears a rect.
- `(frame)` Returns a rect of the frame.
- `(center)` Returns a position of the center of the frame.
@ -59,7 +61,6 @@ Additional functions can be found in the [includes](https://github.com/hundredra
- `(crop rect)` Crop canvas to rect.
- `(clone a b)`
- `(theme variable ~el)`
- `(gradient line ~colors 'black'])`
- `(pixels rect fn q)`
- `(saturation pixel ~q)`
- `(contrast pixel ~q)`

View File

@ -94,11 +94,17 @@ function Library (ronin) {
return rect
}
this.gradient = (line, colors = ['white', 'black']) => {
this.gradient = (line, colors = ['white', 'black']) => { // Defines a gradient color.
return ronin.surface.linearGradient(line.a.x, line.a.y, line.b.x, line.b.y, colors)
}
this.guide = (shape) => { // Draws a shape on the guide layer.
ronin.surface.drawGuide(shape)
return shape
}
this.clear = (rect = this.frame()) => { // Clears a rect.
ronin.surface.clearGuide(rect)
ronin.surface.clear(rect)
return rect
}

View File

@ -160,8 +160,8 @@ function Surface (ronin) {
this.drawGuide = function (shape, context = this.guide) {
this.clearGuide()
this.stroke(shape, 5, 'black', context)
this.stroke(shape, 2, 'white', context)
this.stroke(shape, 3, 'black', context)
this.stroke(shape, 1.5, 'white', context)
}
this.clone = function (a, b) {