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 › Simple Paint Program (Beginner question)
Page Index Toggle Pages: 1
Simple Paint Program (Beginner question) (Read 2065 times)
Simple Paint Program (Beginner question)
Sep 14th, 2007, 8:33pm
 
I am new to processing and I have a very basic understanding of programming in java.

I am looking for reference or examples for how to draw straight lines using mouse input. I have done tests with mouseX, mouseY, etc, in the line command, but because these values are updated every frame I dont get a straight line, I get a free hand line tool. I somehow need to take the value of the x and y on the initial mousePressed, and the final x and y on mouse released. Anyone have any references that I should look into? I would greatly appreciate any help. Thanks!

Joshua
Re: Simple Paint Program (Beginner question)
Reply #1 - Sep 15th, 2007, 11:28am
 
like this?
Code:

float x,y;
void setup(){
size(400, 400);
}
void draw(){
}
void mousePressed(){
x = mouseX;
y = mouseY;
}
void mouseReleased(){
line(x,y,mouseX,mouseY);
}


or do you mean like the continous lines demo in the learning section
Re: Simple Paint Program (Beginner question)
Reply #2 - Sep 17th, 2007, 3:58am
 
I think my problem is that I was trying to do this in the draw  function...

Thanks. Now, trying to give you a preview of the line before you let go... :p
Page Index Toggle Pages: 1