Howto:Extend the Canvas SVG module: Difference between revisions

Jump to navigation Jump to search
Line 32: Line 32:
{{Note|The following code is sufficiently self-contained, so that it can be put into a separate Nasal module, but also executed as a standalone snippet using the [[Nasal Console]]}}  
{{Note|The following code is sufficiently self-contained, so that it can be put into a separate Nasal module, but also executed as a standalone snippet using the [[Nasal Console]]}}  
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
var (width,height) = (320,160);
var (width,height) = (320,320);
var svg_filename = "/Nasal/img.svg";
var svg_filename = "/Textures/img.svg";
var title = 'SVGTest: '~svg_filename;
var title = 'SVGTest: '~svg_filename;


# create a new window, dimensions are WIDTH x HEIGHT, using the dialog decoration (i.e. titlebar)
# create a new window, dimensions are WIDTH x HEIGHT, using the dialog decoration (i.e. titlebar)
Line 55: Line 54:
var svg_symbol = root.createChild('group');
var svg_symbol = root.createChild('group');
canvas.parsesvg(svg_symbol, svg_filename);
canvas.parsesvg(svg_symbol, svg_filename);
svg_symbol.setTranslation(width/2,height/2);
#svg_symbol.setScale(0.2);
#svg_symbol.setRotation(radians)
</syntaxhighlight>
</syntaxhighlight>


Navigation menu