Pushing pixels
in
Programming Questions
•
1 year ago
Hi I've been trying to work out how to get this effect on images. Here are a few examples
I've had a go myself but I can't seem to get the same results.
- PImage img;
- int s = 0;
- void setup() {
- img = loadImage("mount.jpeg");
- size(img.width, img.height, P2D);
- image(img,0,0,img.width,img.height);
- println("img w = " + img.width);
- println("img h = " + img.height);
- }
- void draw() {
- for(int x = 0; x < img.width; x++) {
- for(int y = 0; y < img.height; y++) {
- if(random(1000) > 950) {
- set(x, y+1, get(x,y));
- }
- }
- }
- }
- void keyPressed() {
- if(key == 'p') {
- noLoop();
- }
- if(key == 's') {
- save("outputs"+ s + ".png");
- println("image saved " + s);
- s++;
- }
- }
My output
Any points in the right direction would be great.
Thanks
Sam.
1