[whatwg] Canvas context.drawImage clarification

Ian Hickson ian at hixie.ch
Mon Jul 27 16:14:58 PDT 2009


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 seems pretty unambigious to me.

-- 
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