Re: [whatwg] Canvas v5 API additions

On Thu, 29 Mar 2012, Ashley Gullen wrote:
> On 28 March 2012 22:41, Ian Hickson <ian@hixie.ch> wrote:
> > On Sat, 29 Oct 2011, Ashley Gullen wrote:
> > >
> > > I had a quick go with setting ctx.mozImageSmoothingEnabled = false.  
> > > It works great with drawImage.  However it does not appear to affect 
> > > repeated patterns. This makes for quite a strange effect where the 
> > > game's sprites are pixellated but the tiled backgrounds are bilinear 
> > > filtered.  So it's half way there.
> >
> > This matches what the spec has done; you can make it also affect 
> > patterns if you like by first drawing the image scaled to another 
> > canvas and then using that as the pattern (so the pattern doesn't have 
> > to be scaled).
> >
> > If you just have everything scaled, though, you might be better off 
> > just drawing everything to the canvas without any scaling and then 
> > just scaling the whole thing once per frame, either by stretching the 
> > canvas and relying on CSS to turn off smoothing, or by using 
> > drawImage().
> 
> Why would anyone want to turn off smoothing for just drawImage and not 
> repeat patterns?  Our games use repeat patterns to draw tiled textures 
> as a quicker way to render a grid of drawImage, so why not make them 
> work the same?  If I wasn't clear, in the quoted post I thought the fact 
> mozImageSmoothingEnabled did not affect repeat patterns was a bug.

Fair enough. Since nobody has given a reason why patterns would ignore 
imageSmoothingEnabled, and your argument seems reasonable, I've changed 
the spec to require that it affect both.


> IMO the smoothing property should affect everything (perhaps even the 
> aliased lines request that was brought up).  Things like a retro 
> pixel-style game will want a simple option to deliberately 
> alias/nearest-neighbour everything on the canvas, and having the 
> smoothing option affect some things but not others seems to just be an 
> inconvenience.

I haven't added anything yet for different kinds of line drawing.


On Thu, 29 Mar 2012, Ashley Gullen wrote:
>
> Thanks.  Having looked at the changes, I think it might be more 
> appropriate to put this as a third global option, e.g. "globalAlpha", 
> "globalCompositeOperation" and "globalSmoothingEnabled" (default true, 
> because I think most implementations currently do smoothing).  I think 
> the option should definitely affect all rendering on the canvas (images, 
> patterns, lines, possibly text?) since applications like retro games 
> need a simple switch to affect everything, and the name 
> "globalSmoothingEnabled" should better imply it will affect everything.

I think the use case of "just do everything at a lower quality" isn't 
really well handled by just disabling anti-aliasing, especially as we go 
forward into really high-resolution screens. If you want something to look 
like it was rendered at 320x240 or something, then render it at that 
resolution using a canvas with those dimensions and then scale it to 
another canvas using imageSmoothing disabled.

(Might still not work since the 320x480 canvas could itself be backed 
with a high res store...)

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

Received on Friday, 1 June 2012 02:05:40 UTC