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 › BGraphics, BImage ?
Page Index Toggle Pages: 1
BGraphics, BImage ?? (Read 1001 times)
BGraphics, BImage ??
Aug 17th, 2007, 11:09pm
 
I downloaded some Processing demo codes,
but they can't run cause <BGraphics not found> and <BImage not found>.

Any clue why ?

for example, I have this problem with blobs.pde
from
http://www.hardcorepawn.com/blobs/
Re: BGraphics, BImage ??
Reply #1 - Aug 18th, 2007, 12:10am
 
BGraphics and BImage are old names for some of the classes in Processing.  The new names start with P: PGraphics, PImage.  You may need to make some other changes as well. loop() is now draw() for example.

Re: BGraphics, BImage ??
Reply #2 - Aug 18th, 2007, 12:15am
 
Thanks, I will try that...
Re: BGraphics, BImage ??
Reply #3 - Aug 19th, 2007, 10:21am
 
this file holds all the changes:

http://processing.org/download/revisions.txt

look for "rev 0070" for the changes from ALPHA to BETA ( BImage -> PImage ) ...

F
Re: BGraphics, BImage ??
Reply #4 - Aug 19th, 2007, 10:50am
 
I made all the changes I could find,
like BGraphics -> PGraphics,
but blobs.pde still doesn't work.

Since this is a downloaded demo, (not my program), it's difficult to see what's wrong.

Here is the code, in case someone wants to try it:

//blobs
//2007-aug-17
//from http://www.hardcorepawn.com/blobs/

int NUM_BLOBS=100;
boolean keyp=false;

class Blob
{
 float x,y,vx,vy;
 color c;
 int r;
 PGraphics target;
//  Blob(int _x, int _y, PGraphics _target)
 Blob(int _x, int _y, int _r, PGraphics target)
 {
   x=_x;
   y=_y;
   r=_r;
   vx=random(-2,2);
   vy=random(-2,2);
//    target=_target;
   c=color(int(random(255)),int(random(255)),int(random(255)),32);
   
 }
 
 void show() {
  float closest=width*height;
   int k;
   boolean found=false;
   for(int i=int(y-r);i<int(y+r);i++)
   {
     k=i*width;
     if(i>=0&&i<height)
     {
       for(int j=int(x-r);j<int(x+r);j++)
       {
         if(j>=0&&j<width)
         {
           if((overlay.pixels[j+i*width]&0x000000FF)==0)
           {
             found=true;
             int xd=i-int(y);
             int yd=j-int(x);
             if(sqrt(xd*xd+yd*yd)<closest)
             {
               closest=sqrt(xd*xd+yd*yd);
             }
           }
         }
       }
     }
   }
   if(!found)
   {
     closest=width*height;
   }
   if(closest<r)
   {
     int diam=r-int(closest);
     int alpha=254-int((255.0/float(r))*closest);
     fill(red(c),green(c),blue(c),alpha);
     noStroke();
//      ellipse(x-(diam/2),y-(diam/2),x+(diam/2),y+(diam/2));
     ellipse(x-(diam/2),y-(diam/2),diam,diam);
   }
   else
   {
     noStroke();
     fill(red(c),green(c),blue(c),128);
     ellipse(x-1,y-1,2,2);
//      ellipse(x-1,y-1,2,2);
   }
 }//show()
 
 void move() {
   if(x+vx<=0 || x+vy>width)
   {
     vx=-vx;
   }
   if(y+vy<=0 || y+vy>height)
   {
     vy=-vy;
   }
   x+=vx;
   y+=vy;
 }//move()
 
}//class Blob

class Curvepoint
{
 float x,y,vx,vy;
 Curvepoint(float _x, float _y)
 {
   x=_x;
   y=_y;
   vx=random(-5,5);
   vy=random(-5,5);
 }
 
 void move()
 {
   if(x+vy>=width || x+vy<0)
   {
     vx=0-vx;
     vx+=random(-0.5,0.5);
   }
   if(y+vy>=height || y+vy<0)
   {
     vy=0-vy;
     vy+=random(-0.5,0.5);
   }
   x+=vx;
   y+=vy;
 }//move()
 
}//class Curvepoint

Blob[] blobs;
Curvepoint[] points;
PGraphics overlay;

void setup()
{
 size(400,400);
 overlay=createGraphics(width,height,P2D);
 overlay.stroke(0);
 overlay.background(0);
 
 noStroke();
 background(255,255,255);
 
 blobs=new Blob[NUM_BLOBS];
 points=new Curvepoint[8];
 int a=int(sqrt(blobs.length));
 for(int i=0;i<blobs.length;i++)
 {  
   blobs[i]=new Blob(((width/a)/2)+i%a*(width/a),((height/a)/2)+(i/a)*(height/a),width/a,overlay
);
 }
 for(int i=0;i<points.length;i++)
 {
   points[i]=new Curvepoint(random(width),random(height));
 }
}//setup()

void draw()
{
 background(255,255,255);
 overlay.background(255,255,255);
 stroke(0);
 overlay.beginShape();//@@**something WRONG here ??
 {
   for(int i=0;i<points.length;i++)
   {
     overlay.curveVertex(points[i].x,points[i].y);
     points[i].move();
   }
 }
 overlay.endShape();
 for(int i=0;i<blobs.length;i++)
 {
   blobs[i].show();
//    blobs[i].move();
 }
 if(keyp)
 {
   setup();
   keyp=false;
 }
}//draw()

void keyPressed()
{
 if(key=='a' && NUM_BLOBS<12800)
 {
   NUM_BLOBS*=2;
   keyp=true;
 }
 if(key=='z' && NUM_BLOBS>25)
 {
   NUM_BLOBS/=2;
   keyp=true;
 }
}
Re: BGraphics, BImage ??
Reply #5 - Aug 19th, 2007, 11:15am
 
Wink

ther is no P2D, needs to be JAVA2D or P3D.
P2D is gonna return someday in the future ...

F
Re: BGraphics, BImage ??
Reply #6 - Aug 19th, 2007, 1:16pm
 
Ah, that old code.

I've already made a more up to date version: http://www.hardcorepawn.com/blobs2/ does the same sort of thing, but should work with minimal changes in the latest version of processing.
Re: BGraphics, BImage ??
Reply #7 - Aug 19th, 2007, 9:35pm
 
Blobs2 doesn't run.
Re: BGraphics, BImage ??
Reply #8 - Aug 19th, 2007, 9:47pm
 
Ah yes, there is one change since then that's affecting it:

overlay.beginShape(LINE_STRIP); needs to be overlay.beginShape(); and then overlay.endShape(); soon after needs to become overlay.endShape(CLOSE);
Re: BGraphics, BImage ??
Reply #9 - Aug 19th, 2007, 10:50pm
 
Also PGraphics3 and "house.png" are not found.
Re: BGraphics, BImage ??
Reply #10 - Aug 20th, 2007, 12:46pm
 
Ah yes, PGraphics3 is now PGraphics3D I believe. As for house.png, well, you'll have to make your own.
Re: BGraphics, BImage ??
Reply #11 - Aug 20th, 2007, 1:48pm
 
all these changes are covered in the "changes" page of the reference:
http://processing.org/reference/changes.html
Page Index Toggle Pages: 1