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 & HelpSyntax Questions › mouse coord and drawing a line
Page Index Toggle Pages: 1
mouse coord and drawing a line (Read 758 times)
mouse coord and drawing a line
Feb 17th, 2010, 1:52pm
 
Hi, i want/need for a project mouse-coord (mouse.x)., but how can i use them (instead of pmouse...) to draw a line?

Maybe someone can show me right way?!
Thanx for reading and thinking about.


import processing.opengl.*;

Point mouse;
int mX, mY;

void setmousexy(){
 mouse = MouseInfo.getPointerInfo().getLocation();
 mX = mouse.x;
 mY = mouse.y;
}


void setup() {
 size(screen.width, screen.height, OPENGL);
 background(255);
 noStroke();
}  

void draw() {
 setmousexy();

 stroke(0, 0, 0, 80);
 strokeWeight(1);
 smooth();
 line (?????);
}


Re: mouse coord and drawing a line
Reply #1 - Feb 17th, 2010, 2:05pm
 
what about this :

void setup() {
 size(640, 200);
 background(0);
}

void draw() {
 stroke(255);
 if(mousePressed) {
   line(mouseX, mouseY, pmouseX, pmouseY);
 }
}
Re: mouse coord and drawing a line
Reply #2 - Feb 18th, 2010, 3:35am
 
thnx, but as i mentioned: i don't want to use pmouseX...
because i need the active canvas/window to draw Wink))
Re: mouse coord and drawing a line
Reply #3 - Feb 18th, 2010, 5:24am
 
Look for my last post here
http://processing.org/discourse/yabb2/num_1258557268.html#3

Hope that helps
rS
Re: mouse coord and drawing a line
Reply #4 - Feb 18th, 2010, 6:02pm
 
If you dont want to use vectors.

put
oldx=mouseX
oldy=mouseY

at the end of you program and then use them instead of Pmouse. I might be confused on what your asking. Do you want a totally different way to do it or are you just boycotting Pmouse for some reason?
Page Index Toggle Pages: 1