[whatwg] Stroking algorithm in Canvas 2d

Ian Hickson ian at hixie.ch
Fri Sep 27 15:35:35 PDT 2013


On Mon, 9 Sep 2013, Rik Cabanier wrote:
> On Mon, Sep 9, 2013 at 9:33 AM, Ian Hickson <ian at hixie.ch> wrote:
> > On Thu, 5 Sep 2013, Rik Cabanier wrote:
> > >
> > > we've looked over the algorithm in the Canvas spec that describes 
> > > how strokes are computed. [1] We think that this section is making 
> > > some incorrect assumptions. For instance, the dashes are calculated 
> > > over the total lenght of all subpaths, but each subpath should be 
> > > treated separately.
> >
> > That's intentional, otherwise if you stroke an already-dashed line, 
> > you get weird results.
> 
> As Stephan said, when would this happen? Are you thinking of a case 
> where you did the dashing yourself and then dash/stroke it again? If so, 
> that is expected to give different results.

Expected by whom?

The idea here is that this line:

  ------------------------------

...would result in this dash (assuming equally spaced on-off):

  ---   ---   ---   ---   ---   

...while this line, dashed with the same stroke:

  ---   ---   ---   ---   ---   

...would result in this different line, rather than result in no change:

  ---         ---         ---

...and this line, dashed with the same stroke:

  --  --  --  --  --  --  --  --

...would result in something more like:

  --  -       --  -       --  - 

...rather than, again, resulting in no change.


> > > It's also a bit strange that the spec is trying to describe how to 
> > > stroke.
> >
> > It's trying to describe sufficient detail to get interoperable 
> > behaviour.
> >
> > > For instance, it goes in minute detail on how dashes are applied but 
> > > the hardest part of stroking ("inflating the paths in path 
> > > perpendicular to the direction") is not described at all.
> >
> > Is there any ambiguity in the part that's not described?
> 
> Yes. What is "inflating"?

The dictionary definition is what I intended. To grow, increase in size, 
get bigger in all directions. Inflate.

If you have any better suggestion for how to word this, I'm all for it.


> A stroked bezier curve is no longer a bezier and has to be calculated.

Yes. The idea of defining it in terms of the earlier path is that there's 
no need to be explicit about the maths here.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list