Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PImage img, img2;
- int div = 15;
- int step = 5;
- float scal = 1.5;
- void setup() {
- img = loadImage("h1.jpg");
- img2 = loadImage("h2.jpg");
- size(img.width, img.height);
- //size(480, 500);
- //distort();
- }
- void draw() {
- distort();
- }
- void distort() {
- int stepx = (int) width/div;
- int stepy = (int) height/div;
- for (int y=0; y<height; y += stepy) {
- for (int x=0; x<width; x += stepx) {
- float rx = random(-step, step);
- float ry = random(-step, step);
- if (x > width/2) {
- copy(img2, x, y, stepx, stepy, int(x + rx), int(y+ry), int(stepx*scal), int(stepy*scal));
- }
- else {
- copy(img, x, y, stepx, stepy, int(x + rx), int(y+ry), int(stepx*scal), int(stepy*scal));
- }
- stroke(255);
- strokeWeight(5);
- noFill();
- }
- }
- }
- void mouseClicked() {
- saveFrame("image-###.gif");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement