Hi, I'm having trouble with tint() when drawing an off-screen PGraphics object. The tint() function doesn't seem to have any effect unless I am continually updating the off-screen buffer (which in my case negates the purpose of using the buffer). This is a sample program to demonstrate the problem. I would expect the code as it is now to change the tint level every time the mouse is clicked, but it only has a visible effect if I uncomment line 14.
Any idea how to get this working? Using offScreen.get() doesn't quite work since I believe that returns an image where the pixels have either 0 or 1 for opacity, and that makes the text all aliased.
Thanks for the help,
Justin
- PGraphics offScreen = createGraphics(200, 200, JAVA2D);
- float t = 255;
- void setup() {
- size(200, 200, JAVA2D);
- smooth();
- updateOffscreen();
- }
- void draw() {
- background(0);
- tint(255, t);
- //updateOffscreen(); // Works with this line, but that makes for too much drawing.
- image(offScreen, 0, 0); // image(offScreen.get(), 0, 0); Works but the text is aliased
- }
- void updateOffscreen() {
- offScreen = createGraphics(200, 200, JAVA2D);
- offScreen.smooth();
- offScreen.beginDraw();
- offScreen.fill(255);
- offScreen.rect(50, 50, 100, 100);
- offScreen.textSize(25);
- offScreen.text("Hi Forum", 10, 30);
- offScreen.endDraw();
- }
- void mousePressed() {
- t = random(20, 255);
- }
1