Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int cols = 8, rows = cols, w, h;
- Square[] squares = new Square[rows*cols];
- PImage img;
- long rs = (long) 123564;
- void setup() {
- size(100, 100);
- img = loadImage("https://s-media-cache-ak0.pinimg.com/736x/b9/09/fb/b909fb80abb83d4386e45b79002b68fb.jpg");
- w = 540/cols;
- h = 540/rows;
- surface.setResizable(true);
- surface.setSize(img.width+int(w*1.5), img.height+int(h*1.25));
- int i=0;
- for (int x=0; x<rows; x++) {
- for (int y=0; y<cols; y++) {
- squares[i] = new Square(x*w, y*h);
- i++;
- }
- }
- }
- void draw() {
- //rs = (long) random(1234567);
- randomSeed(rs);
- background(255);
- for (int i=0; i<cols*rows; i++) {
- squares[i].update();
- squares[i].display();
- }
- //if (frameCount<=10) saveFrame("image-###.jpg");
- }
- void mouseReleased() {
- rs = (long) random(1234567);
- }
- class Square {
- PGraphics square;
- PImage temp;
- int x, y;
- Square(int _x, int _y) {
- x = int(_x+w*.75);
- y = _y+25;
- square = createGraphics(w, h);
- }
- void update() {
- square.beginDraw();
- //square.background(255);
- //square.fill(0);
- square.copy(img,x-w,y-h,w*2,h*2,int(random(-w/2)),int(random(-h/2)),w*2,h*2);
- square.endDraw();
- }
- void display() {
- //tint(255,125);
- image(square, x, y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement