20,741
edits
(Created page with "{{Stub}} == Objective == Document and demonstrate how the Canvas/Nasal SVG module can be extended to suport additional SVG features. == Background == == Examples == === <i...") |
m (→Examples) |
||
| Line 5: | Line 5: | ||
== Background == | == Background == | ||
== Test Code == | |||
<syntaxhighlight lang="xml"> | |||
var (width,height) = (320,160); | |||
var svg_filename = ""; | |||
var title = 'SVGTest: '~svg_filename; | |||
# 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); | |||
# adding a canvas to the new window and setting up background colors/transparency | |||
var myCanvas = window.createCanvas().set("background", canvas.style.getColor("bg_color")); | |||
# creating the top-level/root group which will contain all other elements/group | |||
var root = myCanvas.createGroup(); | |||
# change the background color | |||
myCanvas.set("background", "#ffaac0"); | |||
# creating the top-level/root group which will contain all other elements/group | |||
var root = myCanvas.createGroup(); | |||
var svg_symbol = root.createChild('group'); | |||
canvas.parsesvg(svg_symbol, svg_filename); | |||
svg_symbol.setTranslation(width/2,height/2); | |||
#svg_symbol.setScale(0.2); | |||
#svg_symbol.setRotation(radians) | |||
</syntaxhighlight> | |||
== Examples == | == Examples == | ||