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 › !!!!this problem made me sick, please help me!!!!!
Page Index Toggle Pages: 1
!!!!this problem made me sick, please help me!!!!! (Read 720 times)
!!!!this problem made me sick, please help me!!!!!
Apr 2nd, 2009, 4:16pm
 
let's think that we drawing a figure with mouse.
ı must use this drawn figure as a material (moveable object )
ı would appreciate if you may help me about this subject Huh
(attention, figure will be free  drawn ..so, it may be a foolish figure which is drawn randomly)
Re: !!!!this problem made me sick, please help me!!!!!
Reply #1 - Apr 2nd, 2009, 6:53pm
 
just a tipp... less Exclamation marks and an explanation of your problem in the topic and you will probably get some help here.

Re: !!!!this problem made me sick, please help me!!!!!
Reply #2 - Apr 3rd, 2009, 1:18am
 
Cedric is right. Most messages here ask for help, by people with problem, so if all threads have such title, it will be hard to distinguish them!  Cool

And explaining a bit more what you are trying to do might bring you more useful answers... Smiley
You have, IIRC, a sketch in the examples showing how to do free drawing.
Re: !!!!this problem made me sick, please help me!!!!!
Reply #3 - Apr 3rd, 2009, 10:26am
 
I think he wants to be able to draw a scribble or whatever on the screen, and then switch to a mode where he can pick it up with the mouse and move it around.

This isn't conceptually difficult, but if you're new to processing is going to require you to learn some stuff first.  What you're going to want to do is write some code to let the user draw.  There's plenty of examples of how to do that here in the forums and (better) in the "learning" section of this website.  You'll do the same, or steal that code, but change it so that you're drawing into a PGraphics object that you've created, rather than directly to the screen.  Initialize your PGraphics object by filling it with completely transparent white (or black, or mauve, so long as it specifies complete transparency in the alpha channel).

When the user is done drawing, you can analyze the contents of the PGraphics object to find the bounding box of the user's drawing, and then use PGraphics.get() to take a rectangular "slice" out of that PGraphics object.  Store that in a separate PGraphics object.  It is now a "sprite" that you can draw to the screen wherever you want.

If you've gotten that far, it will probably be clear to you how to use further mouse input to control the location at which you draw the sprite to the screen, so that's how you'll be able to pick up the drawing and move it around.
Re: !!!!this problem made me sick, please help me!!!!!
Reply #4 - Apr 3rd, 2009, 11:49am
 
help me on this issue to the person -> I will send 2 box Turkishdelight.(Free shipping) i am serious.
Re: !!!!this problem made me sick, please help me!!!!!
Reply #5 - Apr 3rd, 2009, 1:42pm
 
As i dont know what your program should be able to do I put togther some things you will need...

Like cloister suggested we use a pgraphic to draw in...
you can draw while pressing the mouse button. If you switch to dragging mode by pressing space. You can now drag ( bad dragging, you have to work on that) the image arround...
by pressing X you delete your image and start from scratch.
It just shows the idea of using a Pgraphic Object but you have to work on that. for example if you want to continue drawing or if you want more objects and so one... like i said, dont know what your programm should be able to do, but maybe thats a good start...





float posX;
float posY;

PGraphics pg;
boolean drawing = true;
void setup(){
 size( 400, 400 );
 imageMode(CENTER);
 pg = createGraphics(400,400, P2D);
posX = width/2;
posY = height/2;

}  


void draw(){
 background(255);
 pg.beginDraw();


 // pg.background(255);
 if(drawing==true){
    cursor(ARROW);
   if (mousePressed == true) {
     pg.fill(0);
     pg.ellipse(mouseX,mouseY,10,10);
     pg.endDraw();

   }
 }
 else{
   cursor(HAND);
   if (mousePressed == true) {
     background(255);
     posX = mouseX;
     posY = mouseY;      
     //image(pg,mouseX,mouseY,width,height);
   }
 }
println(posX);
 image(pg,posX,posY,width,height);

}  

void keyPressed() {
  if (key == ' ') {
  if(drawing)  drawing=false;
 else  drawing=true;
}

  if (key == 'x' || key == 'X') {
  pg.background(255);
  posX = width/2;
  posX = height/2;
  pg.endDraw();
  }

}
Page Index Toggle Pages: 1