Changed the line syntax to (line x1 y1 x2 y2)
This commit is contained in:
parent
33574979cd
commit
1c7b74d582
@ -42,7 +42,7 @@ Additional functions can be found in the [includes](https://github.com/hundredra
|
|||||||
- `(size w h)` Returns a size shape.
|
- `(size w h)` Returns a size shape.
|
||||||
- `(rect x y w h)` Returns a rect shape.
|
- `(rect x y w h)` Returns a rect shape.
|
||||||
- `(circle cx cy r)` Returns a circle shape.
|
- `(circle cx cy r)` Returns a circle shape.
|
||||||
- `(line a b)` Returns a line shape.
|
- `(line ax ay bx by)` Returns a line shape.
|
||||||
- `(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.
|
||||||
- `(stroke ~shape)` Strokes a shape.
|
- `(stroke ~shape)` Strokes a shape.
|
||||||
@ -55,7 +55,7 @@ Additional functions can be found in the [includes](https://github.com/hundredra
|
|||||||
- `(crop rect)` Crop canvas to rect.
|
- `(crop rect)` Crop canvas to rect.
|
||||||
- `(clone a b)`
|
- `(clone a b)`
|
||||||
- `(theme variable ~el)`
|
- `(theme variable ~el)`
|
||||||
- `(gradient [x1 y1 x2 y2] ~colors 'black'])`
|
- `(gradient line ~colors 'black'])`
|
||||||
- `(pixels rect fn q)`
|
- `(pixels rect fn q)`
|
||||||
- `(saturation pixel ~q)`
|
- `(saturation pixel ~q)`
|
||||||
- `(contrast pixel ~q)`
|
- `(contrast pixel ~q)`
|
||||||
@ -67,10 +67,10 @@ Additional functions can be found in the [includes](https://github.com/hundredra
|
|||||||
- `(mod a b)` Returns the modulo of a and b.
|
- `(mod a b)` Returns the modulo of a and b.
|
||||||
- `(clamp val min max)` Clamps a value between min and max.
|
- `(clamp val min max)` Clamps a value between min and max.
|
||||||
- `(step val step)`
|
- `(step val step)`
|
||||||
- `(floor)`
|
|
||||||
- `(min)`
|
- `(min)`
|
||||||
- `(max)`
|
- `(max)`
|
||||||
- `(ceil)`
|
- `(ceil)`
|
||||||
|
- `(floor)` round down to the nearest integer.
|
||||||
- `(sin)`
|
- `(sin)`
|
||||||
- `(cos)`
|
- `(cos)`
|
||||||
- `(log)` caclulates on the base of e.
|
- `(log)` caclulates on the base of e.
|
||||||
|
@ -70,8 +70,8 @@ function Library (ronin) {
|
|||||||
return { cx, cy, r }
|
return { cx, cy, r }
|
||||||
}
|
}
|
||||||
|
|
||||||
this.line = (a, b) => { // Returns a line shape.
|
this.line = (ax, ay, bx, by) => { // Returns a line shape.
|
||||||
return { a, b }
|
return { a: this.pos(ax, ay), b: this.pos(bx, by) }
|
||||||
}
|
}
|
||||||
|
|
||||||
this.text = (x, y, p, t, f = 'Arial') => { // Returns a text shape.
|
this.text = (x, y, p, t, f = 'Arial') => { // Returns a text shape.
|
||||||
@ -146,8 +146,8 @@ function Library (ronin) {
|
|||||||
|
|
||||||
// Gradients
|
// Gradients
|
||||||
|
|
||||||
this.gradient = ([x1, y1, x2, y2], colors = ['white', 'black']) => {
|
this.gradient = (line, colors = ['white', 'black']) => {
|
||||||
return ronin.surface.linearGradient(x1, y1, x2, y2, colors)
|
return ronin.surface.linearGradient(line.a.x, line.a.y, line.b.x, line.b.y, colors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pixels
|
// Pixels
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
; guides
|
|
||||||
(clear)
|
|
||||||
(stroke
|
|
||||||
(frame) 1 "red")
|
|
||||||
(stroke
|
|
||||||
(line
|
|
||||||
(pos 0 0)
|
|
||||||
(pos
|
|
||||||
(of
|
|
||||||
(frame) "w")
|
|
||||||
(of
|
|
||||||
(frame) "h"))) 1 "red")
|
|
||||||
(stroke
|
|
||||||
(line
|
|
||||||
(pos
|
|
||||||
(of
|
|
||||||
(frame) "w") 0)
|
|
||||||
(pos 0
|
|
||||||
(of
|
|
||||||
(frame) "h"))) 1 "red")
|
|
||||||
(stroke
|
|
||||||
(line
|
|
||||||
(pos
|
|
||||||
(div
|
|
||||||
(of
|
|
||||||
(frame) "w") 2) 0)
|
|
||||||
(pos
|
|
||||||
(div
|
|
||||||
(of
|
|
||||||
(frame) "w") 2)
|
|
||||||
(of
|
|
||||||
(frame) "h"))) 1 "red")
|
|
||||||
(stroke
|
|
||||||
(line
|
|
||||||
(pos 0
|
|
||||||
(div
|
|
||||||
(of
|
|
||||||
(frame) "h") 2))
|
|
||||||
(pos
|
|
||||||
(div
|
|
||||||
(of
|
|
||||||
(frame) "w") 2)
|
|
||||||
(of
|
|
||||||
(frame) "h"))) 1 "#72dec2")
|
|
||||||
(stroke
|
|
||||||
(line
|
|
||||||
(pos
|
|
||||||
(div
|
|
||||||
(of
|
|
||||||
(frame) "w") 2) 0)
|
|
||||||
(pos
|
|
||||||
(of
|
|
||||||
(frame) "w")
|
|
||||||
(div
|
|
||||||
(of
|
|
||||||
(frame) "h") 2))) 1 "#72dec2")
|
|
31
examples/basics/gradients.lisp
Normal file
31
examples/basics/gradients.lisp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
; gradients
|
||||||
|
(clear)
|
||||||
|
;
|
||||||
|
(def radius (of (frame) :m))
|
||||||
|
;
|
||||||
|
(def gradient-line
|
||||||
|
(line
|
||||||
|
(of (frame) :c) 0
|
||||||
|
(of (frame) :c)
|
||||||
|
(of (frame) :h)))
|
||||||
|
;
|
||||||
|
(fill
|
||||||
|
(circle
|
||||||
|
(of (frame) :c)
|
||||||
|
(of (frame) :m)
|
||||||
|
radius)
|
||||||
|
(gradient gradient-line ("#72dec2" "white")))
|
||||||
|
;
|
||||||
|
(fill
|
||||||
|
(circle
|
||||||
|
(of (frame) :c)
|
||||||
|
(of (frame) :m)
|
||||||
|
(mul radius 0.75))
|
||||||
|
(gradient gradient-line ("white" "#72dec2")))
|
||||||
|
;
|
||||||
|
(fill
|
||||||
|
(circle
|
||||||
|
(of (frame) :c)
|
||||||
|
(of (frame) :m)
|
||||||
|
(mul radius 0.5))
|
||||||
|
(gradient gradient-line ("#72dec2" "white")))
|
@ -18,7 +18,5 @@
|
|||||||
|
|
||||||
; draw line
|
; draw line
|
||||||
(stroke
|
(stroke
|
||||||
(line
|
(line (sub center-w rad) center-h (add center-w rad) center-h))
|
||||||
(pos (sub center-w rad) center-h)
|
|
||||||
(pos (add center-w rad) center-h)))
|
|
||||||
(stroke (text 10 170 200 "HELL") 2 "pink")
|
(stroke (text 10 170 200 "HELL") 2 "pink")
|
@ -1,12 +0,0 @@
|
|||||||
; gradients
|
|
||||||
(clear)
|
|
||||||
(fill
|
|
||||||
(svg 0 0 "M405,15 L405,15 L150,150 L195,90 L240,135 L120,195 L75,90 L135,165 L120,225 L90,240 L60,210 L90,150 L255,180 L285,180 L285,165 ")
|
|
||||||
(gradient
|
|
||||||
(0 -50 600 175)
|
|
||||||
("red" "orange" "blue" "green")))
|
|
||||||
(stroke
|
|
||||||
(svg 0 0 "M255,60 L255,60 L135,180 L75,60 L195,210 L120,225 L105,225 L165,255 L225,195 L255,135 L285,150") 1
|
|
||||||
(gradient
|
|
||||||
(50 0 180 0)
|
|
||||||
("black" "white" "blue" "green")))
|
|
@ -1,20 +0,0 @@
|
|||||||
; welcome to ronin - v2.1
|
|
||||||
(clear)
|
|
||||||
; ronin path
|
|
||||||
(def align {:x
|
|
||||||
(sub
|
|
||||||
(of
|
|
||||||
(frame) :center) 500) :y
|
|
||||||
(sub
|
|
||||||
(of
|
|
||||||
(frame) :middle) 150)})
|
|
||||||
; outline
|
|
||||||
(fill
|
|
||||||
(svg
|
|
||||||
(of align :x)
|
|
||||||
(of align :y) "M15,15 L15,15 L285,15 L285,285 L15,285 Z") "#fff")
|
|
||||||
; stroke
|
|
||||||
(stroke
|
|
||||||
(svg
|
|
||||||
(of align :x)
|
|
||||||
(of 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")
|
|
@ -1,25 +1,24 @@
|
|||||||
(resetTransform)
|
(resetTransform)
|
||||||
(clear)
|
(clear)
|
||||||
|
|
||||||
(defn branch
|
(defn branch
|
||||||
(v)
|
(v)
|
||||||
(if
|
(if
|
||||||
(gt v 0)
|
(gt v 0)
|
||||||
(
|
(
|
||||||
(scale 0.95)
|
(scale 0.95)
|
||||||
(stroke
|
(stroke
|
||||||
(line (pos 0 0) (pos 100 100))
|
(line 0 0 100 100) 2 "white")
|
||||||
10 "white")
|
(move 100 100)
|
||||||
(move 100 100)
|
(pushTransform)
|
||||||
(pushTransform)
|
(rotate
|
||||||
(rotate (div v 50))
|
(div v 50))
|
||||||
(branch (sub v 1))
|
(branch
|
||||||
(popTransform)
|
(sub v 1))
|
||||||
(pushTransform)
|
(popTransform)
|
||||||
(rotate (div v -50))
|
(pushTransform)
|
||||||
(branch (sub v 1))
|
(rotate
|
||||||
(popTransform)
|
(div v -50))
|
||||||
)
|
(branch
|
||||||
)
|
(sub v 1))
|
||||||
)
|
(popTransform)) ))
|
||||||
(branch 10)
|
(branch 10)
|
@ -13,7 +13,7 @@
|
|||||||
))
|
))
|
||||||
;
|
;
|
||||||
(defn when-animate () (
|
(defn when-animate () (
|
||||||
(stroke (line prev-pos mouse-pos) 4 "#72dec2")
|
(stroke (line (of prev-pos :x) (of prev-pos :y) (of mouse-pos :x) (of mouse-pos :y)) 4 "#72dec2")
|
||||||
(move w h)
|
(move w h)
|
||||||
(rotate 0.002)
|
(rotate 0.002)
|
||||||
(scale 0.998)
|
(scale 0.998)
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
(cx cy r a)
|
(cx cy r a)
|
||||||
(
|
(
|
||||||
(stroke
|
(stroke
|
||||||
(line
|
(line cx cy (of (circle-pos cx cy r a) :x) (of (circle-pos cx cy r a) :y)
|
||||||
(pos cx cy)
|
) 2 "white")))
|
||||||
(circle-pos cx cy r a)) 2 "white")))
|
|
||||||
;
|
;
|
||||||
(defn draw-star
|
(defn draw-star
|
||||||
(cx cy r c)
|
(cx cy r c)
|
||||||
|
@ -33,15 +33,13 @@
|
|||||||
(def y
|
(def y
|
||||||
(elevation i))
|
(elevation i))
|
||||||
(stroke
|
(stroke
|
||||||
(line
|
(line x
|
||||||
(pos x
|
(elevation
|
||||||
(elevation
|
(sub i 1))
|
||||||
(sub i 1)))
|
(add x seg-width)
|
||||||
(pos
|
(elevation i)) 4
|
||||||
(add x seg-width)
|
|
||||||
(elevation i))) 4
|
|
||||||
(gradient
|
(gradient
|
||||||
(50 0
|
(line 50 0
|
||||||
(of
|
(of
|
||||||
(frame) :w) 0)
|
(frame) :w) 0)
|
||||||
("#ffb545" "#72dec2")))))
|
("#ffb545" "#72dec2")))))
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
; this demo shows how to use the mouse events.
|
; this demo shows how to use the mouse events.
|
||||||
;
|
|
||||||
(defn redraw
|
(defn redraw
|
||||||
(e)
|
(e)
|
||||||
(
|
(
|
||||||
(clear)
|
(clear)
|
||||||
; vertical line
|
; vertical line
|
||||||
(stroke
|
(stroke (line (of e :x) 0 (of e :x) (of e :y)) 2 "#ff0000")
|
||||||
(line
|
|
||||||
(pos
|
|
||||||
(of e :x) 0) e) 2 "#ff0000")
|
|
||||||
; horizontal line
|
; horizontal line
|
||||||
(stroke
|
(stroke
|
||||||
(line
|
(line 0 (of e :y) (of e :x) (of e :y)) 2 "#72dec2")
|
||||||
(pos 0
|
|
||||||
(of e :y)) e) 2 "#72dec2")
|
|
||||||
; circle
|
; circle
|
||||||
(stroke
|
(stroke
|
||||||
(circle
|
(circle
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
(of e :is-down)
|
(of e :is-down)
|
||||||
(
|
(
|
||||||
(stroke
|
(stroke
|
||||||
(line prev-pos e) 2 "white")
|
(line (of prev-pos :x) (of prev-pos :y) (of e :x) (of e :y)) 2 "white")
|
||||||
(set prev-pos :x
|
(set prev-pos :x
|
||||||
(of e :x) :y
|
(of e :x) :y
|
||||||
(of e :y))))))
|
(of e :y))))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user