Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; add a brush that blends by lightening the color
- (add-linear-brush
- :transparent2
- {:blend {:from "ONE" :to "ONE"}
- :vertex-shader {(g/gl-position) default-vertex-position
- v-value a-value}
- :fragment-shader
- {(g/gl-frag-color) (g/vec4 u-color 1)}})
- ;; save where the stroke started (needed for sin wave)
- (set! stroke-started
- (fn [point]
- (swap! app-state assoc :start-point point)))
- ;; make a sin wave
- (set! constrain-stroke
- (fn [point dir]
- (let [p (geom/+ point (v/vec2 (nth dir 0) 0))]
- (v/vec2 (nth p 0)
- (+ (nth (:start-point @app-state) 1)
- (* (.sin js/Math (/ (nth p 0) 50)) 30))
- ))))
- ;; lock to the x-axis
- (set! constrain-stroke
- (fn [point dir]
- (geom/+ point (v/vec2 (nth dir 0) 0))))
- (repl-swap! :current-brush :transparent2)
- (repl-swap! :background-color "#b0ccbb")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement