Created
July 15, 2020 01:16
-
-
Save cfdrake/85ab5eb0293b485d05a93a5e1e2510aa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
void setup() { | |
// Set window size. | |
size(600, 600); | |
// Use for high def monitors. | |
pixelDensity(2); | |
// Turn off looping draw(), only run once. | |
noLoop(); | |
} | |
void draw() { | |
// Stipple texture in BG. | |
for (int i = 0; i < 400000; i++) { | |
float rx = random(0, width); | |
float ry = random(0, height); | |
stroke(0, 0, 0, 20); // R, G, B, alpha (all 0-255), a little transparent | |
point(rx, ry); // plot a pixel | |
} | |
// Start of new coordinate system! | |
pushMatrix(); | |
// Move to center of screen. | |
translate(width / 2, height / 2); | |
// Draw first layer of spiral. | |
// Random is min max values, ceil just rounds up. | |
// Stroke is R G B Alpha. | |
// Rect is X Y Width Height. | |
float rotateBy = ceil(random(4, 32)); | |
stroke(0, 0, 0, 255); // totally opaque | |
for (int i = 0; i < 400; i += rotateBy) { | |
rotate(radians(rotateBy)); | |
rect(0, 0, 200, 150); | |
} | |
// Draw second layer of spiral. | |
rotateBy = ceil(random(4, 32)); | |
for (int i = 0; i < 500; i += rotateBy) { | |
rotate(radians(rotateBy)); | |
rect(0, 0, 150, 100); | |
} | |
// Draw third layer of spiral. | |
rotateBy = ceil(random(4, 32)); | |
for (int i = 0; i < 360; i += rotateBy) { | |
rotate(radians(rotateBy)); | |
rect(0, 0, 120, 100); | |
} | |
// Draw circle at center of screen. | |
circle(0, 0, 100); | |
// Abandon our coordinate system. | |
// Resets (0, 0) to upper left and resets rotation. | |
popMatrix(); | |
// Move (0, 0) to center of screen. Can address with simple relative coordinates again. | |
// We needed to popMatrix() to reset the rotation mainly. | |
translate(width / 2, height / 2); | |
stroke(0, 0, 0, 20); // a little transparent | |
// Stipple texture the center of the circle. | |
for (int i = 0; i < 10000; i++) { | |
float rx = random(-50, 50); | |
float ry = random(-50, 50); | |
// Check is within circle. | |
if (dist(0, 0, rx, ry) < 50) { | |
point(rx, ry); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment