Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean grow=false;
- public int size=10;
- public float roatateSpeed = 1;
- public int x=0;
- public int y=0;
- public PImage img;
- public int effect = 2;
- void setup() {
- size(500, 500);
- background(0,0,0);
- img = loadImage("C:\\Users\\nrfmunteanu\\Desktop\\dog.jpg");
- frameRate(1000);
- }
- void draw() {
- switch(effect){
- case 0:
- printForward();
- break;
- case 1:
- printBackwards();
- break;
- case 2:
- printSideWays();
- break;
- }
- if(mousePressed) {
- background(0,0,0);
- effect = effect == 2 ? 0: effect+1;
- x=-1;
- }
- }
- PImage getPixel(int x, int y, int size){
- return img.get(x, y, size, size);
- }
- void printForward(){
- if(x==-1) {
- x=0;
- y=0;
- }
- image(getPixel(x, y, size), x,y);
- if(x >= width && y >= height){
- background(0,0,0);
- x=0;
- y=0;
- }
- if(x == width){
- y+= size;
- x=0;
- }else
- x+=size;
- }
- void printBackwards(){
- if(x==-1) {
- x=width;
- y=height;
- }
- image(getPixel(x, y, size), x,y);
- if(x <= 0 && y<=0){
- background(0,0,0);
- x=width;
- y=width;
- }
- if(x <= 0){
- y-= size;
- print (x +"\n");
- x= width;
- }else
- x-=size;
- }
- int x2=0;
- void printSideWays(){
- if(x==-1) {
- x=0;
- y=0;
- x2=width;
- }
- if(x==x2 && y >= height){
- x=0;
- y=0;
- x2=width;
- background(0,0,0);
- }
- image(getPixel(x, y, size), x,y);
- image(getPixel(x2, y, size), x2,y);
- if(x==x2){
- x=0;
- x2=width;
- y+=size;
- }else{
- x+=size;
- x2 -= size;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement