Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PImage img, img1, img2, img3, img4, img5, img6, img7, img8, img9; // Declare a variable of type PImage
int x = 0;
int y = 0;
int bigdistance = 4000;
int distance = 400;
int gridpoints = (bigdistance/distance);
int picheight = 421,picwidth = 0;
int counter = 1;
void setup() {
size(4000,4000);
// background(255, 123, 41);
background(0, 255, 226);
//background(237, 26, 150);
imageMode(CENTER);
img1 = loadImage("diamond (1).PNG");
img2 = loadImage("diamond (2).PNG");
img3 = loadImage("diamond (3).PNG");
img4 = loadImage("diamond (4).PNG");
img5 = loadImage("diamond (5).PNG");
img6 = loadImage("diamond (6).PNG");
img7 = loadImage("diamond (7).PNG");
img8 = loadImage("diamond (8).PNG");
img9 = loadImage("diamond (9).PNG");
img1.resize(picheight,picwidth);
img2.resize(picheight,picwidth);
img3.resize(picheight,picwidth);
img4.resize(picheight,picwidth);
img5.resize(picheight,picwidth);
img6.resize(picheight,picwidth);
img7.resize(picheight,picwidth);
img8.resize(picheight,picwidth);
img9.resize(picheight,picwidth);
noLoop();
}
void draw() {
for (int j = 0; j < 200; j++){
for (int i = 0; i < gridpoints+1; i++){
pushMatrix();
// Make a new instance of a PImage by loading an image file
//int random = int(random(4));
/*x = int(random(2000));
y = int(random(2000));*/
if (counter == 1){
img = img1;
} else if (counter == 2){
img = img2;
} else if (counter == 3){
img = img3;
}else if (counter == 4){
img = img4;
}else if (counter == 5){
img = img5;
}else if (counter == 6){
img = img6;
}else if (counter == 7){
img = img7;
}else if (counter == 8){
img = img8;
}else if (counter == 9){
img = img9;
}
counter++;
if (counter == 10){
counter = 1;
}
//translate(x+picheight/2,y+picwidth/2);
translate(x,y);
//translate(img.width/2, img.height/2);
//int twisty = int((random(360)));
//rotate(radians(int(random(360))));
image(img,0,0);
x += distance;
popMatrix();
}
if ((x % distance) == 0){
x = (distance/2);
} else {
x = 0;
}
y += 116;
}
save("diamonds.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.