Rotation of individual items in a TextVisual

36 views
Skip to first unread message

Wilfred Janssen

unread,
Jun 25, 2017, 9:43:19 AM6/25/17
to vispy-dev
Hello,

I am using the TextVisuals from the scenegraph module. My goal is to plot meteorological station observations on a map using different scenegraph features. Instead of plotting the wind barbs with a set of lines, I want to plot them using a textvisual. I created a custom font containing wind barbs in the range from 0-200 knots. Now I have an array with coordinates, wind speeds and wind directions, which I will use for plotting the wind barbs. Plotting the barbs using my custom font is very easy, but rotating all individual barbs...

My question: Can I rotate all individual text items in the text-array, or do I have to create a TextVisual for every wind barb and rotate it seperately? I could not figure out the good method. A visual for every wind barb is a no-go as I want to plot hundreds of stations on the map.... I tried to add an array with the rotation, but that resulted in some errors.


Kind regards,

Wilfred Janssen
Meteorologist

David Hoese

unread,
Jun 26, 2017, 9:03:40 AM6/26/17
to vispy-dev
Hi Wilfred,

Sounds like a cool use case. I know I could definitely use something like this. However from what I can tell the current TextVisual only takes a single scalar rotation factor. I think if you want to accomplish wind barbs you'll need to subclass the TextVisual and customize the vertex shader and TextVisual to allow for multiple rotation values. Or go back to a LineVisual with individual lines (doesn't sound fun). Either way, it might be cool to make a custom Visual object that accepts wind direction and speed as inputs and figures out the rest.

Dave

Wilfred Janssen

unread,
Jun 28, 2017, 1:21:48 PM6/28/17
to vispy-dev
Hello David,

I already created barbs using the LineVisual. It is actually very fast (I thought it would be quite slow, given the amount of barbs worldwide). The barb-lines are drawn on a predefined coordinate system, so they won't scale to the screen size like text in a TextVisual will do. I have to work on that later on...


Wilfred Janssen
MeteoViewer_screendump.PNG

David Hoese

unread,
Jun 28, 2017, 2:03:24 PM6/28/17
to vispy-dev
> predefined coordinate system

Ok, but couldn't you apply a scale factor or use something like the TransformSystem in vispy's Scene? Or even do an on_resize handler method to change whatever attributes need to be changed to scale the barbs?

Dave

Wilfred Janssen

unread,
Jun 28, 2017, 3:11:17 PM6/28/17
to vispy-dev
I built a function which checks the resizing by scrolling. A scale factor is applied over the LineVisual and the lines are replotted after that. It's not the most ideal way, but is works pretty fine :)
Reply all
Reply to author
Forward
0 new messages