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","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","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","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","Open Theme",() => { ronin.theme.open() },"CmdOrCtrl+Shift+O")
|
||||||
ronin.controller.add("default","Theme","Reset Theme",() => { ronin.theme.reset() },"CmdOrCtrl+Shift+Backspace")
|
ronin.controller.add("default","Theme","Reset Theme",() => { ronin.theme.reset() },"CmdOrCtrl+Shift+Backspace")
|
||||||
ronin.controller.addSpacer('default', 'Theme', 'Download')
|
ronin.controller.addSpacer('default', 'Theme', 'Download')
|
||||||
|
@ -31,25 +31,13 @@ function Commander (ronin) {
|
|||||||
this.hide()
|
this.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cache = ''
|
|
||||||
|
|
||||||
this.run = (txt = this._input.value) => {
|
this.run = (txt = this._input.value) => {
|
||||||
if (txt.indexOf('$') > -1) { ronin.log('Present: $'); return }
|
ronin.bindings = {}
|
||||||
this.cache = txt
|
|
||||||
if (ronin.always !== true) {
|
|
||||||
ronin.surface.maximize()
|
|
||||||
ronin.interpreter.run(this.cache)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.loop = () => {
|
|
||||||
ronin.surface.maximize()
|
ronin.surface.maximize()
|
||||||
ronin.interpreter.run(this.cache)
|
ronin.interpreter.run(txt)
|
||||||
ronin.always === true && requestAnimationFrame(() => this.loop())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.load = function (txt) {
|
this.load = function (txt) {
|
||||||
ronin.animate(false)
|
|
||||||
this._input.value = txt
|
this._input.value = txt
|
||||||
this.run(txt)
|
this.run(txt)
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ function Library (ronin) {
|
|||||||
|
|
||||||
this.map = async (fn, arr) => {
|
this.map = async (fn, arr) => {
|
||||||
for (let i = 0; i < arr.length; i++) {
|
for (let i = 0; i < arr.length; i++) {
|
||||||
const arg = arr[i];
|
const arg = arr[i]
|
||||||
await fn(arg)
|
await fn(arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -437,10 +437,6 @@ function Library (ronin) {
|
|||||||
return (Date.now() * rate)
|
return (Date.now() * rate)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.animate = (play = true) => { // Toggles animation.
|
|
||||||
ronin.animate(play)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.js = () => { // Javascript interop.
|
this.js = () => { // Javascript interop.
|
||||||
return window
|
return window
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,6 @@ function Ronin () {
|
|||||||
this.interpreter = new Lisp(this.library, this.includes)
|
this.interpreter = new Lisp(this.library, this.includes)
|
||||||
this.osc = new Osc(this)
|
this.osc = new Osc(this)
|
||||||
|
|
||||||
// Parameters
|
|
||||||
this.always = false
|
|
||||||
this.bindings = {}
|
this.bindings = {}
|
||||||
|
|
||||||
this.install = function (host = document.body) {
|
this.install = function (host = document.body) {
|
||||||
@ -48,6 +46,14 @@ function Ronin () {
|
|||||||
this.commander.start()
|
this.commander.start()
|
||||||
this.surface.start()
|
this.surface.start()
|
||||||
this.osc.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 () {
|
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.bind = (event, fn) => {
|
||||||
this.bindings[event] = fn
|
this.bindings[event] = fn
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
;
|
|
||||||
(clear)
|
|
||||||
;
|
|
||||||
(def seg-count 50)
|
(def seg-count 50)
|
||||||
;
|
;
|
||||||
(def frame-middle
|
(def frame-middle
|
||||||
@ -47,4 +44,9 @@
|
|||||||
(frame) :w) 0)
|
(frame) :w) 0)
|
||||||
("rgba(255,255,255,0)" "white" "#72dec2" "red")))))
|
("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))
|
|
@ -56,4 +56,13 @@
|
|||||||
|
|
||||||
; Interop
|
; Interop
|
||||||
(test "interop" ((of (of (js) "Math") "max") 2 4) 4)
|
(test "interop" ((of (of (js) "Math") "max") 2 4) 4)
|
||||||
(test "recursive key selector" ((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))
|
|
@ -12,4 +12,6 @@
|
|||||||
(echo (values ob))
|
(echo (values ob))
|
||||||
|
|
||||||
(set ob :a 4)
|
(set ob :a 4)
|
||||||
(echo (of ob :a))
|
(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
|
(defn on-msg
|
||||||
(msg)
|
(msg)
|
||||||
(
|
(
|
||||||
(clear)
|
|
||||||
(def msg-value
|
(def msg-value
|
||||||
(of
|
(of
|
||||||
(first msg) :value))
|
(first msg) :value))
|
||||||
(stroke
|
(set ring :r 150)))
|
||||||
(circle 300 300 150) 2
|
; frame
|
||||||
(if
|
(set ring :r
|
||||||
(eq msg-value 1) "#ffb545" "#72dec2" ))))
|
(sub
|
||||||
|
(of ring :r) 1))
|
||||||
|
(redraw)
|
||||||
; trigger
|
; trigger
|
||||||
(on "/a" on-msg)
|
(on "/a" on-msg)
|
Loading…
x
Reference in New Issue
Block a user