Board index FlightGear Development Canvas

[SOLVED] Trying to experiment 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.

[SOLVED] Trying to experiment Canvas

Postby clm76 » Thu Aug 04, 2016 8:55 pm

Hello,

I'm learning canvas and i tried to implement the code of the wiki :  "Howto:Add a 2D canvas instrument to your aircraft".

I created a simple rectangle with a texture (black) named “ND.screenL” and I wrote the code of the wiki in the aircraft console :

Code: Select all
var my_canvas = canvas.new({
  "name": "MFD-Test", 
  "size": [1024, 1024],
  "view": [768, 1024],
  "mipmapping": 1 
});
my_canvas.addPlacement({"node": "ND.screenL"});
var group = my_canvas.createGroup();
var text = group.createChild("text", "optional-id-for element")
                .setTranslation(10, 20)     
                .setAlignment("left-center")
                .setFont("LiberationFonts/LiberationSans-Regular.ttf")
                .setFontSize(14, 1.2) 
                .setColor(1,0,0) 
                .setText("This is a text element");

text.hide();
text.setText("Hello!").show();

But nothing is written in the rectangle … Which error I made?
Last edited by clm76 on Sun Aug 07, 2016 5:35 pm, edited 1 time in total.
clm76
 
Posts: 149
Joined: Tue Oct 30, 2012 8:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2018.3.0
OS: Linux Mint 18.3

Re: Trying to experiment Canvas

Postby PINTO » Thu Aug 04, 2016 9:13 pm

Is your nasal file in the same folder as the model and xml?
Actively developing the MiG-21bis (github repo) (forum thread) (dev discord) (fg wiki)

http://opredflag.com is an active flightgear dogfighting community (using a system that isn’t bombable)
User avatar
PINTO
 
Posts: 947
Joined: Wed Oct 21, 2015 6:28 pm
Callsign: pinto
Version: 2016.3.0
OS: Win10

Re: Trying to experiment Canvas

Postby Necolatis » Thu Aug 04, 2016 10:03 pm

In my experience, referencing the texture name works more reliable:

my_canvas.addPlacement({"node": "ND.screenL", "texture": "black.png"});
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2044
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Trying to experiment Canvas

Postby Necolatis » Thu Aug 04, 2016 11:26 pm

It might also be cause there is no lightning on your texture. If so try turn the aircraft so the sun hits the texture.
Or make the object emissive.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2044
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Trying to experiment Canvas

Postby PINTO » Thu Aug 04, 2016 11:33 pm

Necolatis wrote in Thu Aug 04, 2016 11:26 pm:It might also be cause there is no lightning


sets weather to thunderstorm
Actively developing the MiG-21bis (github repo) (forum thread) (dev discord) (fg wiki)

http://opredflag.com is an active flightgear dogfighting community (using a system that isn’t bombable)
User avatar
PINTO
 
Posts: 947
Joined: Wed Oct 21, 2015 6:28 pm
Callsign: pinto
Version: 2016.3.0
OS: Win10

Re: Trying to experiment Canvas

Postby Necolatis » Thu Aug 04, 2016 11:41 pm

haha Pinto, lol
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2044
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Trying to experiment Canvas

Postby clm76 » Fri Aug 05, 2016 8:14 am

Thanks for your replies.

It was a problem of texture not well defined.
It's ok now.

I have another question : Is there a plane with a canvas VSD ?
clm76
 
Posts: 149
Joined: Tue Oct 30, 2012 8:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2018.3.0
OS: Linux Mint 18.3

Re: Trying to experiment Canvas

Postby Hooray » Fri Aug 05, 2016 3:54 pm

Omega95 once created a Canvas VSD, my suggestion would be to search the forum/wiki for details:

Image
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: 11427
Joined: Tue Mar 25, 2008 8:40 am

Re: Trying to experiment Canvas

Postby clm76 » Sun Aug 07, 2016 5:34 pm

Ok found.

Thanks for all.
clm76
 
Posts: 149
Joined: Tue Oct 30, 2012 8:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2018.3.0
OS: Linux Mint 18.3

Re: [SOLVED] Trying to experiment Canvas

Postby ausdkunst » Tue Aug 09, 2016 5:17 am

Hi I too have been trying to get the hello message on my model and have set the texture to be emissive. Still I don't get any message. What can be the cause?
BULLDOG RS (The No.1 place for Flightgear automobile): https://bulldogrs.wordpress.com/
User avatar
ausdkunst
 
Posts: 343
Joined: Fri Aug 28, 2015 9:47 am
Callsign: bulldog
Version: 2016.2.1
OS: Mac OS X

Re: [SOLVED] Trying to experiment Canvas

Postby clm76 » Tue Aug 09, 2016 7:26 am

Hi,

I sent you a mail with a quick tutorial.
clm76
 
Posts: 149
Joined: Tue Oct 30, 2012 8:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2018.3.0
OS: Linux Mint 18.3


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest