Created
November 6, 2014 13:43
-
-
Save johnniehard/1639c2d8b3ad0f5d5bf4 to your computer and use it in GitHub Desktop.
Take parts of an image and shuffle them around
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
//ta delar ur en bild och shuffla runt dem | |
int col = 4; //even numbers | |
int row = 2; | |
int w; | |
int h; | |
PImage img; | |
PImage[] delar = new PImage[col*row]; | |
void setup() { | |
img = loadImage("image.jpg"); | |
img.resize(600, 400); //even numbers | |
size(img.width, img.height); | |
w = img.width/col; | |
h = img.height/row; | |
int delCount = 0; | |
for (int x = 0; x < img.width; x+=w) { | |
for (int y = 0; y < img.height; y+=h) { | |
delar[delCount] = img.get(x, y, w, h); | |
if (delCount < delar.length-1) { | |
delCount++; | |
} | |
} | |
} | |
int counter = 0; | |
for (int x = 0; x < img.width; x+=w) { | |
for (int y = 0; y < img.height; y+=h) { | |
image(delar[int(random(delar.length))], x, y); | |
if (counter < delar.length-1) { | |
counter++; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment