diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index f7c2b5c..53b4422 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -299,9 +299,13 @@ function Library (ronin) { return item[key] } - this.set = (item, key, val) => { // Sets an object's parameter with name as value. - item[key] = val - return item[key] + this.set = (item, ...args) => { // Sets an object's parameter with name as value. + for (let i = 0; i < args.length; i += 2) { + const key = args[i] + const val = args[i + 1] + item[key] = val + } + return item } this.of = (h, ...keys) => { // Gets object parameters with names. diff --git a/examples/events.lisp b/examples/events.lisp index df086f1..5a66930 100644 --- a/examples/events.lisp +++ b/examples/events.lisp @@ -2,35 +2,34 @@ ; (def prev-pos {:x 0 :y 0}) ; +(defn stroke-color + (e) + (if + (of e :is-down) "red" "#72dec2")) +; (defn draw-line (e) ( - (debug e) - (debug prev-pos) (if (of e :is-down) ( (stroke - (line prev-pos e) 2 "white") + (line prev-pos e) 2 "white") (set prev-pos :x - (of e :x)) - (set prev-pos :y + (of e :x) :y (of e :y)))))) ; (defn draw-circle (e) ( - (debug e) - (debug - (of e :type)) - (def stroke-color - (if - (eq - (of e :type) "mouse-down") "red" "#72dec2")) + (set prev-pos :x + (of e :x) :y + (of e :y)) (stroke (circle (of e :x) - (of e :y) 10) 4 stroke-color))) + (of e :y) 10) 4 + (stroke-color e)))) ; (on "mouse-down" draw-circle) (on "mouse-up" draw-circle)