Jump to content
You must now use your email address to sign in [click for more info] ×

SVG "stroke-dasharray" interacts surprisingly with non-uniform SVG scaling transformation


Recommended Posts

A non-uniform SVG scale transformation -- eg "scale(1,-30)" --

results in dash pattern being scaled by a factor of 30, eg

  <g transform="scale(1,-30)">
    <g style="stroke-dasharray: 5 3 1 3;">
      <path d="..."/>
    </g>
</g>

will render a path with very large dashes, in effect scaling the path's dash-array by a factor of 30, not by 1.

 

It is entirely unclear what the "correct" behaviour is, but other programs (including the SVG renders in browsers I've tried Firefox and Safari)

instead appear to scale the dashes by the minimum of the differing X and Y scales, or "1" in this case.

 

I suggest this may be the less-bad decision, for compatibility/consistency reasons.

 

SVG is simply a nightmare of misdesign and confusion, isn't it?

 

svg-transform-test-case-2.svg

Link to comment
Share on other sites

  • Staff

Hi Richard,

Unfortunately what the SVG is doing isn't something that is supported or possible within Designer. In Designer when the contents of the groups are transformed, the stroke weight is only ever scaled upwards if that object's stroke has 'Scale with object' enabled. However what this does is just increase the Stroke weight to ensure the stroke still maintains the correct ration when the object has been scaled. The dash pattern is then applied to that stroke weight, so its never possible to give it a non uniform scaling that looks to be what is happening with your SVG.

Link to comment
Share on other sites

Hi, I wasn't suggesting that Designer support non-equal scaling of strokes.  I don't even want that myself!

 

What I am suggesting is that the fall-back *choice* Designer makes in how to interpret this unsupported scaling isn't the same as other programs (Firefox, Safari=Webkit, Illustrator CS4 (the only version I can still run sometimes) do, which is to choose to scale the stroke dash pattern by the *minimum* of transformation's scale-x, scale-y instead of the maximium.

 

So in a "transform=scale(30,1)" choose not to scale the stroke pattern (and stroke width, etc) at all, instead of scaling by a factor of 30.

 

Yes, this is an arbitrary choice, but it's one Designer seems to make differently from some other SVG-consuming programs, and I can argue that the opposite way of doing things is slightly superior.   (It would certainly simplify my life to not have to patch this stuff up by hand.)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.