Improved setter
This commit is contained in:
parent
d88cfdbed7
commit
2ca61842b1
@ -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.
|
||||
|
@ -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")
|
||||
(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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user