SVG icons in buttons

Mark Waddingham mark at livecode.com
Wed Feb 27 06:28:57 EST 2019


On 2019-02-27 11:23, hh via use-livecode wrote:
> That's a fake, as long it is called "SVG"-Icons.
> These are ordinary images, converted from SVG, no longer
> SVG objects.
> 
> Also the import is not a real SVG import but an import
> of the converted image.
> 
> This is fine, but we shouldn't name these objects "SVG"
> as they are ordinary images in the stack.

Well regardless of what people want to call them or how they want to 
refer to them...

It is possible in 9.0+ to use a reasonably sized subset of the SVG 
vector image format to define your icons and graphics in a highly 
efficient way:

   - in storage: compiled svg files (drawings) are almost always a lot 
smaller than the original text on disk
   - in memory: drawings take the same amount of space in memory and to 
render as they do on disk (which is not true of the XML data-structure 
needed in memory to render raw SVG!)
   - in time: drawings are a sequence of vector graphics operations which 
require virtually no processing to execute, they are just run from start 
to end as needed (again something which is not true of raw SVG which, 
being mostly declarative, requires a lot of processing to render)

As drawings are vector based, they scale to any size and density very 
naturally (i.e. they are not raster images!) - which means you no longer 
need to have multiple rasterized versions of icons/graphics, nor 
re-generate them each time a new screen density appears.

Admittedly you do need to compile your SVG to the drawing format so you 
can use them in images, but then previously you needed to re-rasterize 
images at various densities anyway to make your apps look as good as 
possible. (However, both of these are entirely scriptable - e.g. in the 
standalone build start handler - or by executing a suitably crafted 
handler in your stack from the message box).

If you need an element of dynamic SVG image generation at runtime then 
you can include the drawing script-library in a standalone, and use 
drawingSvgCompile and friends there too.

Warmest Regards,

Mark.

P.S. In response to Haken's query: the need to compile SVG to drawings, 
and the SVG compiler being a LiveCode library is why you can't set the 
filename of an image to an SVG file - the engine only understands the 
'drawing' format, not SVG.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list