Template:Canvas Snippets Boilerplate
Jump to navigation
Jump to search
var (width, height) = (320, 160);
var title = 'My new Window';
# create a new window, dimensions are WIDTH x HEIGHT, using the dialog decoration (i.e. titlebar)
var window = canvas.Window.new([width, height], "dialog")
.set('title', title);
##
# The del() function is the destructor of the Window
# which will be called upon termination (dialog closing)
# You can use this to do resource management (clean up timers, listeners or background threads)
# window.del = func {
# print("Cleaning up window: ", title, "\n");
# # explanation for the call() technique at:
# # https://wiki.flightgear.org/Object_oriented_programming_in_Nasal#Making_safer_base-class_calls
# call(canvas.Window.del, [], me);
# };
# 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();| Work in progress This article or section will be worked on in the upcoming hours or days. See history for the latest developments. |
| Note This template is used by most Canvas Snippets to make them entirely self-contained. |