diff --git a/desktop/sources/scripts/lisp.js b/desktop/sources/scripts/lisp.js index b1907ca..07d2c91 100644 --- a/desktop/sources/scripts/lisp.js +++ b/desktop/sources/scripts/lisp.js @@ -113,7 +113,6 @@ function Lisp (lib = {}, includes = []) { const interpret = async function (input, context) { if (!input) { console.warn('Lisp', 'error', context.scope); return null } - if (context === undefined) { return interpret(input, new Context(lib)) } else if (input instanceof Array) { diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js index ee7236c..db384a9 100644 --- a/desktop/sources/scripts/ronin.js +++ b/desktop/sources/scripts/ronin.js @@ -126,13 +126,13 @@ function Ronin () { a: { x: this.mouseOrigin.x, y: this.mouseOrigin.y }, b: { x: pos.x, y: pos.y } } - const distance = Math.sqrt(((line.a.x - line.b.x) * (line.a.x - line.b.x)) + ((line.a.y - line.b.y) * (line.a.y - line.b.y))) + const d = Math.sqrt(((line.a.x - line.b.x) * (line.a.x - line.b.x)) + ((line.a.y - line.b.y) * (line.a.y - line.b.y))) const circle = { cx: this.mouseOrigin.x, cy: this.mouseOrigin.y, - r: distance + r: d } - return { x, y, line, rect, pos, circle, type, 'is-down': type !== 'mouse-up' ? true : null } + return { x, y, d, line, rect, pos, circle, type, 'is-down': type !== 'mouse-up' ? true : null } } // Zoom diff --git a/examples/projects/spire.lisp b/examples/projects/spire.lisp new file mode 100644 index 0000000..4bea501 --- /dev/null +++ b/examples/projects/spire.lisp @@ -0,0 +1,16 @@ +; this demo shows how to use the mouse events to draw make a simple drawing tool. +; +(clear) +; +(def gradient-line + (line frame-rect:c 0 frame-rect:c frame-rect:h)) +; +(defn draw-circle + (e) + ( + (stroke + (circle e:x e:y e:d) 1 + (gradient gradient-line + ("black" "#ffb545"))))) +; +(on "mouse-move" draw-circle) \ No newline at end of file diff --git a/examples/projects/tunnel.lisp b/examples/projects/tunnel.lisp deleted file mode 100644 index 7316877..0000000 --- a/examples/projects/tunnel.lisp +++ /dev/null @@ -1,37 +0,0 @@ -; this demo shows how to use the mouse events to draw make a simple drawing tool. -; -(clear) -; -(def prev-pos {:x 0 :y 0}) -; -(defn stroke-color - (e) - (if - (eq e:is-down true) "#ffb545" "#72dec2")) -; -(defn draw-line - (e) - ( - (if - (eq e:is-down true) - ( - (debug e:is-down) - (stroke - (line prev-pos:x prev-pos:y e:x e:y) 2 "white") - (set prev-pos "x" e:x "y" e:y) - (debug prev-pos) - (debug e))))) -; -(defn draw-circle - (e) - ( - (debug e) - (set prev-pos "x" e:x "y" e:y) - (debug e:x) - (stroke - (circle e:x e:y 10) 4 - (stroke-color e)))) -; -(on "mouse-down" draw-circle) -(on "mouse-up" draw-circle) -(on "mouse-move" draw-line) \ No newline at end of file