diff --git a/desktop/sources/index.html b/desktop/sources/index.html
index dd1d251..c9ffde9 100644
--- a/desktop/sources/index.html
+++ b/desktop/sources/index.html
@@ -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')
diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js
index 2290fed..978c2ed 100644
--- a/desktop/sources/scripts/commander.js
+++ b/desktop/sources/scripts/commander.js
@@ -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.surface.maximize()
- ronin.interpreter.run(this.cache)
- }
- }
-
- this.loop = () => {
+ ronin.bindings = {}
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)
}
diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js
index 9078761..8145d8a 100644
--- a/desktop/sources/scripts/library.js
+++ b/desktop/sources/scripts/library.js
@@ -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
}
diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js
index daf9e30..fdb214d 100644
--- a/desktop/sources/scripts/ronin.js
+++ b/desktop/sources/scripts/ronin.js
@@ -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
}
diff --git a/examples/animate.lisp b/examples/animate.lisp
index 7943d97..894eccb 100644
--- a/examples/animate.lisp
+++ b/examples/animate.lisp
@@ -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)
\ No newline at end of file
+(defn redraw
+ ()
+ (
+ (clear)
+ (times seg-count draw-dash)))
+(on "animate" redraw)
\ No newline at end of file
diff --git a/examples/benchmark.fs.lisp b/examples/benchmark.fs.lisp
deleted file mode 100644
index 7867c03..0000000
--- a/examples/benchmark.fs.lisp
+++ /dev/null
@@ -1,14 +0,0 @@
-; filesystem
-
-; print path
-(echo
- (filepath))
-; print folder path
-(echo
- (dirpath))
-; print file content
-(echo
- (file))
-; print folder content
-(echo
- (dir))
\ No newline at end of file
diff --git a/examples/benchmark.lisp b/examples/benchmark.lisp
index 03e1e51..dc232c1 100644
--- a/examples/benchmark.lisp
+++ b/examples/benchmark.lisp
@@ -56,4 +56,13 @@
; Interop
(test "interop" ((of (of (js) "Math") "max") 2 4) 4)
- (test "recursive key selector" ((of (js) "Math" "max") 2 4) 4)
\ No newline at end of file
+ (test "recursive key selector" ((of (js) "Math" "max") 2 4) 4)
+
+; fs
+
+; filesystem
+
+(echo (filepath))
+(echo (dirpath))
+(echo (file))
+(echo (dir))
\ No newline at end of file
diff --git a/examples/lambda.lisp b/examples/lambda.lisp
deleted file mode 100644
index d22fb5c..0000000
--- a/examples/lambda.lisp
+++ /dev/null
@@ -1 +0,0 @@
-(echo (map '(add %1 2) (4 5 6))
diff --git a/examples/objects.lisp b/examples/objects.lisp
index e02eca0..cc87ab6 100644
--- a/examples/objects.lisp
+++ b/examples/objects.lisp
@@ -12,4 +12,6 @@
(echo (values ob))
(set ob :a 4)
-(echo (of ob :a))
\ No newline at end of file
+(echo (of ob :a))
+
+(echo (map '(add %1 2) (4 5 6))
diff --git a/examples/osc.lisp b/examples/osc.lisp
index 2a3afc3..a82e98d 100644
--- a/examples/osc.lisp
+++ b/examples/osc.lisp
@@ -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)
\ No newline at end of file