Drawing zero length closed subpaths

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Drawing zero length closed subpaths

Kari Pihkala
It is unclear how to draw closed subpaths with zero length [1], for instance ‘M0,0L0,0Z’ and ‘M10,10C10,10,10,10,10,10Z’. The spec doesn’t explicitly say what to do in this case (except M0,0Z) and browsers are currently drawing these inconsistently. These are the options:

    1. Draw nothing. (Chrome, Opera)
    2. Draw a dot using stroke-linecap (Safari, FF, Edge)
    3. Draw a dot using stroke-linejoin (my suggestion)

The third option is my suggestion and isn’t currently implemented by any browser. I made an animation showing why it would make sense to use stroke-linejoin instead of linecap. This example has an open subpath (a line which works fine) and a closed subpath (a triangle which looks odd with option 1 or 2): https://jsfiddle.net/mqm8vbt4/ (the animation uses SMIL, but works in Safari, FF and Chrome48).

Option 3 would keep the triangle animation consistent. The triangle has a round line join, so the dot would be drawn as a circle instead of a square or disappearing.

Which option is the way to go? The browsers draw line caps or nothing, but would it make sense to use line join? It feels wrong to draw closed paths with line caps.

BR,
Kari

[1] https://bugs.chromium.org/p/skia/issues/detail?id=4784

Reply | Threaded
Open this post in threaded view
|

Re: Drawing zero length closed subpaths

Dr. Olaf Hoffmann

Your example looks good for stroke-linejoin round, because here
no directionality is relevant, but there is no good solution for miter or
bevel (By the way - your sample exposes funny artefacts in browsers for the
bevel case, worth to explore ;o).
Obviously, with intelligence and declarative animation it is possible to
determine/extrapolate a meaningful result, but without, what to do?
At some point, there is no mathematical trick anymore to determine,
what is the right and meaningful solution.
At this point authors have to care themselves to ensure, that something
meaningful happens.

But of course, a nice and consistent behaviour for closed subpaths of zero
length would be helpful, as far as possible.


Olaf

Reply | Threaded
Open this post in threaded view
|

Re: Drawing zero length closed subpaths

Nikos Andronikos

> On 25 Jan 2016, at 9:21 PM, Dr. Olaf Hoffmann <[hidden email]> wrote:
>
>
> Your example looks good for stroke-linejoin round, because here
> no directionality is relevant, but there is no good solution for miter or
> bevel (By the way - your sample exposes funny artefacts in browsers for the
> bevel case, worth to explore ;o).
> Obviously, with intelligence and declarative animation it is possible to
> determine/extrapolate a meaningful result, but without, what to do?
> At some point, there is no mathematical trick anymore to determine,
> what is the right and meaningful solution.
> At this point authors have to care themselves to ensure, that something
> meaningful happens.
>
> But of course, a nice and consistent behaviour for closed subpaths of zero
> length would be helpful, as far as possible.


I’ve created a github issue to track this:
https://github.com/w3c/svgwg/issues/42

Please continue discussion there.

Thanks,
Nikos.
The information contained in this email message and any attachments may be confidential and may also be the subject to legal professional privilege. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. If you have received this email in error, please immediately advise the sender by return email and delete the information from your system.