We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi Everyone,
I am currently making a mosaic for a Christmas prezzy. How can i use a scrollbar to display the pixels that are outside the window as i move the scrollbar across? A simple example is an image of 900px x 700px but the processing window in only 450px x 350px. The scrollbar will only be used to inspect the hidden portions of the image, to ensure that the effect works as it should across the whole image. I got the idea from The Coding Train Youtube channel. Link is Any help would be greatly appreciated.
Answers
Consider checking prev related posts:
https://forum.processing.org/two/search?Search=panning
Kf
There are heavy duty options like the unfoldingmaps library.
The simplest possible way of doing this is to pass an argument to
translate(x,y)
at the beginning of your draw loop. You could set that offset with arrow key input, or just change the offset whenever the mouse is touching the edge of the screen.If you want to make an actual scrollbar, put your entire mosaic drawing (with the translate()) between a pushMatrix / popMatrix pair. Then draw your scrollbar.
If you want to use a pre-made scrollbar class, consider a UI library like G4P.
Hey! I had this task when I was making this SAT test engine. The code for it is pretty long since you have to account for a rectangle that responds to mouse movements and have the image react accordingly. Try and see if these code snippets help :
So this is essentially the code to make a scroll bar that does respond to you when you click over it. Instead of using the example in my program, I'll have this simpler sketch that's more for your request.
Oh darn. Sorry about the duplicated comments :( I'll put the main sketch here as an example of how to use it :
Here's the dog image : https://d2pu2bk1b66iw6.cloudfront.net/photos/2015/02/03/6-91803-disappearing-corgi-1423002967.jpg
In the constructor, the "startValue" and "endValue" stand for the values when the bar is as high and low as it can go, respectively. (It's been quite a while, this may be wrong :o)
Hope this helps! Ask if you have any questions. I probably shouldn't just give you the code but making these took quite a while so I'd like to spare you the headache of it :)
Second comment duplicate. My bad.