Improved setter
This commit is contained in:
parent
d88cfdbed7
commit
2ca61842b1
@ -299,9 +299,13 @@ function Library (ronin) {
|
|||||||
return item[key]
|
return item[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set = (item, key, val) => { // Sets an object's parameter with name as value.
|
this.set = (item, ...args) => { // Sets an object's parameter with name as value.
|
||||||
item[key] = val
|
for (let i = 0; i < args.length; i += 2) {
|
||||||
return item[key]
|
const key = args[i]
|
||||||
|
const val = args[i + 1]
|
||||||
|
item[key] = val
|
||||||
|
}
|
||||||
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
this.of = (h, ...keys) => { // Gets object parameters with names.
|
this.of = (h, ...keys) => { // Gets object parameters with names.
|
||||||
|
@ -2,35 +2,34 @@
|
|||||||
;
|
;
|
||||||
(def prev-pos {:x 0 :y 0})
|
(def prev-pos {:x 0 :y 0})
|
||||||
;
|
;
|
||||||
|
(defn stroke-color
|
||||||
|
(e)
|
||||||
|
(if
|
||||||
|
(of e :is-down) "red" "#72dec2"))
|
||||||
|
;
|
||||||
(defn draw-line
|
(defn draw-line
|
||||||
(e)
|
(e)
|
||||||
(
|
(
|
||||||
(debug e)
|
|
||||||
(debug prev-pos)
|
|
||||||
(if
|
(if
|
||||||
(of e :is-down)
|
(of e :is-down)
|
||||||
(
|
(
|
||||||
(stroke
|
(stroke
|
||||||
(line prev-pos e) 2 "white")
|
(line prev-pos e) 2 "white")
|
||||||
(set prev-pos :x
|
(set prev-pos :x
|
||||||
(of e :x))
|
(of e :x) :y
|
||||||
(set prev-pos :y
|
|
||||||
(of e :y))))))
|
(of e :y))))))
|
||||||
;
|
;
|
||||||
(defn draw-circle
|
(defn draw-circle
|
||||||
(e)
|
(e)
|
||||||
(
|
(
|
||||||
(debug e)
|
(set prev-pos :x
|
||||||
(debug
|
(of e :x) :y
|
||||||
(of e :type))
|
(of e :y))
|
||||||
(def stroke-color
|
|
||||||
(if
|
|
||||||
(eq
|
|
||||||
(of e :type) "mouse-down") "red" "#72dec2"))
|
|
||||||
(stroke
|
(stroke
|
||||||
(circle
|
(circle
|
||||||
(of e :x)
|
(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-down" draw-circle)
|
||||||
(on "mouse-up" draw-circle)
|
(on "mouse-up" draw-circle)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user