I have a Processing sketch that takes used input and displays it. My problem is that I need to clear the input at certain points on the screen. Using background(255) in draw, clears the entire screen, however, I Only want to clear sections of the screen. What is the normal way to approach this?
I'm having a problem scaling Pgraphics on event. For example, when you press the 'a' key I want the Pgraphic to zoom in; simple enough but I am unable to get the Pgraphic to scale. I am using Matt Patey's example. I think it might be how I order the image and Pgraphic.
See below.
Thanks for any help....
j
/**
* Pan Demo
*
* Processing sketch illustrates how an off-screen buffer can be
* used to create a panning tool to view an image larger than the
* base canvas. Use the arrow keys to scroll to the limits of
* the displayed image.
*
* @author Matt Patey
*/
PImage bufSlice;
PGraphics buf;
int copyOffsetX;
int copyOffsetY;
int copyWidth;
int copyHeight;
float scaler = 1.0;
void setup() {
size(400, 400, P3D);
// Create an off-screen buffer that will contain the entire image.
buf = createGraphics(800, 800, JAVA2D);
buf.beginDraw();
buf.smooth();
buf.scale(scaler);
buf.background(255);
for (int i = 0; i < buf.width; i+=10) {
buf.line(i, 0, i + 50, buf.height);
buf.line(0, i, buf.height, i + 30);
}
buf.endDraw();
copyOffsetX = 0;
copyOffsetY = 0;
copyWidth = width;
copyHeight = height;
}
void draw() {
background(0);
image(getBufSlice(), 0, 0);
}
/**
* Updates the copied version of the off-screen buffer.
What is the best approach for two windows in one sketch. Window one has pan and zoom while window two is a small version of window one, used primarily as "Where am I now" a map. It is easy to draw and relate both windows in a basic processing sketch, but I only want to pan and zoom on one of the windows and not the other.
drawTitle() is called in draw however I want to update the text on a mouse event. When I do this currently the text does not update but writes on top of the previous text. Could you tell me please how to do this?