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 & HelpSyntax Questions › offscreen images + motionblur in v.0114 beta
Page Index Toggle Pages: 1
offscreen images + motionblur in v.0114 beta ? (Read 554 times)
offscreen images + motionblur in v.0114 beta ?
May 16th, 2006, 3:59pm
 
hi im also new to processing and using the 0114 beta version
i would like to put an kind of motionblur/feedback effekt on some rotating typo (P3D) and moving beziercurves

here is an examplescript for a simple kind of feedback i found (sorry, cant remember from where)

--------------------------------------------------
void setup() {
 size(640,480);
 fill(255);
 stroke(0);
}

void loop() {
 fadescr(255,255,255);
 line(mouseX,mouseY,mouseX+100,mouseY);
}

void fadescr(int r, int g, int b) {
 int red, green, blue;
 for (int i = 0; i < pixels.length; i++) {
   red = (pixels[i] >> 16) & 0x000000ff;
   green = (pixels[i] >> 8) & 0x000000ff;
   blue = pixels[i] & 0x000000ff;
   pixels[i] = (((red+((r-red)>>3)) << 16) | ((green+((g-green)>>3)) << 8) | (blue+((b-blue)>>3)));
 }
}
--------------------------------------------------

it works with processing 0068 alpha but not with my version 0114
actualy most of the codes i found on the net dont work with my version
i know i have to change BImage to PImage and BGraphics to PGraphics etc.

i also tryed to draw some offscreen images with PGraphics but it also dosent work

so. could somebody please tell me whats wrong with the code above for 0114 beta
and if and how it is possible to draw stuff first to an offscreen in processing 0114

thanx for help

_tobias


Re: offscreen images + motionblur in v.0114 beta ?
Reply #1 - May 16th, 2006, 4:19pm
 
change "void loop" to "void draw"

-seltar
Re: offscreen images + motionblur in v.0114 beta ?
Reply #2 - May 16th, 2006, 4:35pm
 
yes. i know
i left the code like it worked in version 0068

in 0114 beta with draw instead of loop i get the error:

-------------------------------------

java.lang.NullPointerException


at Temporary_1263_4176.fadescr(Temporary_1263_4176.java:14)


at Temporary_1263_4176.draw(Temporary_1263_4176.java:8)


at processing.core.PApplet.handleDisplay(PApplet.java:1336)


at processing.core.PGraphics.requestDisplay(PGraphics.java:535)


at processing.core.PApplet.run(PApplet.java:1152)


at java.lang.Thread.run(Unknown Source)
-------------------------------------

with loop just an empty screen

-------------------------------------
-------------------------------------

how can i do something like:
PGraphics offscreenbuffer;
offscreenbuffer = new PGraphics(width,height,null);
offscreenbuffer.line(10,10,10,10);
etc.

thanx for answering
Re: offscreen images + motionblur in v.0114 beta ?
Reply #3 - May 16th, 2006, 4:42pm
 
you need to use updatePixels(). please read the faq on how to update code for beta releases:
http://processing.org/faq/changes.html
Re: offscreen images + motionblur in v.0114 beta ?
Reply #4 - May 16th, 2006, 9:22pm
 
now i read the f*g + the endless revisions
and im using loadPixels and updatePixels
and i still dont understand why it is not doing my bitshifts


is it still the same language ???


void setup() {
 size(640,480);
 fill(255);
 stroke(0);
}

void draw() {
 loadPixels();
 fadescr(255,255,255);
 updatePixels();
 line(mouseX,mouseY,mouseX+100,mouseY);
}

void fadescr(int r, int g, int b) {
 int red, green, blue;
 for (int i = 0; i < pixels.length; i++) {
   red = (pixels[i] & 0x000000ff) >> 16;
   green = (pixels[i] & 0x000000ff) >> 8;
   blue = (pixels[i] & 0x000000ff) >> 0;
   pixels[i] = (((red+((r-red)>>3)) << 16) | ((green+((g-green)>>3)) << 8) | (blue+((b-blue)>>3)));  

 }
}

Re: offscreen images + motionblur in v.0114 beta ?
Reply #5 - May 16th, 2006, 9:40pm
 
the pixels are simply transparent, do this:
Code:

pixels[i] = 0xFF000000 | (((red+((r-red)>>3)) << 16) | ((green+((g-green)>>3)) << 8) | (blue+((b-blue)>>3)));

btw:
Code:

// alpha = (pixels[i] >> 24) & 0xFF;
   red = (pixels[i] >> 16) & 0xFF;  
   green = (pixels[i] >> 8) & 0xFF;  
   blue = pixels[i] & 0xFF;

F
Re: offscreen images + motionblur in v.0114 beta ?
Reply #6 - May 17th, 2006, 12:34am
 
hi fjen

it works
so pixels didnt have an alpha channel in version 0068 ?!
thanx a lot for your help

best.

_tobias

Page Index Toggle Pages: 1