Canvas troubleshooting: Difference between revisions

Jump to navigation Jump to search
m
m (→‎Adding draw masks for Canvas: http://forum.flightgear.org/viewtopic.php?f=5&t=23781&p=231142&hilit=masks#p231142)
Line 108: Line 108:


[[File:PropertyBrowser with Canvas Preview.png|thumb|Slightly extended Property Browser to show a preview for each Canvas for troubleshooting/debugging purposes, as per [http://forum.flightgear.org/viewtopic.php?f=71&t=21139&start=75#p195232].]]
[[File:PropertyBrowser with Canvas Preview.png|thumb|Slightly extended Property Browser to show a preview for each Canvas for troubleshooting/debugging purposes, as per [http://forum.flightgear.org/viewtopic.php?f=71&t=21139&start=75#p195232].]]
You can also create a Canvas dialog showing a preview of all active Canvas textures using 10-15 lines of code, for example see:
<syntaxhighlight lang="nasal">var (width, height) = (640,480);
var window = canvas.Window.new([width,height],"dialog");
var myCanvas = window.createCanvas().set("background", canvas.style.getColor("bg_color"));
var root = myCanvas.createGroup();
var (x,y) = (30,30);
var size = 128;
var padding = 30;
foreach(var c; props.globals.getNode('canvas/by-index').getChildren('texture') ) {
if (c.getPath() == myCanvas.getPath()) continue; # skip own Canvas
var child=root.createChild("image")
                                  .setFile( 'canvas://'~c.getPath() )
  .setTranslation(x,y)
                                  .setSize(128,128);
x += size + padding;
if (x >= width) {
y += size;
        x = padding;
}
}
</syntaxhighlight>


=== Inspecting a Canvas Group ===
=== Inspecting a Canvas Group ===

Navigation menu