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 3: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 3:20 pm, edited 1 time in total.
Thorsten
 
Posts: 10843
Joined: Mon Nov 02, 2009 8:33 am

Re: Best way to learn Canvas?

Postby Hooray » Sun Oct 09, 2016 3: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: 11326
Joined: Tue Mar 25, 2008 8:40 am

Re: Best way to learn Canvas?

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

Awesome, thanks!
Octal450

Lead Programmer, IDG (Join our Discord!)
Download High Quality Aircraft from Octal450 Hangar
User avatar
Octal450
 
Posts: 4303
Joined: Tue Oct 06, 2015 12:51 pm

Re: Best way to learn Canvas?

Postby Hooray » Sun Oct 09, 2016 3: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: 11326
Joined: Tue Mar 25, 2008 8:40 am

Re: Best way to learn Canvas?

Postby Hooray » Sat Feb 25, 2017 2: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: 11326
Joined: Tue Mar 25, 2008 8:40 am

Previous

Return to Canvas

Who is online

Users browsing this forum: No registered users and 4 guests