[whatwg] Canvas context.drawImage clarification
Gregg Tavares
gman at google.com
Mon Jul 27 22:41:32 PDT 2009
On Mon, Jul 27, 2009 at 4:14 PM, Ian Hickson <ian at hixie.ch> wrote:
> On Mon, 27 Jul 2009, Gregg Tavares wrote:
> >
> > The diagram in the docs
> >
> http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#images
> >
> > Clearly show SX maps to DX, SY maps top DY
> >
> > But that is not the interpretation that is implemented. The
> > interpretation that is implemented is Source Top/Left maps to Dest
> > Top/Left regardless of whether SX/SY define top left or SX + WIDTH, SY +
> > HEIGHT define top left.
> >
> > That seems pretty ambiguous to me.
>
> Ignore the diagram. It's not normative. The text is the only thing that
> matters. I've moved the diagram up to the intro section to make this
> clearer.
>
>
> > I'd argue that based on the spec as currently written, all current
> > canvas implementations are wrong. Hence the suggestion to make it
> > unambiguous or get the implementation to match the spec.
>
> Could you explain what other interpretations of the following you think
> are reasonable?:
>
> # The source rectangle is the rectangle whose corners are the four points
> # (sx, sy), (sx+sw, sy), (sx+sw, sy+sh), (sx, sy+sh).
> # [...]
> # The destination rectangle is the rectangle whose corners are the four
> # points (dx, dy), (dx+dw, dy), (dx+dw, dy+dh), (dx, dy+dh).
> #
> # When drawImage() is invoked, the region of the image specified by the
> # source rectangle must be painted on the region of the canvas specified
> # by the destination rectangle [...]
It's ambiguous because images have a direction. An image that starts at 10
with a width of -5 is not the same as an image that starts at 6 with a width
of +5 any more than starting in SF and driving 5 miles south is not the same
as starting in Brisbane and driving 5 miles north.
The spec doesn't say which interpretation is correct.
The one where SrcX maps to DstX and from there width can be positive or
negative OR the one as currently implemented in 2 of the 4 browsers which is
that Source Left maps to Dest Left regardless of the starting values.
Without the diagram, both of those interpretations match the text. With the
diagram only 1 interpretation matches, it just happens the be the one no one
has implemented.
>
>
> It seems pretty unambigious to me.
>
> --
> Ian Hickson U+1047E )\._.,--....,'``. fL
> http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
> Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090727/74dd8b74/attachment-0002.htm>
More information about the whatwg
mailing list