20,741
edits
Line 181: | Line 181: | ||
The next step is processing the x,y,width and height attributes of the image tag - to do that, we can also refer to existing code: | The next step is processing the x,y,width and height attributes of the image tag - to do that, we can also refer to existing code: | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="diff"> | ||
diff --git a/Nasal/canvas/svg.nas b/Nasal/canvas/svg.nas | |||
index d7fe570..64e1fbf 100644 | |||
--- a/Nasal/canvas/svg.nas | |||
+++ b/Nasal/canvas/svg.nas | |||
@@ -578,6 +578,22 @@ var parsesvg = func(group, path, options = nil) | |||
append(defs_stack, "defs"); | |||
return; | |||
} | |||
+ else if (name == "image") | |||
+ { | |||
+ printlog("alert", "image tag encountered (not yet implemented)"); | |||
+ | |||
+ var ref = attr["xlink:href"]; | |||
+ if( ref == nil ) | |||
+ return printlog("alert", "Invalid or missing href in image tag: '" ~ ref ~ '"'); | |||
+ pushElement('image', attr['id']); | |||
+ var image = stack[-1]; | |||
+ if ( attr['x'] != nil and attr['y'] != nil) | |||
+ image.setTranslation(attr.x, attr.y); | |||
+ if ( attr['width'] !=nil and attr['height']!=nil) | |||
+ image.setSize(attr.width,attr.height); | |||
+ image.setFile(ref); # set the filename to the xlink/href value | |||
+ #printlog("alert", "image added"); | |||
+ } | |||
else | |||
{ | |||
printlog("info", "Skipping unknown element '" ~ name ~ "'"); | |||
</syntaxhighlight> | </syntaxhighlight> | ||