Canvas
|
| |
| Started in | 05/2012 (Available since FlightGear 2.8) |
|---|---|
| Description | Dynamic 2D drawing at runtime using the property tree and scripting (for instruments, HUDs, GUIs) |
| Maintainer(s) | TheTom and more |
| Status | Under active development |
| Folders | |
| Subforum | http://forum.flightgear.org/viewforum.php?f=71 |
| The FlightGear forum has a subforum related to: Canvas |
| Canvas - the FlightGear 2D drawing API |
|---|
|
In FlightGear, a Canvas is a dynamically created image (OpenGL texture) that can be created and modified (drawn to) at runtime by using the Property Tree, i.e. via the built-in scripting language Nasal and setting a few properties via setprop() or its object-oriented wrapper props.nas.
Canvas is all about rendering to a texture and updating it dynamically at run-time by modifying a sub-tree in the property tree that represents the texture (RTT) - its primary rendering primitives are:
- text (via osgText)
- vector graphics (via shivaVG/OpenVG, see Shiva Alternatives)
- static raster images (or dynamic images via osg::Image represented as another Canvas)
- groups/maps - for grouping/nesting elements to arbitrary depths, and selectively controlling/transforming/clipping each sub-tree
See the right navigation bar "Canvas - the FlightGear 2D drawing API" for more info.
Gallery
Support for using the canvas in a gui widget:
With the new map element it is also very easy to draw maps:
Videos
A short video demonstrating a possible usecase (C-130J AMU):
By using alphablending it can also be used to render the contents of a HUD:
Using the new canvas.parsesvg function to use an SVG file to simulate an EICAS display:
Demonstrating how the new Canvas GUI wrapper can be used to create entirely custom, scripted GUI widgets using XML, SVG and Nasal:
Experimenting with selecting text and positioning a cursor inside the text. The visualization is all done using Nasal.
Since 07/2012, the canvas system also provides support for full window-drawing:
Omega95 has reimplemented the CDU of the ATR72 using the Canvas system:
Another video demonstrating window stacking and nested canvases:
Using Canvas mouse events to create animation of slider, wheel and knob