PDA

View Full Version : how to draw a line on the 2D screen with mouse


aaaa
11-08-2014, 06:40 AM
in the 2D screen, I want to draw a line. One point of the line is given, for example (400,500,0), the other point of the line is where the click of the mouse.

since the coordinate range of the mouse is [0,1], while the coordinate range of the point of the line is determinated by the resolution of the screen. How to make sure the other end of the line is the point where the mouse clicks?

Frank Verberne
11-10-2014, 05:32 AM
To get the coordinate in window pixels or screen pixels, use:
# Get mouse position in pixel coordinates
x,y = viz.mouse.getPosition(viz.WINDOW_PIXELS)
# Get mouse position in screen coordinates
x,y = viz.mouse.getPosition(viz.SCREEN_PIXELS)

More info: http://docs.worldviz.com/vizard/Mouse.htm.