Free SVG icons

Mark Waddingham mark at livecode.com
Tue Jan 9 04:44:13 EST 2018


On 2018-01-03 16:16, Mark Waddingham via use-livecode wrote:
>> Please post whenever you find or write such a general 
>> "flatten-to-path".
> 
> Assuming that 'flatten-to-path' means:
> 
> "Produce a compound path which, when filled, produces the same result
> as filling and/or stroking a sequence of paths and/or shapes."
> 
> Then, in full generality, this is really quite complex - particularly
> if you want to preserve curves (which is important if you want your
> resulting path to scale arbitrarily).
> 
> There are two pieces:
> 
>   1) A 'thicken' operation which takes a path and stroke properties as
> input and produces a path which can be filled to produce the stroke.
> (i.e. the 'inside' of the path is the same as the 'inside' of the
> stroke of the original path).
> 
>   2) A 'union' operation which takes two arbitrary paths and produces
> a single path which, when filled, produces the same result as filling
> the first path, and then filling and compositing the second path on
> top of it. (i.e. the 'inside' of the path is the same as the union of
> the 'insides' of the two input paths).

For what its worth, I found that Skia (in principal) has boolean path 
operation support (i.e. the critical union operation!) - 
https://skia.org/dev/present/pathops.

As we also need something along these lines to support the general 
'clipPath' element in SVG, I had a go at implementing a simple shape 
abstraction.

A shape is basically an expressing where the factors are 
paths/ellipses/rectangles/polygons etc. and the operations are:
   - transform
   - fill (turn the shape into non-intersecting regions relative to a 
fill rule)
   - dash
   - thicken (apply stroke attributes to create the thickened lines which 
are filled to form a stroke)
   - union / intersect / difference / xor

So you can do things like:

   union(fill(thicken(... circle ...), fill(thicken(... square ...))

It seemed to work fine on simple unions/intersections of thickened 
squares circles - as long as there was no collinearity / difficult 
intersections. However, when I tried some of the simple feature icons - 
it did not work so well :(

Basically, the version of the path-ops we have in the version of Skia we 
use seem to suffer from some rather unfortunate collinearity / numerical 
issues - of course, updating Skia *might* fix the problem, however it 
seems that quite a bit has changed since we last updated Skia so that is 
not a 'drop-in replacement' type of thing *sigh*.

Warmest Regards,

Mark.

P.S. One thing I do need to try is 'fuzzing' the shapes before applying 
the boolean ops - i.e. adding a tiny random delta, small enough that you 
won't notice when rendered, but large enough that it turns any difficult 
intersections into easier ones.

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




More information about the use-livecode mailing list