From 0294c0485830bd0454afd63dce79f88077df3212 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 24 Jul 2019 09:31:41 +0900 Subject: [PATCH] Fixed issue with Lamda --- desktop/sources/scripts/library.js | 2 +- desktop/sources/scripts/lisp.js | 2 +- examples/archives/gradient.lisp | 14 ------- examples/basics/svg.gradient.lisp | 12 ++++++ examples/demo/spiral.lisp | 58 +++++++++++++------------- examples/{archives => demo}/stars.lisp | 0 examples/{archives => misc}/theme.lisp | 2 +- 7 files changed, 44 insertions(+), 46 deletions(-) delete mode 100644 examples/archives/gradient.lisp create mode 100644 examples/basics/svg.gradient.lisp rename examples/{archives => demo}/stars.lisp (100%) rename examples/{archives => misc}/theme.lisp (95%) diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index d575ee1..0e6bcee 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -235,7 +235,7 @@ function Library (ronin) { this.sqrt = Math.sqrt // calculate the square root this.sq = (a) => { // calculate the square - return a * a; + return a * a } this.PI = Math.PI diff --git a/desktop/sources/scripts/lisp.js b/desktop/sources/scripts/lisp.js index a6cc74f..8a79efa 100644 --- a/desktop/sources/scripts/lisp.js +++ b/desktop/sources/scripts/lisp.js @@ -152,7 +152,7 @@ function Lisp (lib = {}, includes = []) { } const tokenize = function (input) { - const i = input.replace(/^\;.*\n?/gm, '').replace('λ', 'lambda ').split('"') + const i = input.replace(/^\;.*\n?/gm, '').replace(/λ /g, 'lambda ').split('"') return i.map(function (x, i) { return i % 2 === 0 ? x.replace(/\(/g, ' ( ') diff --git a/examples/archives/gradient.lisp b/examples/archives/gradient.lisp deleted file mode 100644 index 3637db9..0000000 --- a/examples/archives/gradient.lisp +++ /dev/null @@ -1,14 +0,0 @@ -; gradients - -(clear) -(fill - (svg "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 "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.gradient.lisp b/examples/basics/svg.gradient.lisp new file mode 100644 index 0000000..61b1a17 --- /dev/null +++ b/examples/basics/svg.gradient.lisp @@ -0,0 +1,12 @@ +; 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/demo/spiral.lisp b/examples/demo/spiral.lisp index 39027a8..bcc8c6e 100644 --- a/examples/demo/spiral.lisp +++ b/examples/demo/spiral.lisp @@ -1,30 +1,30 @@ ; animated recusive spiral -; by @local_guru - - (clear) - (defn rec - (v) - (if - (gt v 0) - ( - (stroke - (circle - (add 375 - (mul - (cos - (add - (div v 17) - (div - (time) 2000))) - (div v 2))) - (add 300 - (mul - (sin - (div v 11)) - (div v 2))) - (div v 2)) 1 "rgba(114,222, 194,0.1)") - (rec - (sub v 0.3))))) - ; set false to stop - (animate true) - (rec 300) \ No newline at end of file +; by @local_guru +(clear) +(defn rec + (v) + (if + (gt v 0) + ( + (stroke + (circle + (add 375 + (mul + (cos + (add + (div v 17) + (div + (time) 2000))) + (div v 2))) + (add 300 + (mul + (sin + (div v 11)) + (div v 2))) + (div v 2)) 1 "rgba + (114,222, 194,0.1)") + (rec + (sub v 0.3))))) +; set false to stop +(animate true) +(rec 300) \ No newline at end of file diff --git a/examples/archives/stars.lisp b/examples/demo/stars.lisp similarity index 100% rename from examples/archives/stars.lisp rename to examples/demo/stars.lisp diff --git a/examples/archives/theme.lisp b/examples/misc/theme.lisp similarity index 95% rename from examples/archives/theme.lisp rename to examples/misc/theme.lisp index 7a5db32..8c2dbe7 100644 --- a/examples/archives/theme.lisp +++ b/examples/misc/theme.lisp @@ -1,5 +1,5 @@ ; theme - +; reads color from the theme. (clear) (def col (λ