Skip to content

Instantly share code, notes, and snippets.

@errete
Last active December 31, 2015 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save errete/7949653 to your computer and use it in GitHub Desktop.
Save errete/7949653 to your computer and use it in GitHub Desktop.
code for the cover of http://8tracks.com/danielrt/33
int i, j; // loops
color[] c={
color(234, 38, 92), // red
color(5, 130, 204), // blue
color(144, 204, 0), // green
color(254, 183, 0) // orange
};
int[] displacement=new int[2]; // [0=x; 1=y]
int sSize=8; // squares size
PGraphics n33; // raster "33"
int gray; // color of current pixel
PFont fnt=createFont("HelveticaNeue-Bold", 54);
void setup() {
size(1440, 1440);
background(255);
// creating the raster "33"
n33=createGraphics(90, 90);
n33.beginDraw();
n33.background(255);
n33.fill(0);
n33.textFont(fnt);
n33.textAlign(CENTER, TOP);
n33.text("33.", 45, 26);
n33.endDraw();
noStroke();
for (i=0; i<90; i++) {
for (j=0; j<90; j++) {
gray=16-round(red(n33.pixels[i+j*n33.width])/16);
displacement[0]=i-45+gray;
displacement[1]=j-45+gray;
fill(c[floor(random(c.length))], 91+round(random(2)*gray));
quad( // top face
i*16,
j*16,
i*16+sSize,
j*16,
i*16+sSize+displacement[0],
j*16+displacement[1],
i*16+displacement[0],
j*16+displacement[1]
);
quad( // left face
i*16,
j*16,
i*16,
j*16+sSize,
i*16+displacement[0],
j*16+displacement[1]+sSize,
i*16+displacement[0],
j*16+displacement[1]
);
quad( // bottom face
i*16,
j*16+sSize,
i*16+displacement[0],
j*16+displacement[1]+sSize,
i*16+displacement[0]+sSize,
j*16+displacement[1]+sSize,
i*16+sSize,
j*16+sSize
);
quad( // right face
i*16+sSize+displacement[0],
j*16+displacement[1],
i*16+sSize,
j*16,
i*16+sSize,
j*16+sSize,
i*16+displacement[0]+sSize,
j*16+displacement[1]+sSize
);
}
}
// uncoment the next line to save
//save("portada_32.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment