FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   drawing on a 'self created' image
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: drawing on a 'self created' image  (Read 1447 times)
elout

12747371274737 WWW
drawing on a 'self created' image
« on: Mar 30th, 2004, 7:38pm »

I was just wandering if it`s possible to draw onto a new created BImage. It seems it`s not possible right now.
 
something like  
my_img.line(0,0,100,100);  
 
I just started another project, and although I have several work-arounds, like drawing on the screen, copy the screen to an image buffer, and clearing the screen again.. I was just wandering if the p5 enviroment is flexible for this kind of stuff.
 
 
 
Code:

BImage my_img;
 
void setup()
{
  size(600, 300);
  my_img = new BImage(100,100);  
}
 
void loop()
{
  background(155);
  image(my_img,0,0,40,40);
  line(0,0,100,100);
   
  //my_img.line(0,0,100,100);  //won`t work
   
  //just add a little delay so the cpu can handle other stuff
  delay(15);  
}
 
fry


WWW
Re: drawing on a 'self created' image
« Reply #1 on: Mar 30th, 2004, 8:10pm »

use BGraphics instead, which subclasses BImage..
 
myimg = new BGraphics(100, 100);
 
myimg.line(20, 20, 80, 80);
 
then you can draw myimg the same way you would other images.
 
mKoser

WWW Email
Re: drawing on a 'self created' image
« Reply #2 on: Mar 30th, 2004, 9:15pm »

cheeky, very cheeky (and usefull!)
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
narain


Re: drawing on a 'self created' image
« Reply #3 on: Jul 30th, 2004, 5:37pm »

BGraphics isn't working for me...
 
Code:
BGraphics g;
 
void setup () {
  size(100,100);
  g = new BGraphics(width,height);
}
 
void draw () {
  g.ellipse(20,20,60,60);
  image(g,0,0);
}

 
I just get a blank sketch. If I just do ellipse() instead of g.ellipse(), the ellipse shows up.
 
Am I doing something wrong?
 
P.S. Could it have something to do with the BGraphics image being transparent by default?
 
fry


WWW
Re: drawing on a 'self created' image
« Reply #4 on: Jul 30th, 2004, 8:13pm »

don't use 'g', since the "real" BGraphics is already called 'g', so you're gonna confuse the hell outta p5.
 
Andre_Michelle

WWW
Re: drawing on a 'self created' image
« Reply #5 on: Jul 30th, 2004, 9:50pm »

I cannot do this with the 3d camera, don't I ?
 
I'm afterall trying to find a solution to move the projectionplane on the screen...
 
narain


Re: drawing on a 'self created' image
« Reply #6 on: Jul 31st, 2004, 5:28am »

It still doesn't work...
Code:
BGraphics myG;
void setup () {
  size(100,100);
  myG = new BGraphics(width,height);
}
void draw () {
  myG.ellipse(20,20,60,60);
  image(myG,0,0);
}

I'm kinda embarrassed posting this - I keep thinking it'll be some very stupid little mistake that I can't find.
 
Update: Did some testing, and I found image(myG, 0,0) doesn't work, but image(myG, 0,0, myG.width,myG.height) does. Bug?
« Last Edit: Jul 31st, 2004, 5:37am by narain »  
Andre_Michelle

WWW
Re: drawing on a 'self created' image
« Reply #7 on: Jul 31st, 2004, 7:20am »

Yes, you are right. It works even with 3d.
 
fry


WWW
Re: drawing on a 'self created' image
« Reply #8 on: Sep 21st, 2004, 3:32am »

just add  
myG.format = RGB  
after it's created. and i've just fixed this for megabucket.
 
Pages: 1 

« Previous topic | Next topic »