Skip to content

Instantly share code, notes, and snippets.

@memish
Last active December 4, 2018 16:54
Show Gist options
  • Save memish/3077b4f4ea55476c49685ee6a1d2b06c to your computer and use it in GitHub Desktop.
Save memish/3077b4f4ea55476c49685ee6a1d2b06c to your computer and use it in GitHub Desktop.
import java.io.FilenameFilter;
int counter = 1;
int pn = 16;
PImage img; // Declare a variable of type PImage
PImage[][] pieceArray = new PImage[pn][pn];
int width = 800;
int height = 600;
void setup() {
frameRate(1);
size(800, 600);
// Make a new instance of a PImage by loading an image file
// pieceArray[0][0] = img.get(0, 0, 200,200);
// pieceArray[1][0] = img.get(200, 0, 200,200);
}//end of setup
void draw() {
loadNextImage();
background(0);
for (int i = 0; i <pn; i++) {
for (int j = pn-1; j >=0; j--) {
int rr=int(random(0,pn));
int ry=int(random(0,pn));
image(pieceArray[rr][ry],i * width / pn, j * height/pn);
}}
// image(pieceArray[0][0], 200, 0);
// Draw the image to the screen at coordinate (0,0)
/*
for (int i = 0; i <4; i++) {
for (int j = 3; j >=0; j--) {
image(pieceArray[i][j], i * width / 4, j * height/4);
}
}
*/
// image(img, 800, 800);
}
public void loadNextImage(){
img = loadImage("faculty/" + counter + ".jpg");
img.resize(800, 600);
/* */
for (int i = 0; i < pn; i++) {
for (int j = 0; j < pn; j++) {
pieceArray[i][j] = img.get(i * width/pn, j * height/pn, width/pn, height/pn);
}
}
counter++;
if(counter>10){
counter = 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment