Skip to content

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

Open
evanfuture wants to merge 2 commits into
fogleman:masterfrom
evanfuture:svg-optimisations
Open

evanfuture wants to merge 2 commits into
fogleman:masterfrom
evanfuture:svg-optimisations

Conversation

@evanfuture

Copy link
Copy Markdown

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]).

Also, only apply opacity to individual elements if they are different (maybe there's a better way to do this)
bmaltais added a commit to bmaltais/primitive that referenced this pull request Jul 9, 2018
@loyality7

Copy link
Copy Markdown

Heads up, this panics for me: with -s 128 on a 256px working image the scale is 0.5, so int(scale) is 0 and NewModel divides by zero. With a non-integer scale (e.g. -s 400) the viewBox comes out as 400x400 even though the shapes are in the 256px input space, so the drawing only covers part of the image. Using the input image's width/height for the viewBox fixes both. I did that in my fork if it helps: https://github.com/loyality7/primitive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址