fogleman / primitive

Reproducing images with geometric primitives.
https://primitive.lol/
MIT License
12.35k stars 608 forks source link

Reduce generated SVG file size #63

Open ghost opened 6 years ago

ghost commented 6 years ago

Since this project takes alpha from a global config, all shapes share the same opacity.

Giving alpha to the parent element, reduces size of generated SVG by 31% for n=100

css117 commented 6 years ago

Alpha on single shapes won't output same as group alpha opacity-per-element-or-per-group

davethegr8 commented 6 years ago

Instead, use a style tag as a child of the svg and it'd be a fine replacement. Example:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="640" height="480" viewbox="0 0 4096 3072">
        <style>polygon { fill-opacity: 0.5; }</style>
...