Cedric
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(); } }