Created
July 10, 2016 16:28
-
-
Save melklein/b61246f4891075d33dc420a216fe1337 to your computer and use it in GitHub Desktop.
draw lines following the mouse in rainbow colours; base stroke thickness on mouse speed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns mouse-interactivity.core | |
(:require [quil.core :refer :all])) | |
(def max-stroke-weight 40) | |
(defn setup [] | |
(background 255) | |
(color-mode :hsb) | |
(smooth)) | |
(defn draw [] | |
(stroke (mod (frame-count) 360) 255 255) | |
(let [speed-x (abs (- (mouse-x) (pmouse-x))) | |
speed-y (abs (- (mouse-y) (pmouse-y))) | |
new-weight (mod (+ speed-x speed-y) max-stroke-weight)] | |
(stroke-weight new-weight) | |
(line (mouse-x) (mouse-y) (pmouse-x) (pmouse-y)))) | |
(defsketch example | |
:title "Example" | |
:setup setup | |
:draw draw | |
:size [400 400]) | |
(defn -main [& args]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment