Created
March 14, 2019 22:35
-
-
Save mrmemmo/6ba02f14d25cf2632466d0c47c43d61b to your computer and use it in GitHub Desktop.
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
import java.io.FilenameFilter; | |
int counter = 1; | |
int pn = 16;//number of puzzle pieces | |
PImage img; // Declare a variable of type PImage | |
PImage[][] pieceArray = new PImage[pn][pn];//array of images | |
int width = 800; | |
int height = 600; | |
void setup() { | |
frameRate(5); | |
size(800, 600); | |
loadNextImage(); | |
}//end of setup | |
void draw() { | |
background(0); | |
image(pieceArray[0][0],width/pn, height/pn); | |
} | |
void loadNextImage(){ | |
img = loadImage("images/" + 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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment