Canvas draw library: Difference between revisions

no edit summary
mNo edit summary
No edit summary
Line 1: Line 1:
{{Note|Canvas draw is currently work in progress. You can test and improve it by downloading the [[Addons|CanvasDrawDev add-on]]. }}
{{tip|The basic canvas.draw library was merged into FGDATA in 03/2020 so it available by default now. }}
{{tip| A merge of canvas.draw library into FGDATA as optional module has been requested 02/2020. Please check [[Nasal Initialization]] for information on how to activate the module ''canvas_draw''. }}


{{Canvas Navigation}}
{{Canvas Navigation}}
= CanvasDrawDev add-on =
= Introduction =
{{Note|As of 12/2018, the add-on is largely based on GPL'ed [[How to manipulate Canvas elements|plot2D code]] written originally by {{Usr|Rodolfo}} (rleibner on the forums) as part of the [[Spoken GCA]], [[PAR instrument]] and [[Oscilloscope addon|Oscilloscope]] add-ons.}}
 
The purpose of this add-on is to develop and grow a nasal library of canvas drawing
functions. This lib should eventually be moved to FGDATA/Nasal once it has
reached a sufficient quality.
 
== Motivation ==
There are basically two ways to populate a canvas, loading an SVG file which
There are basically two ways to populate a canvas, loading an SVG file which
has been created with some tool like inkscape, or by writing a nasal program
has been created with some tool like inkscape, or by writing a nasal program
Line 17: Line 9:
Both ways are valid and have their pros and cons.
Both ways are valid and have their pros and cons.


The canvas API is quite limited (at the time of writing), only a few basic  
The canvas API was quite limited, only a few basic commands were available, so canvas.draw library was created
commands are available. There should be more drawing commands to allow rapid
to provide more drawing commands.
development of canvas instruments for other aircraft.
 
{{Note|Development of this library started in 12/2018 as a separate [[Addons|CanvasDrawDev add-on]] and is largely based on GPL'ed [[How to manipulate Canvas elements|plot2D code]] written originally by {{Usr|Rodolfo}}
(rleibner on the forums) as part of the [[Spoken GCA]], [[PAR instrument]] and [[Oscilloscope addon|Oscilloscope]] add-ons.}}


== Goals ==
== Goals ==
Line 25: Line 19:
* Provide complex drawing commands needed for e.g. compass rose or speed tapes  
* Provide complex drawing commands needed for e.g. compass rose or speed tapes  
* Provide easy to use styles  
* Provide easy to use styles  
* Support API versioning to allow later extensions of the library


= canvas.draw API =
= canvas.draw API =
{{Note|This API is subject to change without notice until it has been released with FG in FGDATA}}
== draw module ==
== draw module ==
All draw methods expect a canvas group element 'cgroup' as first parameter to draw on.  
{{note|All draw methods expect a canvas group element 'cgroup' as first parameter to draw on.}}


=== draw.colors ===
=== draw.colors ===
Line 282: Line 273:
Set length of subdivision marker in %marker_length
Set length of subdivision marker in %marker_length


== Modules ==
= References =
[[CompassRose]]
[[CompassRose]] is based on canvas draw.
{{Note|You can test, improve and play around with canvas.draw by downloading the [[Addons|CanvasDrawDev add-on]]. }}
252

edits