Swapped stroke-width and stroke-color params, fixes #82
This commit is contained in:
parent
adec70791e
commit
38ee25ac2c
@ -11,7 +11,7 @@ Learn more by reading the <a href="https://github.com/Hundredrabbits/Ronin" targ
|
|||||||
```lisp
|
```lisp
|
||||||
; draw a red square
|
; draw a red square
|
||||||
(stroke
|
(stroke
|
||||||
(rect 30 30 100 100) 2 "red")
|
(rect 30 30 100 100) "red" 2)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install & Run
|
## Install & Run
|
||||||
@ -57,7 +57,7 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i
|
|||||||
- `(text x y p t ~f)` Returns a text shape.
|
- `(text x y p t ~f)` Returns a text shape.
|
||||||
- `(svg x y d)` Returns a svg shape.
|
- `(svg x y d)` Returns a svg shape.
|
||||||
- `(offset a b)` Returns the offset between two pos.
|
- `(offset a b)` Returns the offset between two pos.
|
||||||
- `(stroke ~shape)` Strokes a shape.
|
- `(stroke shape color ~thickness)` Strokes a shape.
|
||||||
- `(fill ~rect)` Fills a shape.
|
- `(fill ~rect)` Fills a shape.
|
||||||
- `(gradient line ~colors 'black'])` Defines a gradient color.
|
- `(gradient line ~colors 'black'])` Defines a gradient color.
|
||||||
- `(guide shape color)` Draws a shape on the guide layer.
|
- `(guide shape color)` Draws a shape on the guide layer.
|
||||||
|
@ -80,14 +80,14 @@ In Ronin, a shape is either a `(rect)`, a `(line)`, a `(circle)` or a `(pos)`. T
|
|||||||
|
|
||||||
```lisp
|
```lisp
|
||||||
(stroke
|
(stroke
|
||||||
(rect 100 100 300 200) 10 "red")
|
(rect 100 100 300 200) "red" 10)
|
||||||
```
|
```
|
||||||
|
|
||||||
Or, if you would like to trace the shape with your mouse:
|
Or, if you would like to trace the shape with your mouse:
|
||||||
|
|
||||||
```lisp
|
```lisp
|
||||||
(stroke
|
(stroke
|
||||||
$rect 10 "red")
|
$rect "red" 10)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Fill
|
### Fill
|
||||||
|
@ -223,7 +223,7 @@ function Commander (ronin) {
|
|||||||
(fill
|
(fill
|
||||||
(svg align:x align:y "M15,15 L15,15 L285,15 L285,285 L15,285 Z") "#fff")
|
(svg align:x align:y "M15,15 L15,15 L285,15 L285,285 L15,285 Z") "#fff")
|
||||||
(stroke
|
(stroke
|
||||||
(svg align:x align:y "M60,60 L195,60 A45,45 0 0,1 240,105 A45,45 0 0,1 195,150 L60,150 M195,150 A45,45 0 0,1 240,195 L240,240 ") 5 "#000")`
|
(svg align:x align:y "M60,60 L195,60 A45,45 0 0,1 240,105 A45,45 0 0,1 195,150 L60,150 M195,150 A45,45 0 0,1 240,195 L240,240 ") "#000" 5)`
|
||||||
|
|
||||||
String.prototype.insert = function (s, i) { return [this.slice(0, i), `${s}`, this.slice(i)].join('') }
|
String.prototype.insert = function (s, i) { return [this.slice(0, i), `${s}`, this.slice(i)].join('') }
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,8 @@ function Library (ronin) {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
this.stroke = (shape = this.frame(), thickness, color) => { // Strokes a shape.
|
this.stroke = (shape, color, thickness = 2) => { // Strokes a shape.
|
||||||
ronin.surface.stroke(shape, thickness, color)
|
ronin.surface.stroke(shape, color, thickness)
|
||||||
return shape
|
return shape
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ function Surface (ronin) {
|
|||||||
|
|
||||||
// Shape
|
// Shape
|
||||||
|
|
||||||
this.stroke = (shape, width, color, context = this.context) => {
|
this.stroke = (shape, color, width, context = this.context) => {
|
||||||
context.beginPath()
|
context.beginPath()
|
||||||
this.trace(shape, context)
|
this.trace(shape, context)
|
||||||
context.lineWidth = width
|
context.lineWidth = width
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
(circle
|
(circle
|
||||||
(mul 5 v)
|
(mul 5 v)
|
||||||
(mul 5 v)
|
(mul 5 v)
|
||||||
(mul 5 v)) 1 "red")
|
(mul 5 v)) "red" 1)
|
||||||
(rec
|
(rec
|
||||||
(sub v 5)))))
|
(sub v 5)))))
|
||||||
(rec 100)
|
(rec 100)
|
@ -9,14 +9,14 @@
|
|||||||
|
|
||||||
; draw circle
|
; draw circle
|
||||||
(stroke
|
(stroke
|
||||||
(circle center-w center-h rad) 2 "white")
|
(circle center-w center-h rad) "white" 2)
|
||||||
|
|
||||||
; draw rect
|
; draw rect
|
||||||
(stroke
|
(stroke
|
||||||
(rect
|
(rect
|
||||||
(sub center-w rad) (sub center-h rad) center-h center-h) 2 "white")
|
(sub center-w rad) (sub center-h rad) center-h center-h) "white" 2)
|
||||||
|
|
||||||
; draw line
|
; draw line
|
||||||
(stroke
|
(stroke
|
||||||
(line (sub center-w rad) center-h (add center-w rad) center-h))
|
(line (sub center-w rad) center-h (add center-w rad) center-h))
|
||||||
(stroke (text 10 170 200 "HELL") 2 "pink")
|
(stroke (text 10 170 200 "HELL") "pink" 2)
|
@ -7,7 +7,7 @@
|
|||||||
(
|
(
|
||||||
(scale 0.95)
|
(scale 0.95)
|
||||||
(stroke
|
(stroke
|
||||||
(line 0 0 100 100) 2 "white")
|
(line 0 0 100 100) "white" 2)
|
||||||
(move 100 100)
|
(move 100 100)
|
||||||
(pushTransform)
|
(pushTransform)
|
||||||
(rotate
|
(rotate
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
))
|
))
|
||||||
;
|
;
|
||||||
(defn when-animate () (
|
(defn when-animate () (
|
||||||
(stroke (line prev-pos:x prev-pos:y mouse-pos:x mouse-pos:y) 4 "#72dec2")
|
(stroke (line prev-pos:x prev-pos:y mouse-pos:x mouse-pos:y) "#72dec2" 4)
|
||||||
(move frame-rect:c frame-rect:m)
|
(move frame-rect:c frame-rect:m)
|
||||||
(rotate 0.002)
|
(rotate 0.002)
|
||||||
(scale 0.998)
|
(scale 0.998)
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
(def spiral-y (add frame-rect:m (mul (sin (div v 11)) (div v 2))))
|
(def spiral-y (add frame-rect:m (mul (sin (div v 11)) (div v 2))))
|
||||||
(def spiral-r (div v 2))
|
(def spiral-r (div v 2))
|
||||||
; draw
|
; draw
|
||||||
(stroke (circle spiral-x spiral-y spiral-r) 1 "rgba(114,222,194,0.1)") (rec (sub v 0.3)))))
|
(stroke (circle spiral-x spiral-y spiral-r) "rgba(114,222,194,0.1)" 1) (rec (sub v 0.3)))))
|
||||||
;
|
;
|
||||||
(defn redraw () (
|
(defn redraw () (
|
||||||
(clear)
|
(clear)
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
(
|
(
|
||||||
(stroke
|
(stroke
|
||||||
(line cx cy (:x (circle-pos cx cy r a)) (:y (circle-pos cx cy r a))
|
(line cx cy (:x (circle-pos cx cy r a)) (:y (circle-pos cx cy r a))
|
||||||
) 2 "white")))
|
) "white" 2)))
|
||||||
;
|
;
|
||||||
(defn draw-star
|
(defn draw-star
|
||||||
(cx cy r c)
|
(cx cy r c)
|
||||||
|
@ -34,11 +34,11 @@
|
|||||||
(elevation
|
(elevation
|
||||||
(sub i 1))
|
(sub i 1))
|
||||||
(add x seg-width)
|
(add x seg-width)
|
||||||
(elevation i)) 4
|
(elevation i))
|
||||||
(gradient
|
(gradient
|
||||||
(line 50 0
|
(line 50 0
|
||||||
frame-rect:w 0)
|
frame-rect:w 0)
|
||||||
("#ffb545" "#72dec2")))))
|
("#ffb545" "#72dec2")) 4 )))
|
||||||
;
|
;
|
||||||
(defn redraw
|
(defn redraw
|
||||||
()
|
()
|
||||||
|
@ -4,15 +4,15 @@
|
|||||||
(
|
(
|
||||||
(clear)
|
(clear)
|
||||||
; vertical line
|
; vertical line
|
||||||
(stroke (line e:x 0 e:x e:y) 2 "#ff0000")
|
(stroke (line e:x 0 e:x e:y) "#ff0000")
|
||||||
; horizontal line
|
; horizontal line
|
||||||
(stroke
|
(stroke
|
||||||
(line 0 e:y e:x e:y) 2 "#72dec2")
|
(line 0 e:y e:x e:y) "#72dec2")
|
||||||
; circle
|
; circle
|
||||||
(stroke
|
(stroke
|
||||||
(circle
|
(circle
|
||||||
e:x
|
e:x
|
||||||
e:y 30) 2 "#ffffff")))
|
e:y 30) "#ffffff")))
|
||||||
;
|
;
|
||||||
(on "mouse-down" redraw)
|
(on "mouse-down" redraw)
|
||||||
(on "mouse-up" redraw)
|
(on "mouse-up" redraw)
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
(
|
(
|
||||||
(debug e:is-down)
|
(debug e:is-down)
|
||||||
(stroke
|
(stroke
|
||||||
(line prev-pos:x prev-pos:y e:x e:y) 2 "white")
|
(line prev-pos:x prev-pos:y e:x e:y) "white")
|
||||||
(set prev-pos "x" e:x "y" e:y)
|
(set prev-pos "x" e:x "y" e:y)
|
||||||
(debug prev-pos)
|
(debug prev-pos)
|
||||||
(debug e)))))
|
(debug e)))))
|
||||||
@ -29,7 +29,7 @@
|
|||||||
(set prev-pos "x" e:x "y" e:y)
|
(set prev-pos "x" e:x "y" e:y)
|
||||||
(debug e:x)
|
(debug e:x)
|
||||||
(stroke
|
(stroke
|
||||||
(circle e:x e:y 10) 4
|
(circle e:x e:y 10)
|
||||||
(stroke-color e))))
|
(stroke-color e))))
|
||||||
;
|
;
|
||||||
(on "mouse-down" draw-circle)
|
(on "mouse-down" draw-circle)
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
(e)
|
(e)
|
||||||
(
|
(
|
||||||
(stroke
|
(stroke
|
||||||
(circle e:x e:y e:d) 1
|
(circle e:x e:y e:d)
|
||||||
(gradient gradient-line
|
(gradient gradient-line
|
||||||
("black" "#ffb545")))))
|
("black" "#ffb545")))))
|
||||||
;
|
;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user