Canvas snippets: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 28: Line 28:


<syntaxhighlight lang="nasal" enclose="div">
<syntaxhighlight lang="nasal" enclose="div">
var (width, height) = (512,512);
# Create a standalone Canvas (not attached to any GUI dialog/aircraft etc)  
# Create a standalone Canvas (not attached to any GUI dialog/aircraft etc)  
var myCanvas = canvas.new({
var myCanvas = canvas.new({
   "name": "Livery Test",  # The name is optional but allow for easier identification
   "name": "Livery Test",  # The name is optional but allow for easier identification
   "size": [512, 512], # Size of the underlying texture (should be a power of 2, required) [Resolution]
   "size": [width, height], # Size of the underlying texture (should be a power of 2, required) [Resolution]
   "view": [512, 512],  # Virtual resolution (Defines the coordinate system of the canvas [Dimensions]
   "view": [width, height],  # Virtual resolution (Defines the coordinate system of the canvas [Dimensions]
                         # which will be stretched the size of the texture, required)
                         # which will be stretched the size of the texture, required)
   "mipmapping": 1      # Enable mipmapping (optional)
   "mipmapping": 1      # Enable mipmapping (optional)
Line 45: Line 46:
# OPTIONAL: Create a Canvas dialog window to hold the canvas and show that it's working
# OPTIONAL: Create a Canvas dialog window to hold the canvas and show that it's working
# the Canvas is now standalone, i.e. continues to live once the dialog is closed!
# the Canvas is now standalone, i.e. continues to live once the dialog is closed!
var window = canvas.Window.new([512,512],"dialog");
var window = canvas.Window.new([width,height],"dialog");
window.setCanvas(myCanvas);
window.setCanvas(myCanvas);
</syntaxhighlight>
</syntaxhighlight>

Navigation menu