Canvas snippets: Difference between revisions

Jump to navigation Jump to search
m
→‎Adding Raster Images: http://forum.flightgear.org/viewtopic.php?f=4&t=25747&start=90#p238157
m (→‎Adding Raster Images: http://forum.flightgear.org/viewtopic.php?f=4&t=25747&start=90#p238157)
Line 77: Line 77:
# path is relative to $FG_ROOT (base package)
# path is relative to $FG_ROOT (base package)
var path = "Textures/Splash1.png";
var path = "Textures/Splash1.png";
# create an image child for the texture
var child=root.createChild("image")
          .setFile( path )
  .setTranslation(100,10)
                                  .setSize(130,130);
</syntaxhighlight>
|-
|}
The '''filename''' could also just as well be a URL, i.e. a raster image retrieved via http:
{| class="wikitable"
|-
! Screenshot !! Code !!
|-
| [[File:Canvas Snippets-raster image.png|thumb|Canvas snippet demonstrating how to load a raster image]] ||
<syntaxhighlight lang="nasal" enclose="div">
# path is relative to $FG_ROOT (base package)
var path = "http://www.worldwidetelescope.org/docs/Images/MapOfEarth.jpg";
# create an image child for the texture
# create an image child for the texture
var child=root.createChild("image")
var child=root.createChild("image")

Navigation menu