Last active
July 10, 2016 14:34
-
-
Save melklein/33bf82d9838d1b2c8c5bb8a7c320da3a to your computer and use it in GitHub Desktop.
visualisation of gaussian distribution in quil (from The Nature of Code - Daniel Shiffman)
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 fun-mode-sketch | |
(:require [quil.core :as q] | |
[quil.middleware :as m])) | |
(def win-width 400) | |
(def win-height 200) | |
(def sd 60) ;standard deviation | |
(def center-x (/ win-width 2)) | |
(def center-y (/ win-height 2)) | |
(defn setup [] | |
(q/background 255) | |
(q/no-stroke) | |
(q/frame-rate 3)) | |
(defn draw [] | |
(q/fill 228 0 0 20) | |
(let [num (q/random-gaussian) | |
x (* num sd)] | |
(q/push-matrix) | |
(q/translate center-x center-y) | |
(q/ellipse x 0 20 20) | |
(q/pop-matrix))) | |
(q/defsketch example | |
:size [win-width win-height] | |
:setup setup | |
:draw draw) | |
(defn -main [& args]) |
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 fun-mode-sketch | |
(:require [quil.core :as q] | |
[quil.middleware :as m])) | |
(def win-width 400) | |
(def win-height 200) | |
(def sd 60) ;standard deviation | |
(def mean (/ win-width 2)) | |
(def y (/ win-height 2)) | |
(defn setup [] | |
(q/background 255) | |
(q/no-stroke) | |
(q/frame-rate 3)) | |
(defn draw [] | |
(q/fill 228 0 0 20) | |
(let [num (q/random-gaussian) | |
x (+ (* num sd) mean)] | |
(q/ellipse x y 20 20))) | |
(q/defsketch example | |
:size [win-width win-height] | |
:setup setup | |
:draw draw) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment