Day 22 - Transformer Cube
I started this sketch trying to put together a bunch of cubes into one larger cube shape to learn more about working with 3D. It quickly divulged from there into…whatever this is! It almost feels like maybe the lamest transformer ever? I couldn’t get the controls right, so I just slowed the frame rate way down and added the ability to save it if a drawing you like pops up by pressing the “s” key.
Sketch:
Drawings:
Code:
function setup() { createCanvas(700, 700, WEBGL); strokeWeight(1); stroke(50); frameRate(0.5); } function draw() { background(50); let s1 = random(50, 150); let s2 = random(50, 150); let s3 = random(50, 150); rotateX(millis(2000) / 2000); rotateY(millis(2000) / 2000); fill(s1, s2, s3); box(s1, s2, s3); fill(s2, s1, s1); translate(80, 0); box(s2, s1, s1); fill(s3, s1, s2); translate(0, 0, 80); box(s3, s1, s2); fill(s3, s2, s2); translate(-80, 0); box(s3, s2, s2); fill(s1, s3, s3); translate(0, 80); box(s1, s3, s3); fill(s2, s3, s2); translate(80, 0); box(s2, s3, s2); fill(s2, s2, s1); translate(0, 0, -80); box(s2, s2, s1); fill(s3, s1, s3); translate(-80, 0); box(s3, s1, s3); } function keyReleased() { if (key == 's' || key == 'S') saveCanvas(); }