// // an endless picture scroller // // no copyright, january 2007, benn:org // String imgFilePath = "mehr.jpg"; int imgWidth = 200; // should match image file width int imgHeight = 200; // should match image file height float scrollSpeed = 0.1; // the larger the number, the faster the scrolling float x; float y; PImage img; void setup() { size(200, 200); // should match image dimensions frameRate(50); // we want a lot of frames for smooth scrolling img = loadImage(imgFilePath); } void draw() { // measure distance of mouse from sketch center and use as // accelerator, slow down by a factor x = x - (mouseX-width/2) * scrollSpeed; y = y - (mouseY-height/2) * scrollSpeed; // wrap movement around if (x < 0) { x = width; } if (x > width) { x = 0; } if (y < 0) { y = height; } if (y > height) { y = 0; } // draw 4 copies of the image to have no gaps image(img, x, y); image(img, x, y-height); image(img, x-width, y); image(img, x-width, y-height); }