For our first assignment in Intro to Computational Media, Daniel asked us to play around with shape primitives in Processing and “make something static”.
I started experimenting with shapes and colors and came up with the sun-like sketch below. Note – this isn’t quite static – you can click on the sketch to generate a new, semi-randomized sun. Clicking more to the right will generate more sun rays, and clicking more towards the bottom will alter the background color slightly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
int rays = 24; void setup() { size(640, 460); colorMode(HSB, 100, 100, 100, 100); noStroke(); drawSun(); } void draw() {} void drawSun() { background(map(mouseY, 0, height, 40, 60), 10, 100); pushMatrix(); translate(width / 2, height / 2); rays = (int) map(mouseX, 0, width, 6, 20) * 2; for (int i = 0; i < rays; i++) { fill(random(20), 100, 100, 90); triangle( random(10, 30), random(20, 30), random(20, 30), random(5, 8), width / 2, height / 2 ); rotate(TWO_PI/ rays); } popMatrix(); fill(0, 0, 100); ellipse(width / 2, height / 2, 120, 120); } void mouseReleased() { drawSun(); } |
Afterwards I made this goofy hand/recursion thing that really had nothing to do with the assignment (inspired by this work). Move the mouse around to play with scale etc.
Here’s a screenshot of another version:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
PImage img; int levels = 4; float scale_by = 2; float displace_l = 5; float displace_r = 2; void setup() { size(640, 600); img = loadImage("/wp-content/uploads/2013/09/hand.png"); } void draw() { background(255, 50, 50); scale_by = map(mouseY, 0, height, .5, 6); drawHand(mouseX - img.width/2, height - img.height, 1, levels); } void drawHand(int x, int y, float scale, int level) { image(img, x, y, img.width*scale, img.height*scale); if(level > 1) { level = level - 1; drawHand(x - int(img.width * scale / displace_l), height - int(img.height * (scale / scale_by)), scale / scale_by, level); drawHand(x + int(img.width * scale / displace_r), height - int(img.height * (scale / scale_by)), scale / scale_by, level); } } |