Board index FlightGear Development Canvas

Best way to learn Canvas?

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.

Re: Best way to learn Canvas?

Postby Thorsten » Sun Oct 09, 2016 4:18 pm

SVG text element;

Code: Select all
   <text
         sodipodi:linespacing="125%"
         id="p_dps_hyd_thermal_label36"
         y="30.178572"
         x="43.928574"
         style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
         xml:space="preserve"><tspan
           style="font-size:14px;fill:#ffffff"
           y="282.178572"
           x="248.428574"
           id="tspan3112"
           sodipodi:role="line">     MFUS 2</tspan></text>


The string following id="... is what you're looking for - so this element is called p_dps_hyd_thermal_label36 and can be accessed by

Code: Select all
*.getElementById("p_dps_hyd_thermal_label36");


You can read the id opening the SVG in a text editor if necessary - probably some SVG editor also displays and sets it as well, but I've never used one.
Last edited by Thorsten on Sun Oct 09, 2016 4:20 pm, edited 1 time in total.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Best way to learn Canvas?

Postby Hooray » Sun Oct 09, 2016 4:19 pm

And at that point, you have a conventional Canvas element: http://wiki.flightgear.org/Canvas_SVG_P ... ic_example
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Best way to learn Canvas?

Postby Octal450 » Sun Oct 09, 2016 4:34 pm

Awesome, thanks!
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Best way to learn Canvas?

Postby Hooray » Sun Oct 09, 2016 4:38 pm

please feel free to help us update the wiki to better document such details - e.g. you could create your own little SVG tutorial animating a smiley (e.g. changing its size/orientation or background color), all via the Nasal console :D
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Best way to learn Canvas?

Postby Hooray » Sat Feb 25, 2017 3:28 pm

Updated (using forum excerpts): http://wiki.flightgear.org/Canvas_Conce ... troduction

Feedback appreciated.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Previous

Return to Canvas

Who is online

Users browsing this forum: No registered users and 3 guests