Board index FlightGear Development Canvas

Missing support for circle in svg.nas

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Missing support for circle in svg.nas

Postby jsb » Tue Mar 20, 2018 8:38 pm

Hi,
I am missing support for circles drawn in inkscape when using canvas.parsesvg
If someone competent could point me to the relevant docs I would try to add support to the nasal file.
I wonder why it is missing as arcs are obviously supported somehow...
jsb
 
Posts: 219
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: Missing support for circle in svg.nas

Postby Hooray » Wed Mar 21, 2018 5:18 pm

like you say, the svg parser is implemented in svg.nas
To add missing features to it, you only need to open the file and map the corresponding SVG element/tag (attribute) to a matching Canvas primitive (element).

There's an example illustrating how to do this, which adds support for the <image> tag: http://wiki.flightgear.org/Howto:Extend ... SVG_module
Image
I think Stuart said, that he was going to add this to svg.nas - so don't bother.

This would also be the right place/method to add support for vector images, i.e. SVG files referencing other SVG files and so on (recursively).

This would undoubtedly help better organize complex projects (think FG1000-style avionics)

Apart from that, most SVG related stuff ends up being OpenVG paths - thus, you need to look at api.nas and navigate to the wrappers for Canvas.Path

Supported instructions can be found there, too:

https://sourceforge.net/p/flightgear/fg ... as/api.nas
Code: Select all
# Path
# ==============================================================================
# Class for an (OpenVG) path element on a canvas
#
var Path = {
  # Path segment commands (VGPathCommand)
  VG_CLOSE_PATH:     0,
  VG_MOVE_TO:        2,
  VG_MOVE_TO_ABS:    2,
  VG_MOVE_TO_REL:    3,
  VG_LINE_TO:        4,
  VG_LINE_TO_ABS:    4,
  VG_LINE_TO_REL:    5,
  VG_HLINE_TO:       6,
  VG_HLINE_TO_ABS:   6,
  VG_HLINE_TO_REL:   7,
  VG_VLINE_TO:       8,
  VG_VLINE_TO_ABS:   8,
  VG_VLINE_TO_REL:   9,
  VG_QUAD_TO:       10,
  VG_QUAD_TO_ABS:   10,
  VG_QUAD_TO_REL:   11,
  VG_CUBIC_TO:      12,
  VG_CUBIC_TO_ABS:  12,
  VG_CUBIC_TO_REL:  13,
  VG_SQUAD_TO:      14,
  VG_SQUAD_TO_ABS:  14,
  VG_SQUAD_TO_REL:  15,
  VG_SCUBIC_TO:     16,
  VG_SCUBIC_TO_ABS: 16,
  VG_SCUBIC_TO_REL: 17,
  VG_SCCWARC_TO:    20, # Note that CC and CCW commands are swapped. This is
  VG_SCCWARC_TO_ABS:20, # needed  due to the different coordinate systems used.
  VG_SCCWARC_TO_REL:21, # In OpenVG values along the y-axis increase from bottom
  VG_SCWARC_TO:     18, # to top, whereas in the Canvas system it is flipped.
  VG_SCWARC_TO_ABS: 18,
  VG_SCWARC_TO_REL: 19,
  VG_LCCWARC_TO:    24,
  VG_LCCWARC_TO_ABS:24,
  VG_LCCWARC_TO_REL:25,
  VG_LCWARC_TO:     22,
  VG_LCWARC_TO_ABS: 22,
  VG_LCWARC_TO_REL: 23,

Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11326
Joined: Tue Mar 25, 2008 8:40 am

Re: Missing support for circle in svg.nas

Postby jsb » Sun Apr 08, 2018 8:07 pm

Meanwhile I found out one can convert a circle in inkscape to a path but for reasons I do not understand it is necessary to "break" the path at one point (I guess this means it is not a loop anymore after you click "break"). Otherwise the path looks kind of funny on the canvas, not like a circle, the arcs seem to be mirrored in a way.
jsb
 
Posts: 219
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: Missing support for circle in svg.nas

Postby wkitty42 » Sun Apr 08, 2018 8:21 pm

you have to break it because a path has a beginning and an end ;)
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 5574
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest