diff --git a/README.md b/README.md index a8de701..cff9060 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Additional functions can be found in the [includes](https://github.com/hundredra - `(size w h)` Returns a size shape. - `(rect x y w h)` Returns a rect 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. - `(svg x y d)` Returns a svg 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. - `(clone a b)` - `(theme variable ~el)` -- `(gradient [x1 y1 x2 y2] ~colors 'black'])` +- `(gradient line ~colors 'black'])` - `(pixels rect fn q)` - `(saturation 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. - `(clamp val min max)` Clamps a value between min and max. - `(step val step)` -- `(floor)` - `(min)` - `(max)` - `(ceil)` +- `(floor)` round down to the nearest integer. - `(sin)` - `(cos)` - `(log)` caclulates on the base of e. diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index a32976e..d2b42ac 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -70,8 +70,8 @@ function Library (ronin) { return { cx, cy, r } } - this.line = (a, b) => { // Returns a line shape. - return { a, b } + this.line = (ax, ay, bx, by) => { // Returns a line shape. + return { a: this.pos(ax, ay), b: this.pos(bx, by) } } this.text = (x, y, p, t, f = 'Arial') => { // Returns a text shape. @@ -146,8 +146,8 @@ function Library (ronin) { // Gradients - this.gradient = ([x1, y1, x2, y2], colors = ['white', 'black']) => { - return ronin.surface.linearGradient(x1, y1, x2, y2, colors) + this.gradient = (line, colors = ['white', 'black']) => { + return ronin.surface.linearGradient(line.a.x, line.a.y, line.b.x, line.b.y, colors) } // Pixels diff --git a/examples/archives/guides.lisp b/examples/archives/guides.lisp deleted file mode 100644 index 66c9758..0000000 --- a/examples/archives/guides.lisp +++ /dev/null @@ -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") \ No newline at end of file diff --git a/examples/basics/gradients.lisp b/examples/basics/gradients.lisp new file mode 100644 index 0000000..1a767db --- /dev/null +++ b/examples/basics/gradients.lisp @@ -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"))) \ No newline at end of file diff --git a/examples/basics/shapes.lisp b/examples/basics/shapes.lisp index d9712c4..d97ecfe 100644 --- a/examples/basics/shapes.lisp +++ b/examples/basics/shapes.lisp @@ -18,7 +18,5 @@ ; draw line (stroke - (line - (pos (sub center-w rad) center-h) - (pos (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") \ No newline at end of file diff --git a/examples/basics/svg.gradient.lisp b/examples/basics/svg.gradient.lisp deleted file mode 100644 index 61b1a17..0000000 --- a/examples/basics/svg.gradient.lisp +++ /dev/null @@ -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"))) \ No newline at end of file diff --git a/examples/basics/svg.lisp b/examples/basics/svg.lisp deleted file mode 100644 index 7f1a961..0000000 --- a/examples/basics/svg.lisp +++ /dev/null @@ -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") \ No newline at end of file diff --git a/examples/demo/branch.lisp b/examples/demo/branch.lisp index adb12f7..163ac2f 100644 --- a/examples/demo/branch.lisp +++ b/examples/demo/branch.lisp @@ -1,25 +1,24 @@ (resetTransform) (clear) - -(defn branch - (v) - (if - (gt v 0) +(defn branch + (v) + (if + (gt v 0) ( - (scale 0.95) - (stroke - (line (pos 0 0) (pos 100 100)) - 10 "white") - (move 100 100) - (pushTransform) - (rotate (div v 50)) - (branch (sub v 1)) - (popTransform) - (pushTransform) - (rotate (div v -50)) - (branch (sub v 1)) - (popTransform) - ) - ) -) + (scale 0.95) + (stroke + (line 0 0 100 100) 2 "white") + (move 100 100) + (pushTransform) + (rotate + (div v 50)) + (branch + (sub v 1)) + (popTransform) + (pushTransform) + (rotate + (div v -50)) + (branch + (sub v 1)) + (popTransform)) )) (branch 10) \ No newline at end of file diff --git a/examples/demo/fog.lisp b/examples/demo/fog.lisp index e5c0c25..8b61a29 100644 --- a/examples/demo/fog.lisp +++ b/examples/demo/fog.lisp @@ -13,7 +13,7 @@ )) ; (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) (rotate 0.002) (scale 0.998) diff --git a/examples/demo/stars.lisp b/examples/demo/stars.lisp index bff89e3..c2353f2 100644 --- a/examples/demo/stars.lisp +++ b/examples/demo/stars.lisp @@ -5,9 +5,8 @@ (cx cy r a) ( (stroke - (line - (pos cx cy) - (circle-pos cx cy r a)) 2 "white"))) + (line cx cy (of (circle-pos cx cy r a) :x) (of (circle-pos cx cy r a) :y) + ) 2 "white"))) ; (defn draw-star (cx cy r c) diff --git a/examples/events/on-animate.lisp b/examples/events/on-animate.lisp index 0da2d6a..569396f 100644 --- a/examples/events/on-animate.lisp +++ b/examples/events/on-animate.lisp @@ -33,15 +33,13 @@ (def y (elevation i)) (stroke - (line - (pos x - (elevation - (sub i 1))) - (pos - (add x seg-width) - (elevation i))) 4 + (line x + (elevation + (sub i 1)) + (add x seg-width) + (elevation i)) 4 (gradient - (50 0 + (line 50 0 (of (frame) :w) 0) ("#ffb545" "#72dec2"))))) diff --git a/examples/events/on-mouse.lisp b/examples/events/on-mouse.lisp index edd3e33..165dd59 100644 --- a/examples/events/on-mouse.lisp +++ b/examples/events/on-mouse.lisp @@ -1,19 +1,13 @@ ; this demo shows how to use the mouse events. -; (defn redraw (e) ( (clear) ; vertical line - (stroke - (line - (pos - (of e :x) 0) e) 2 "#ff0000") + (stroke (line (of e :x) 0 (of e :x) (of e :y)) 2 "#ff0000") ; horizontal line (stroke - (line - (pos 0 - (of e :y)) e) 2 "#72dec2") + (line 0 (of e :y) (of e :x) (of e :y)) 2 "#72dec2") ; circle (stroke (circle diff --git a/examples/projects/drawing.lisp b/examples/projects/drawing.lisp index 8e8293f..f21a529 100644 --- a/examples/projects/drawing.lisp +++ b/examples/projects/drawing.lisp @@ -16,7 +16,7 @@ (of e :is-down) ( (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 (of e :x) :y (of e :y))))))