This document provides a visual overview of creative coding and graphic design techniques using code. It includes examples of static and animated graphics using processing, as well as motion graphics, data visualization, collages, photo manipulation, and 3D graphics. Basic code examples are provided for creating static and animated graphics. Additional resources include links to online tutorials and books about creative coding.
26. basic code example I (static)
source: p5art.tumblr.com
color bg = #352238, f = #87334F;
int step = 50;
float diam = 20;
void setup() {
size(600, 800);
background(bg);
fill(f);
noStroke();
for (int y=step/2; y<height; y +=step) {
for (int x=step/2; x< width; x += step) {
ellipse(x, y, diam, diam);
diam += 0.3;
}
}
}
27. basic code example II (animated)
source: p5art.tumblr.com
float unit, theta;
int num = 20, numFrames = 120;
void setup() {
size(500, 500);
unit = width/num;
noStroke();
}
void draw() {
background(0);
for (int y=0; y<=num; y++) {
for (int x=0; x<=num; x++) {
float distance = dist(width/2, height/2, x*unit, y*unit);
float offSet = map(distance, 0, width/2+height/2, 0, TWO_PI);
float sz = map(sin(theta+offSet),-1,1,unit*.1,unit*.9);
float start = map(sin(theta+offSet),-1,1,0,PI);
float lerpAmount = map(distance, 0, width/2+height/2, 0,1);
color col = lerpColor(#FCE400, #C60C0C, lerpAmount);
fill(col);
arc(x*unit, y*unit, sz, sz,start,start+PI);
}
}
theta += TWO_PI/numFrames;
}
28. don¡¯t be afraid of the math, this is more or less all you need (basic trigonometry)
source: www.zenbullets.com
29. additional resources
A lot of links to free online tutorials (from total beginner
to more advanced) and to creative coding books can be
found at p5art.tumblr.com/tutorials