Added "animate" binding, fixes #70
This commit is contained in:
parent
00dc10894e
commit
7e99df545e
@ -50,7 +50,6 @@
|
||||
ronin.controller.add("default","View","Expand Commander",() => { ronin.commander.toggle(true); },"CmdOrCtrl+Shift+K");
|
||||
ronin.controller.add("default","Project","Run",() => { ronin.commander.run(); },"CmdOrCtrl+R");
|
||||
ronin.controller.add("default","Project","Reload Run",() => { ronin.source.revert(); ronin.commander.run(); },"CmdOrCtrl+Shift+R");
|
||||
ronin.controller.add("default","Project", "Animate",() => { ronin.animate(!ronin.always); },"CmdOrCtrl+Shift+T");
|
||||
ronin.controller.add("default","Theme","Open Theme",() => { ronin.theme.open() },"CmdOrCtrl+Shift+O")
|
||||
ronin.controller.add("default","Theme","Reset Theme",() => { ronin.theme.reset() },"CmdOrCtrl+Shift+Backspace")
|
||||
ronin.controller.addSpacer('default', 'Theme', 'Download')
|
||||
|
@ -31,25 +31,13 @@ function Commander (ronin) {
|
||||
this.hide()
|
||||
}
|
||||
|
||||
this.cache = ''
|
||||
|
||||
this.run = (txt = this._input.value) => {
|
||||
if (txt.indexOf('$') > -1) { ronin.log('Present: $'); return }
|
||||
this.cache = txt
|
||||
if (ronin.always !== true) {
|
||||
ronin.bindings = {}
|
||||
ronin.surface.maximize()
|
||||
ronin.interpreter.run(this.cache)
|
||||
}
|
||||
}
|
||||
|
||||
this.loop = () => {
|
||||
ronin.surface.maximize()
|
||||
ronin.interpreter.run(this.cache)
|
||||
ronin.always === true && requestAnimationFrame(() => this.loop())
|
||||
ronin.interpreter.run(txt)
|
||||
}
|
||||
|
||||
this.load = function (txt) {
|
||||
ronin.animate(false)
|
||||
this._input.value = txt
|
||||
this.run(txt)
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ function Library (ronin) {
|
||||
|
||||
this.map = async (fn, arr) => {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const arg = arr[i];
|
||||
const arg = arr[i]
|
||||
await fn(arg)
|
||||
}
|
||||
}
|
||||
@ -437,10 +437,6 @@ function Library (ronin) {
|
||||
return (Date.now() * rate)
|
||||
}
|
||||
|
||||
this.animate = (play = true) => { // Toggles animation.
|
||||
ronin.animate(play)
|
||||
}
|
||||
|
||||
this.js = () => { // Javascript interop.
|
||||
return window
|
||||
}
|
||||
|
@ -24,8 +24,6 @@ function Ronin () {
|
||||
this.interpreter = new Lisp(this.library, this.includes)
|
||||
this.osc = new Osc(this)
|
||||
|
||||
// Parameters
|
||||
this.always = false
|
||||
this.bindings = {}
|
||||
|
||||
this.install = function (host = document.body) {
|
||||
@ -48,6 +46,14 @@ function Ronin () {
|
||||
this.commander.start()
|
||||
this.surface.start()
|
||||
this.osc.start()
|
||||
this.loop()
|
||||
}
|
||||
|
||||
this.loop = () => {
|
||||
if (this.bindings['animate'] && typeof this.bindings['animate'] === 'function') {
|
||||
this.bindings['animate']()
|
||||
}
|
||||
requestAnimationFrame(() => this.loop())
|
||||
}
|
||||
|
||||
this.reset = function () {
|
||||
@ -62,12 +68,6 @@ function Ronin () {
|
||||
|
||||
}
|
||||
|
||||
this.animate = (b = true) => {
|
||||
if (this.always === b) { return }
|
||||
this.always = b
|
||||
this.commander.loop()
|
||||
}
|
||||
|
||||
this.bind = (event, fn) => {
|
||||
this.bindings[event] = fn
|
||||
}
|
||||
|
@ -1,6 +1,3 @@
|
||||
;
|
||||
(clear)
|
||||
;
|
||||
(def seg-count 50)
|
||||
;
|
||||
(def frame-middle
|
||||
@ -47,4 +44,9 @@
|
||||
(frame) :w) 0)
|
||||
("rgba(255,255,255,0)" "white" "#72dec2" "red")))))
|
||||
;
|
||||
(times seg-count draw-dash)
|
||||
(defn redraw
|
||||
()
|
||||
(
|
||||
(clear)
|
||||
(times seg-count draw-dash)))
|
||||
(on "animate" redraw)
|
@ -1,14 +0,0 @@
|
||||
; filesystem
|
||||
|
||||
; print path
|
||||
(echo
|
||||
(filepath))
|
||||
; print folder path
|
||||
(echo
|
||||
(dirpath))
|
||||
; print file content
|
||||
(echo
|
||||
(file))
|
||||
; print folder content
|
||||
(echo
|
||||
(dir))
|
@ -57,3 +57,12 @@
|
||||
; Interop
|
||||
(test "interop" ((of (of (js) "Math") "max") 2 4) 4)
|
||||
(test "recursive key selector" ((of (js) "Math" "max") 2 4) 4)
|
||||
|
||||
; fs
|
||||
|
||||
; filesystem
|
||||
|
||||
(echo (filepath))
|
||||
(echo (dirpath))
|
||||
(echo (file))
|
||||
(echo (dir))
|
@ -1 +0,0 @@
|
||||
(echo (map '(add %1 2) (4 5 6))
|
@ -13,3 +13,5 @@
|
||||
|
||||
(set ob :a 4)
|
||||
(echo (of ob :a))
|
||||
|
||||
(echo (map '(add %1 2) (4 5 6))
|
||||
|
@ -1,13 +1,24 @@
|
||||
;
|
||||
(def ring
|
||||
(circle 300 300 150))
|
||||
;
|
||||
(defn redraw
|
||||
()
|
||||
(
|
||||
(clear)
|
||||
(stroke ring 2 "red")))
|
||||
;
|
||||
(defn on-msg
|
||||
(msg)
|
||||
(
|
||||
(clear)
|
||||
(def msg-value
|
||||
(of
|
||||
(first msg) :value))
|
||||
(stroke
|
||||
(circle 300 300 150) 2
|
||||
(if
|
||||
(eq msg-value 1) "#ffb545" "#72dec2" ))))
|
||||
(set ring :r 150)))
|
||||
; frame
|
||||
(set ring :r
|
||||
(sub
|
||||
(of ring :r) 1))
|
||||
(redraw)
|
||||
; trigger
|
||||
(on "/a" on-msg)
|
Loading…
x
Reference in New Issue
Block a user