Re: [whatwg] Canvas size and double buffering.

2010-02-04 Thread Nikita Popov
Am 04.02.2010 01:00, schrieb Tim Hutt: On 3 February 2010 23:16, Boris Zbarskybzbar...@mit.edu wrote: On 2/3/10 6:12 PM, Tim Hutt wrote: Ah yes that works nicely Hmm maybe I spoke too soon. The interaction of the CSS size and the canvas.width/height is confounding! It seems

Re: [whatwg] Canvas size and double buffering.

2010-02-04 Thread Nikita Popov
I tried to solve the aliasing problem in Firefox and found out, that it really isn't possible to get it right, if you set the width and height in CSS: If you leave the css-width/height as it is when resizing the canvas, it will get blurred in Firefox. If you change it to 'auto' it won't resize

Re: [whatwg] Canvas size and double buffering.

2010-02-04 Thread Brian Campbell
On Feb 4, 2010, at 1:55 AM, Robert O'Callahan wrote: On Thu, Feb 4, 2010 at 6:50 PM, Brian Campbell lam...@continuation.org wrote: I think the most reasonable approach would be to say that the getBoundingClientRect().width or height is rounded to the nearest pixel. Boxes are displayed

Re: [whatwg] Canvas size and double buffering.

2010-02-04 Thread Robert O'Callahan
On Fri, Feb 5, 2010 at 3:25 AM, Brian Campbell lam...@continuation.orgwrote: On Feb 4, 2010, at 1:55 AM, Robert O'Callahan wrote: On Thu, Feb 4, 2010 at 6:50 PM, Brian Campbell lam...@continuation.org wrote: I think the most reasonable approach would be to say that the

[whatwg] Canvas size and double buffering.

2010-02-03 Thread Tim Hutt
Hi, I've been trying to use the HTML5 canvas to implement a slippy map. It works ( http://concentriclivers.com/ ), but there were a couple of issues I had for which there seems to be no good solution. 1. You can only set the size exactly in pixels. It is very hard to get a resizable canvas that

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Boris Zbarsky
On 2/3/10 9:05 AM, Tim Hutt wrote: 1. You can only set the size exactly in pixels. It is very hard to get a resizable canvas that fills the page. You *can* set the size in CSS, but it doesn't work very well (e.g. using left,right-margin: auto; to centre the canvas doesn't work. Also it scales

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Simon Fraser
On Feb 3, 2010, at 7:59 AM, Boris Zbarsky wrote: On 2/3/10 9:05 AM, Tim Hutt wrote: 1. You can only set the size exactly in pixels. It is very hard to get a resizable canvas that fills the page. You *can* set the size in CSS, but it doesn't work very well (e.g. using left,right-margin: auto;

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Tim Hutt
On 3 February 2010 16:50, Simon Fraser s...@me.com wrote: On Feb 3, 2010, at 7:59 AM, Boris Zbarsky wrote: On 2/3/10 9:05 AM, Tim Hutt wrote: 1. You can only set the size exactly in pixels. It is very hard to get a resizable canvas that fills the page. You *can* set the size in CSS, but it

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Boris Zbarsky
On 2/3/10 12:22 PM, Tim Hutt wrote: Yes it should be cleared and there should be a oncanvasresize() callback. What uses cases does this cover that are not covered by a general resize event? -Boris

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Boris Zbarsky
On 2/3/10 1:01 PM, Tim Hutt wrote: Good point, it would be better to call it 'onresize' for consistency. So my revised suggestion is: 1. Support more length specifiers for the width and height of a canvas(%, em, etc.). 2. Add an onresize event to the canvas tag. When the canvas is resized it is

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Tim Hutt
On 3 February 2010 17:45, Boris Zbarsky bzbar...@mit.edu wrote: On 2/3/10 12:22 PM, Tim Hutt wrote: Yes it should be cleared and there should be a oncanvasresize() callback. What uses cases does this cover that are not covered by a general resize event? Good point, it would be better to

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Oliver Hunt
On Feb 3, 2010, at 10:01 AM, Tim Hutt wrote: On 3 February 2010 17:45, Boris Zbarsky bzbar...@mit.edu wrote: On 2/3/10 12:22 PM, Tim Hutt wrote: Yes it should be cleared and there should be a oncanvasresize() callback. What uses cases does this cover that are not covered by a general

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Tim Hutt
On 3 February 2010 19:23, Oliver Hunt oli...@apple.com wrote: 1. Support more length specifiers for the width and height of a canvas(%, em, etc.). This doesn't really make sense for the backing buffer as it is logically defined in terms of pixel. The layout engine would decide how many

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Boris Zbarsky
On 2/3/10 2:54 PM, Tim Hutt wrote: a) Otherwise width:100% in CSS and width=100% in HTML would have different meanings. Confusing! I'm not suggesting that. I'm saying we keep supporting only integers in the width attribute and if you put width:100% in your CSS and the canvas resizes you can

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Oliver Hunt
On Feb 3, 2010, at 11:54 AM, Tim Hutt wrote: On 3 February 2010 19:23, Oliver Hunt oli...@apple.com wrote: 1. Support more length specifiers for the width and height of a canvas(%, em, etc.). This doesn't really make sense for the backing buffer as it is logically defined in terms of

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Oliver Hunt
On Feb 3, 2010, at 11:54 AM, Tim Hutt wrote: On 3 February 2010 19:23, Oliver Hunt oli...@apple.com wrote: 1. Support more length specifiers for the width and height of a canvas(%, em, etc.). This doesn't really make sense for the backing buffer as it is logically defined in terms of

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Brian Campbell
On Feb 3, 2010, at 3:14 PM, Boris Zbarsky wrote: On 2/3/10 2:54 PM, Tim Hutt wrote: Well, yes it would be good to have onresize for all elements. Which is why it's being worked on anyway. I'm curious; where is this being worked on? Discussed here on this list? On another list? Or is it

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Boris Zbarsky
On 2/3/10 5:27 PM, Brian Campbell wrote: I'm curious; where is this being worked on? Discussed here on this list? On another list? I believe it's been discussed on public-webapps. It's also implemented in IE, to some extent. -Boris

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Tim Hutt
On 3 February 2010 20:14, Boris Zbarsky bzbar...@mit.edu wrote: Yep.  canvas.width = canvas.getBoundingClientRect().width; Ah yes that works nicely, with one minor caveat: it seems to include the width of the border if there is one, so you have to take that into account. You're right, this is a

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Boris Zbarsky
On 2/3/10 6:12 PM, Tim Hutt wrote: Ah yes that works nicely, with one minor caveat: it seems to include the width of the border if there is one, so you have to take that into account. You're right, this is a better solution. Ah, yes. Padding too. You could instead ask for the computed style

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Tim Hutt
On 3 February 2010 23:16, Boris Zbarsky bzbar...@mit.edu wrote: On 2/3/10 6:12 PM, Tim Hutt wrote: Ah yes that works nicely Hmm maybe I spoke too soon. The interaction of the CSS size and the canvas.width/height is confounding! It seems if you set a CSS width of, say 80% then that is that and

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Boris Zbarsky
On 2/3/10 7:00 PM, Tim Hutt wrote: http://concentriclivers.com/canvas.html (the source is nicely formatted and very short) So you want a canvas that takes 80% of the horizontal space but has an integer width in pixels? Which of those constraints do you really want to relax? Presumably the

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Brian Campbell
On Feb 3, 2010, at 7:00 PM, Tim Hutt wrote: On 3 February 2010 23:16, Boris Zbarsky bzbar...@mit.edu wrote: On 2/3/10 6:12 PM, Tim Hutt wrote: Ah yes that works nicely Hmm maybe I spoke too soon. The interaction of the CSS size and the canvas.width/height is confounding! It seems if you

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Robert O'Callahan
On Thu, Feb 4, 2010 at 6:50 PM, Brian Campbell lam...@continuation.orgwrote: I think the most reasonable approach would be to say that the getBoundingClientRect().width or height is rounded to the nearest pixel. Boxes are displayed rounded to the nearest pixel, with no fractional pixels being

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Robert O'Callahan
On Thu, Feb 4, 2010 at 1:00 PM, Tim Hutt tdh...@gmail.com wrote: http://concentriclivers.com/canvas.html (the source is nicely formatted and very short) canvas.style.width = ww; canvas.style.height = hh; Perhaps you meant ww +

Re: [whatwg] Canvas size and double buffering.

2010-02-03 Thread Robert O'Callahan
In general, keeping the canvas buffer size matching its rendered size so that no resampling occurs requires clearing and repainting the canvas during browser zoom changes as well as layout changes (and possibly during other changes such as changes to the transforms of ancestors). It also requires