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 › Bug or feature!
Page Index Toggle Pages: 1
Bug or feature?! (Read 732 times)
Bug or feature?!
Mar 9th, 2008, 5:54pm
 
Click'n'drug and see what will happen. Pay attention to the right bottom area of the canvas especially.

I can't understand)) Would you help?
I tried to write canvas cleaner that supports fading of the previous frames but... If you have any idea how to do it without drawing of the black rectangle and without cycle that subtracting pixels - share it!

It would be very convinient if background(0) will take alpha  when cleaning canvas in draw().

Quote:


PImage img;
void setup()
{
 size(640, 480, P3D);
 frameRate(24);
 background(255);
 img = createImage(width, height, ARGB);
 loadPixels();
}

void draw(){
 //background(255);
 tint(255, 128);
 image(img,0,0,width, height);
 img.pixels = pixels;
 //arraycopy(pixels, img.pixels);
}
void mouseDragged() {
 line(pmouseX,pmouseY,mouseX,mouseY);
}


Re: Why this code works in this way?!
Reply #1 - Mar 9th, 2008, 6:23pm
 
interesting effect, if you want to fade the line into the background, this might help.
instead of using background or an image, you draw a rect with the corresponding color and alpha value over the existing frame.
Code:

void setup()
{
size(640, 480, P3D);
frameRate(24);
}

void draw(){
fill(255,64);
noStroke();
rect(0,0,width,height);
}

void mouseDragged() {
stroke(0);
line(pmouseX,pmouseY,mouseX,mouseY);
}


Re: Bug or feature?!
Reply #2 - Mar 10th, 2008, 6:21pm
 
It's not just effect, it looks like bug. Why line trace forms rectangles that flow to left top corner? It must not))

I edited code, so now it works more correct. But previous frames is not removed completly still (increase alpha inside tint()).

Drawing rectangle is nice way to clean canvas, but it's uncovinient in 3d mode.

Switching to HSB inside createImage() remove motion effect but slight line trace still stays on canvas.

Quote:


PImage img;
void setup()
{
 size(640, 480, P3D);
 frameRate(30);
 background(255);
 img = createImage(width, height, RGB);
}

void draw(){
 loadPixels();
 //img.pixels = pixels;
 arraycopy(pixels, img.pixels);
 background(255);
 tint(255, 200);
 image(img,0,0,width, height);

}
void mouseDragged() {
 line(pmouseX,pmouseY,mouseX,mouseY);
}


Re: Bug or feature?!
Reply #3 - Mar 10th, 2008, 7:29pm
 
If you use OPENGL mode there is no blurring/sliding.

P3D is meant to be quick, not accurate.
Page Index Toggle Pages: 1