Skip to content

Instantly share code, notes, and snippets.

@dantheobserver
Last active July 16, 2018 18:09
Show Gist options
  • Save dantheobserver/bf161183409d9c01b2812521872f3514 to your computer and use it in GitHub Desktop.
Save dantheobserver/bf161183409d9c01b2812521872f3514 to your computer and use it in GitHub Desktop.

converting this code to clojure for renndering with 2d library Copied from https://twitter.com/TedAjax/status/1004865330831712256 l={10,9,8,2,1} ;; list of colors

l={10,9,8,2,1} ;; list of colors
::_::
cls()srand()for m=0,99 do
x=rnd(8)-4
z=rnd(8)-4
y=rnd(14)-7
for n=4,0,-1 do ;;each orb will be comprised of 3 orbs as a trail
a=t()/4+n*.01
b=t()/4+(n+1)*.01
c=cos(a)*x-sin(a)*z
d=sin(a)*x+cos(a)*z+7
g=64+(c*64)/d
h=64+(y*64)/d
circfill(g,h,max((7-d)+n/2,0),l[4-n+1]) ;;circfill(x, y, r, color)
end
end
flip()goto _
{:deps {org.clojure/clojure {:mvn/version "1.9.0"}
generateme/fastmath {:mvn/version "1.0.3"}}}
(ns experiment.ted_sketch
(:require [fastmath.core :as m]
[fastmath.random :as r]))
(def pico-colors
["#000000" "#1D2B53" "#7E2553" "#008751" "#AB5236" "#5F574F" "#C2C3C7" "#FFF1E8"
"#FF004D" "#FFA300" "#FFEC27" "#00E436" "#29ADFF" "#83769C" "#FF77A8" "#FFCCAA"])
(defrecord Orb [x y r color])
(defn rand-orb [colors time n]
(let [x-seed (r/irand -4 4)
y-seed (r/irand -4 4)
z-seed (r/irand -7 7)]
(for [n [4 0 -1]
:let [color (- 4 (+ n 1))
a (+ (/ time 4) (* n 0.01))
b (+ (/ time 4) (* (inc n) 0.01))
cos-a (m/cos a)
sin-a (m/sin a)
c (- (* cos-a x-seed) (* sin-a z-seed))
d (+ (* sin-a x-seed) (* cos-a z-seed) 7)
x (+ 64 (/ (* c 64) d))
y (+ 64 (/ (* y 64) d))
radius (s/max (0 (+ (- 7 d) (/ n 2))))]]
(->Orb x y r (nth pico-colors color)))))
(defn update-orb [])
(defn orb-seq
(let []))
(let [orb-count 99
color-pics [10 9 8 2 1]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment