20,741
edits
m (→Adding Raster Images: http://forum.flightgear.org/viewtopic.php?f=4&t=25747&start=90#p238157) |
m (→Adding Raster Images: more specific snippets for thorsten's space shuttle avionics effort: http://forum.flightgear.org/viewtopic.php?f=4&t=25747&start=90#p238159) |
||
| Line 92: | Line 92: | ||
! Screenshot !! Code !! | ! Screenshot !! Code !! | ||
|- | |- | ||
| [[File:Canvas | | [[File:Canvas-raster-images-via-url.png|thumb|screen shot demonstrating how Nasal and Canvas can be used to display raster images downloaded on demand]] || | ||
<syntaxhighlight lang="nasal" enclose="div"> | <syntaxhighlight lang="nasal" enclose="div"> | ||
# | # create a new window, dimensions are 400 x 200, using the dialog decoration (i.e. titlebar) | ||
var path = "http://www.worldwidetelescope.org/docs/Images/MapOfEarth.jpg"; | var window = canvas.Window.new([400,200],"dialog"); | ||
# adding a canvas to the new window and setting up background colors/transparency | |||
var myCanvas = window.createCanvas().set("background", canvas.style.getColor("bg_color")); | |||
# Using specific css colors would also be possible: | |||
# myCanvas.set("background", "#ffaac0"); | |||
# creating the top-level/root group which will contain all other elements/group | |||
var root = myCanvas.createGroup(); | |||
# path now a URL | |||
var url = "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") | ||
.setFile( url) | |||
.setTranslation(45,22) | |||
.setSize( | .setSize(310,155); | ||
</syntaxhighlight> | </syntaxhighlight> | ||