fogleman / primitive

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

Use viewbox so svg is not a fixed size (easier to animate) #79

Open evanfuture opened 6 years ago

evanfuture commented 6 years ago

Using width and height on an svg element defeats the purpose of using svg. It is better to use the viewbox. I applied the scale to the viewbox instead of the polygons to simplify future animations. (This article explains it nicely: https://css-tricks.com/scale-svg/ )

Also, I added a conditional to only apply fill-opacity to individual elements if they are different from the 1st shape's alpha channel (maybe there's a better way to do this than array[0]).