Redoing the animation example
This commit is contained in:
parent
70fa2b420f
commit
bb887ae6c3
@ -14,4 +14,4 @@ body { margin:0px; padding:0px; overflow:hidden; font-family:"input_mono_regular
|
|||||||
#ronin canvas#guide { background:none; }
|
#ronin canvas#guide { background:none; }
|
||||||
#ronin canvas#surface { border-radius: 2px }
|
#ronin canvas#surface { border-radius: 2px }
|
||||||
|
|
||||||
#ronin.hidden canvas#surface, #ronin.hidden canvas#guide { left:10px; }
|
#ronin.hidden canvas#surface, #ronin.hidden canvas#guide { left:0px; }
|
@ -17,4 +17,18 @@
|
|||||||
(if
|
(if
|
||||||
(gt v 1)
|
(gt v 1)
|
||||||
(times
|
(times
|
||||||
(sub v 1) f))))
|
(sub v 1) f))))
|
||||||
|
; convert deg to radians
|
||||||
|
(defn deg-rad
|
||||||
|
(deg)
|
||||||
|
(mul deg
|
||||||
|
(div PI 180)))
|
||||||
|
; position on a circle from angle
|
||||||
|
(defn circle-pos
|
||||||
|
(cx cy r a) {:x
|
||||||
|
(add cx
|
||||||
|
(mul r
|
||||||
|
(cos a))) :y
|
||||||
|
(add cy
|
||||||
|
(mul r
|
||||||
|
(sin a)))})
|
@ -185,7 +185,7 @@ function Surface (ronin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.maximize = function () {
|
this.maximize = function () {
|
||||||
this.resize({ x: 0, y: 0, w: (window.innerWidth * this.ratio) - 60, h: (window.innerHeight * this.ratio) - 60, t: 'rect' })
|
this.resize({ x: 0, y: 0, w: ((window.innerWidth - 60) * this.ratio), h: ((window.innerHeight - 60) * this.ratio), t: 'rect' })
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onResize = function () {
|
this.onResize = function () {
|
||||||
|
@ -1,17 +1,34 @@
|
|||||||
; animate
|
;
|
||||||
|
(clear)
|
||||||
(clear)
|
;
|
||||||
(def t
|
(def seg-count 20)
|
||||||
(sin
|
;
|
||||||
(div
|
(def center
|
||||||
(time) 100)))
|
(div
|
||||||
(def pos
|
(of
|
||||||
(add 200 30
|
(frame) :h) 2))
|
||||||
(mul 30 t)))
|
;
|
||||||
(defn square
|
(def seg-width
|
||||||
(a)
|
(div
|
||||||
(rect a a a a))
|
(of
|
||||||
(stroke
|
(frame) :w) count))
|
||||||
(square pos) 1 "red")
|
;
|
||||||
; set false to stop
|
(defn draw-dash
|
||||||
(animate true)
|
(i)
|
||||||
|
(
|
||||||
|
(def x
|
||||||
|
(mul
|
||||||
|
(sub i 1) seg-width))
|
||||||
|
(def y
|
||||||
|
(add
|
||||||
|
(mul
|
||||||
|
(sin
|
||||||
|
(add
|
||||||
|
(time 0.01) i)) 15) center))
|
||||||
|
(stroke
|
||||||
|
(line
|
||||||
|
(pos x y)
|
||||||
|
(pos
|
||||||
|
(add x seg-width) y)) 4 "red")))
|
||||||
|
;
|
||||||
|
(times seg-count draw-dash)
|
@ -1,20 +1,6 @@
|
|||||||
; stars
|
; stars
|
||||||
(clear)
|
(clear)
|
||||||
;
|
;
|
||||||
(defn deg-rad
|
|
||||||
(deg)
|
|
||||||
(mul deg
|
|
||||||
(div PI 180)))
|
|
||||||
;
|
|
||||||
(defn circle-pos
|
|
||||||
(cx cy r a) {:x
|
|
||||||
(add cx
|
|
||||||
(mul r
|
|
||||||
(cos a))) :y
|
|
||||||
(add cy
|
|
||||||
(mul r
|
|
||||||
(sin a)))})
|
|
||||||
;
|
|
||||||
(defn draw-spoke
|
(defn draw-spoke
|
||||||
(cx cy r a)
|
(cx cy r a)
|
||||||
(
|
(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user