how to get pixel coordinates of vpython.label object?

36 views
Skip to first unread message

Horst JENS

unread,
Oct 2, 2024, 1:20:12 PM10/2/24
to VPython-users
Is there a method to get the x,y pixel coordinates of a vpython 3d label object ?
less important, is there a method to get the size (width, height) of a vpython label object ?

details:
I have an 3d vector and use it as a the pos argument for an vpython label object. The label is displayed, i want to know the xy pixel coordinate of the label (distance from the lower left screen corner) and also the size of the label object in pixel.

-Horst 

Bruce Sherwood

unread,
Oct 2, 2024, 2:26:10 PM10/2/24
to VPython-users
I can't think of a way to determine the current width and height of a label, but scene.pixel_to_world tells you how big a pixel is in world coordinates. Also, scene.range gives you in world coordinates half the shorter of scene.width/2 and scene.height/2.

Bruce

Bruce Sherwood

unread,
Oct 2, 2024, 10:31:25 PM10/2/24
to VPython-users
Correction:

I can't think of a way to determine the current width and height of a label, but scene.pixel_to_world tells you how big a pixel is in world coordinates. Also, scene.range gives you in world coordinates the shorter of scene.width/2 and scene.height/2.

Bruce

Reply all
Reply to author
Forward
0 new messages