add (animate)

This commit is contained in:
Quentin Leonetti 2019-07-17 23:00:21 +02:00
parent 77eb301d3e
commit 521ece7937
3 changed files with 12 additions and 5 deletions

View File

@ -1,4 +1,5 @@
function Library (ronin) {
console.log(ronin)
this.open = async (path) => {
return ronin.surface.open(path)
}
@ -326,12 +327,15 @@ function Library (ronin) {
return a === b
}
// Client
this.ronin = ronin
// Livecoding
this.time = Date.now
this.animate = (b = true) => ronin.animate(b)
// javascript interop
this.js = window
// Client
this.ronin = ronin
}

View File

@ -146,6 +146,10 @@
`(time)` returns timestamp in milliseconds
`(animate)` start animation
`(animate false)` stop animation
## Javascript interop
`js`

View File

@ -1,13 +1,12 @@
; animate
(
(def start (get ronin "animate"))
(def t (sin (div (time) 100)))
(def pos (add 200 (mul 30 t)))
(defn square (a) (rect a a a a))
(stroke (square pos) 1 "red")
(start)
(animate)
;(animate false) to stop animation
)