Added frame-rect to prelude
This commit is contained in:
parent
0c51b3d32e
commit
5a53fa58f2
@ -1,5 +1,7 @@
|
||||
;
|
||||
(echo "Loading prelude.lisp")
|
||||
;
|
||||
(def frame-rect (frame))
|
||||
; translate
|
||||
(defn translate
|
||||
(r p)
|
||||
|
@ -11,7 +11,7 @@ function Ronin () {
|
||||
b_inv: '#ffb545'
|
||||
}
|
||||
|
||||
this.includes = [] // ['prelude']
|
||||
this.includes = ['prelude']
|
||||
|
||||
this.el = document.createElement('div')
|
||||
this.el.id = 'ronin'
|
||||
|
@ -2,26 +2,25 @@
|
||||
(resetTransform)
|
||||
(clear)
|
||||
;
|
||||
(def w (of (frame) :c))
|
||||
(def h (of (frame) :m ))
|
||||
(def frame-rect (frame))
|
||||
(def mouse-pos (pos))
|
||||
(def prev-pos (pos))
|
||||
;
|
||||
(defn when-mouse-move (e) (
|
||||
(set mouse-pos :x (of e :x))
|
||||
(set mouse-pos :y (of e :y))
|
||||
(set mouse-pos "x" e:x)
|
||||
(set mouse-pos "y" e:y)
|
||||
))
|
||||
;
|
||||
(defn when-animate () (
|
||||
(stroke (line (of prev-pos :x) (of prev-pos :y) (of mouse-pos :x) (of mouse-pos :y)) 4 "#72dec2")
|
||||
(move w h)
|
||||
(stroke (line prev-pos:x prev-pos:y mouse-pos:x mouse-pos:y) 4 "#72dec2")
|
||||
(move frame-rect:c frame-rect:m)
|
||||
(rotate 0.002)
|
||||
(scale 0.998)
|
||||
(translate (frame) (pos (mul -1 w) (mul -1 h)))
|
||||
(translate frame-rect (pos (mul -1 frame-rect:w) (mul -1 frame-rect:h)))
|
||||
(resetTransform)
|
||||
(fill (frame) "#00000004")
|
||||
(set prev-pos :x (of mouse-pos :x))
|
||||
(set prev-pos :y (of mouse-pos :y))
|
||||
(fill frame-rect "#00000004")
|
||||
(set prev-pos "x" mouse-pos:x)
|
||||
(set prev-pos "y" mouse-pos:y)
|
||||
))
|
||||
;
|
||||
(on "animate" when-animate)
|
||||
|
@ -1,12 +1,13 @@
|
||||
; animated recusive spiral
|
||||
; by @local_guru
|
||||
(def frame-rect (frame))
|
||||
(defn rec
|
||||
(v)
|
||||
(if (gt v 0)
|
||||
(
|
||||
; params
|
||||
(def spiral-x (add (:c (frame)) (mul (cos (add (div v 17) (time 0.001))) (div v 2))))
|
||||
(def spiral-y (add (:m (frame)) (mul (sin (div v 11)) (div v 2))))
|
||||
(def spiral-x (add frame-rect:c (mul (cos (add (div v 17) (time 0.001))) (div v 2))))
|
||||
(def spiral-y (add frame-rect:m (mul (sin (div v 11)) (div v 2))))
|
||||
(def spiral-r (div v 2))
|
||||
; draw
|
||||
(stroke (circle spiral-x spiral-y spiral-r) 1 "rgba(114,222,194,0.1)") (rec (sub v 0.3)))))
|
||||
|
@ -5,7 +5,7 @@
|
||||
(cx cy r a)
|
||||
(
|
||||
(stroke
|
||||
(line cx cy (of (circle-pos cx cy r a) :x) (of (circle-pos cx cy r a) :y)
|
||||
(line cx cy (:x (circle-pos cx cy r a)) (:y (circle-pos cx cy r a))
|
||||
) 2 "white")))
|
||||
;
|
||||
(defn draw-star
|
||||
@ -25,12 +25,8 @@
|
||||
()
|
||||
(
|
||||
(draw-star
|
||||
(random 100
|
||||
(of
|
||||
(frame) :w))
|
||||
(random 100
|
||||
(of
|
||||
(frame) :h))
|
||||
(random 100 frame-rect:w)
|
||||
(random 100 frame-rect:h)
|
||||
(random 10 100)
|
||||
(floor
|
||||
(random 3 32))))))
|
37
examples/projects/tunnel.lisp
Normal file
37
examples/projects/tunnel.lisp
Normal file
@ -0,0 +1,37 @@
|
||||
; this demo shows how to use the mouse events to draw make a simple drawing tool.
|
||||
;
|
||||
(clear)
|
||||
;
|
||||
(def prev-pos {:x 0 :y 0})
|
||||
;
|
||||
(defn stroke-color
|
||||
(e)
|
||||
(if
|
||||
(eq e:is-down true) "#ffb545" "#72dec2"))
|
||||
;
|
||||
(defn draw-line
|
||||
(e)
|
||||
(
|
||||
(if
|
||||
(eq e:is-down true)
|
||||
(
|
||||
(debug e:is-down)
|
||||
(stroke
|
||||
(line prev-pos:x prev-pos:y e:x e:y) 2 "white")
|
||||
(set prev-pos "x" e:x "y" e:y)
|
||||
(debug prev-pos)
|
||||
(debug e)))))
|
||||
;
|
||||
(defn draw-circle
|
||||
(e)
|
||||
(
|
||||
(debug e)
|
||||
(set prev-pos "x" e:x "y" e:y)
|
||||
(debug e:x)
|
||||
(stroke
|
||||
(circle e:x e:y 10) 4
|
||||
(stroke-color e))))
|
||||
;
|
||||
(on "mouse-down" draw-circle)
|
||||
(on "mouse-up" draw-circle)
|
||||
(on "mouse-move" draw-line)
|
Loading…
x
Reference in New Issue
Block a user