Starting Steps of Generative Art

29 Dec, 2019 - 19:14:17

By

Matthew Deig

Why this road

I got inspire by my visit up to the Vintage Computer Festival Midwest with their talk on the computer that made the Death Star plans graphics. Then later on this year I saw this post Functional Christmas Article on Generative Art and I recently was picking up Clojure and was thinking that I could use this to do something like I saw at the Festival. Turns out it wasn't too bad to try to get something like it, because I found this video of retro computer graphics so I dug in.

First Attempt

I started out doing circles to get some polar coordinates down and some other functions but I ended up switching to lines and came up with this

Unfortunately I don't have the code that made that video.

My other experiments

A few more of my experiments.

My Final Experiment of the Day

While I was working on the lines I decided to add more lines to the animation. When I was doing that it started to look like a ship scanning something so I ended up creating what I was seeing.

I do have the code for that

``` (defn polar-conv-x [r x] ( r (q/cos x))) (defn polar-conv-y [r y] ( r (q/sin y)))

(defn parametic-fun-x [x] (+ (q/sin (/ x 10.5)) (q/cos (/ x 5.5))))

(defn parametic-fun-y [y] (+ (q/cos (/ y 2)) (q/sin (/ y 4))))

(defn setup [] ; Set frame rate to 30 frames per second. (q/frame-rate 30) ; Set color mode to HSB (HSV) instead of default RGB. (q/color-mode :hsb) (q/background 0) ; setup function returns initial state. It contains ; circle color and position. {:color 0 :t 0})

(defn update-state [state] ; Update sketch state by changing circle color and position. {:color (mod (+ (:color state) 0.7) 255) :t (+ (:t state) 0.1)})

(defn draw-state [state] ; Clear the sketch by filling it with light-grey color. (q/background 0) ; Set circle color. (q/stroke (:color state) 255 255) ; Calculate x and y coordinates of the circle. (let [t (:t state) x (polar-conv-x ( t 2) (parametic-fun-x t)) y (polar-conv-y ( t 2) (parametic-fun-y t))] ; Move origin point to the center of the sketch. (q/with-translation [(/ (q/width) 2) (/ (q/height) 2)] ; Draw the circle. (q/line x y ( -1 y) ( -1 x)) (q/line ( -1 x) ( -1 y) ( -1 y) ( -1 x)) (q/line x ( -1 y) ( -1 y) ( -1 x)) (q/line ( -1 x) y ( -1 y) ( -1 x)) (q/line x ( -1 y) ( -1 x) ( -1 y)) (q/line x y ( -1 x) y) (q/line x ( -1 y) x y) (q/line ( -1 x) y ( -1 x) ( -1 y)) ))) ```