Last active
December 31, 2015 06:48
-
-
Save errete/7949653 to your computer and use it in GitHub Desktop.
code for the cover of http://8tracks.com/danielrt/33
This file contains 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
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