Re: [whatwg] <canvas> feedback

On Mon, Apr 7, 2014 at 3:35 PM, Ian Hickson <ian@hixie.ch> wrote:

>
> On Wed, 12 Mar 2014, Rik Cabanier wrote:
> > On Wed, Mar 12, 2014 at 3:44 PM, Ian Hickson wrote:
> > > On Thu, 28 Nov 2013, Rik Cabanier wrote:
> > > > On Thu, Nov 28, 2013 at 8:30 AM, Jürg Lehni wrote:
> > > > >
> > > > > I meant to say that it I think it would make more sense if the
> > > > > path was in the current transformation matrix, so it would
> > > > > represent the same coordinate values in which it was drawn, and
> > > > > could be used in the same 'context' of transformations applied to
> > > > > the drawing context later on.
> > > >
> > > > No worries, it *is* confusing. For instance, if you emit coordinates
> > > > and then scale the matrix by 2, those coordinates from
> > > > getCurrentPath will have a scale of .5 applied.
> > >
> > > That's rather confusing, and a pretty good reason not to have a way to
> > > go from the current default path to an explicit Path, IMHO.
> > >
> > > Transformations affect the building of the current default path at
> > > each step of the way, which is really a very confusing API. The Path
> > > API on the other hand doesn't have this problem -- it has no
> > > transformation matrix. It's only when you use Path objects that they
> > > get transformed.
> >
> > This happens transparently to the author so it's not confusing.
>
> I've been confused by it multiple times over the years, and I wrote the
> spec. I am confident in calling it confusing.
>

Only when you think about it :-)


> > For instance:
> >
> > ctx.rect(0,0,10,10);
> > ctx.scale(2,2); <- should not affect geometry of the previous rect
> > ctx.stroke(); <- linewidth is scaled by 2, but rect is still 10x10
>
> It's confusing because it's not at all clear why this doesn't result in
> two rectangles of different sizes:
>
>  ctx.rect(0,0,10,10);
>  ctx.scale(2,2);
>  ctx.stroke();
>  ctx.scale(2,2);
>  ctx.stroke();
>
> ...while this does:
>
>  ctx.rect(0,0,10,10);
>  ctx.scale(2,2);
>  ctx.stroke();
>  ctx.beginPath();
>  ctx.rect(0,0,10,10);
>  ctx.scale(2,2);
>  ctx.stroke();
>
> It appears to be the same path in both cases, after all.
>

Maybe you can think about drawing paths like drawing in a graphics
application.
- moveTo, lineTo, etc = drawing line segments in the document
- scale = hitting the magnifying glass/zooming
- translate = panning the document (0,0) is the upper left of the screen
- coordinates in path segments/rect = coordinates on the screen

It would be very surprising that line art would change when zooming in or
out or panning.

Received on Tuesday, 8 April 2014 11:19:03 UTC