Howto:Extend the Canvas SVG module: Difference between revisions

Jump to navigation Jump to search
Line 95: Line 95:
The next step is actually mapping the SVG markup to the corresponding Nasal/Canvas code.  
The next step is actually mapping the SVG markup to the corresponding Nasal/Canvas code.  


However, for starters, we will keep things simple and add a fixed image from $FG_ROOT/Textures whenever an image tag is encountered, e.g. a splash screen texture:
However, for starters, we will keep things simple and add a fixed image from $FG_ROOT/Textures whenever an image tag is encountered, e.g. a splash screen texture.


For that, we need to take into account that, as per the SVG spec, an image tag may not only refer to raster images, but also other vector graphics (SVG files), which means that we need to look at the file extension - i.e. only add a raster image primitive (Canvas.Image) if the extension is not .svg:
{{See also|raster image stuff}}
 
So, the corresponding Nasal/Canvas magic to load a raster image from the base package looks basically like this:
 
<syntaxhighlight lang="nasal">
</syntaxhighlight>
 
We also need to take into account that, as per the SVG spec, an image tag may not only refer to raster images, but also other vector graphics (SVG files), which means that we need to look at the file extension - i.e. only add a raster image primitive (Canvas.Image) if the extension is not .svg:

Navigation menu