We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › background brush
Page Index Toggle Pages: 1
background brush (Read 1085 times)
background brush
Apr 22nd, 2009, 2:10pm
 
I need to make a brush which draws on top of an image which changes when c is pressed on the keyboard. The brush is erased because of the image as a background.  Embarrassed Can someone please help? I know i need to organize it into arrays and loops but can someone help with code.
Re: background brush
Reply #1 - Apr 23rd, 2009, 1:50am
 
You want to change the background while preserving the previous strokes?
A way to do that is to paint on a PImage (PGraphics actually): in Java2D mode, background is transparent, so you can paint that image on top of the background: even if you change it, the painting is still there.
Re: background brush!
Reply #2 - May 29th, 2009, 2:19pm
 
hi maybe you try this!:

PGraphics pg;

void setup(){
 size(400, 400);  
 background(255);
 pg = createGraphics(400, 400, P2D);
}

void draw() {
   background(imageBg);
   if(i<255)
     i++;
   if(i>=255)
     i = 0;
    if(mousePressed){
       pg.beginDraw();
       pg.stroke(255,34,58);
       pg.line(pmouseX, pmouseY, mouseX, mouseY);
       pg.endDraw();
    }
    image(pg,0,0);
}

good luck
Page Index Toggle Pages: 1