add animation
This commit is contained in:
parent
391874841b
commit
fccfb598d9
@ -42,6 +42,7 @@
|
||||
ronin.controller.addRole('default', 'Edit', 'selectall')
|
||||
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", "Toggle Animation (experimental)",() => { ronin.commander.toggleAnimation(); },"CmdOrCtrl+Shift+T");
|
||||
ronin.controller.add("default","Commander","Toggle",() => { ronin.commander.toggle(); },"CmdOrCtrl+K");
|
||||
ronin.controller.commit();
|
||||
ronin.install(document.body);
|
||||
|
@ -4,6 +4,7 @@ function Commander (ronin) {
|
||||
this._input = document.createElement('textarea')
|
||||
this._status = document.createElement('div')
|
||||
this._status.id = 'status'
|
||||
this.isAnimated = false
|
||||
|
||||
this.install = function (host) {
|
||||
this.el.appendChild(this._input)
|
||||
@ -20,12 +21,18 @@ function Commander (ronin) {
|
||||
this.hide()
|
||||
}
|
||||
|
||||
this.run = function (txt = this._input.value) {
|
||||
this.run = (txt = this._input.value) => {
|
||||
if (txt.indexOf('$') > -1) { ronin.log('Present: $'); return }
|
||||
console.log('========')
|
||||
!this.isAnimated && console.log('========')
|
||||
ronin.surface.maximize()
|
||||
const inter = new Lisp(txt, ronin.library)
|
||||
inter.toPixels()
|
||||
this.isAnimated && requestAnimationFrame(() => this.run(txt))
|
||||
}
|
||||
|
||||
this.toggleAnimation = () => {
|
||||
this.isAnimated = !this.isAnimated
|
||||
this.run(this._input.value)
|
||||
}
|
||||
|
||||
this.load = function (txt) {
|
||||
|
@ -253,4 +253,8 @@ function Library (ronin) {
|
||||
}
|
||||
return a === b
|
||||
}
|
||||
|
||||
// Livecoding
|
||||
|
||||
this.time = Date.now
|
||||
}
|
||||
|
10
examples/animation.lisp
Normal file
10
examples/animation.lisp
Normal file
@ -0,0 +1,10 @@
|
||||
; animation
|
||||
; click Project > Toggle Animation
|
||||
|
||||
(
|
||||
(def t (sin (div (time) 100)))
|
||||
|
||||
(def pos (add 200 (mul 30 t)))
|
||||
(def square (lambda (a) (rect (add 200 a) a a a)))
|
||||
(stroke (square pos) 1 "red")
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user