W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2013

Re: [whatwg] Path API feedback

From: Rik Cabanier <cabanier@gmail.com>
Date: Thu, 5 Sep 2013 15:56:43 -0700
Message-ID: <CAGN7qDDXqyZt2gkmttoUps3qgEUiesBdpGmhotUhk4Ay6S_PVQ@mail.gmail.com>
To: Ian Hickson <ian@hixie.ch>
Cc: whatwg <whatwg@lists.whatwg.org>
On Tue, Aug 20, 2013 at 3:36 PM, Ian Hickson <ian@hixie.ch> wrote:

> On Fri, 26 Apr 2013, Rik Cabanier wrote:
> >
> > I think an author would expect that 'addPathByStrokingPath' and other
> > path methods render as if you stroked/outlined directly on the canvas
> > context. Same goes for 'addPath'.
> >
> > I believe very few people actually want the current behavior that's in
> > the spec.
>
> I don't know how true that is.
>
> It seems logical to me that this:
>
>    context.beginPath();
>    context.rect(0,0,100,100);
>    context.rect(50,50,150,150);
>    context.fill();
>
> ...should do the same as this:
>
>    var p1 = new Path();
>    p1.rect(0,0,100,100);
>    var p2 = new Path();s
>    p2.rect(50,50,150,150);
>    var p = new Path();
>    p.addPath(p1);
>    p.addPath(p2);
>    context.fill(p);
>
> ...for any combination of path commands where I've put the rect()s.
>

Yes, that would be reasonable behavior since a path is just an aggregation
of segments.

The problem happens when you call fill or stroke multiple times.

For instance:

context.beginPath();
context.rect(0,0,100,100);
context.fill();
context.beginPath();
context.rect(200,50,-150,150);
context.fill();


Now I want to create a region that covers what was drawn.

p1.rect(0,0,100,100);
var p2 = new Path();s
p2.rect(200,50,-150,150);
var p = new Path();
p.addPath(p1);
p.addPath(p2);


'p' won't describe the same area as what was filled.


>
> > > > I think the spec needs to mention that
> > > > - sections of the path where both edges are filled should be removed
> > > > - winding needs to be done so eofill and fill give the same result
> > >
> > > I've filed a bug for adding something like this:
> > >
> > >    https://www.w3.org/Bugs/Public/show_bug.cgi?id=21835
> > >
> > > I'm not sure exactly what the algorithm should be (as we discussed on
> > > IRC today), so if anyone has any input here, please don't hesitate to
> > > comment.
> >
> > I can help if needed. I know the skia people are working on this as
> > well.
> >
> > The algorithm is fairly straightforward to describe in prose.
> > Implementation is very hard though...
>
> Please do add such help as comments on the bug, that would be very
> helpful.
>
> --
> Ian Hickson               U+1047E                )\._.,--....,'``.    fL
> http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
> Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
>
Received on Thursday, 5 September 2013 22:57:13 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:09 UTC