[whatwg] Canvas in Workers
Gregg Tavares (社用)
gman at google.com
Thu Nov 29 23:24:17 PST 2012
on ImageBitmap should zero size canvases just work (and create a 0 sized
ImageBitmap)?
My personal preference is for APIs that just work with zero sizes so I
don't have to write lots of special cases for handling zero.
For example [1,2,3].slice(0,0) returns []. It doesn't throw.
"abc".substring(0,0) returns "" it doesn't throw. fillRect(x, y, 0, 0)
doesn't throw. etc...
It just makes life a lot easier
On Tue, Nov 20, 2012 at 3:33 AM, Elliott Sprehn <esprehn at chromium.org>wrote:
>
> On Mon, Nov 19, 2012 at 12:26 AM, Gregg Tavares (社用) <gman at google.com>wrote:
>
>> Sorry if this is clear in the specs but can you explain how sizing the
>> canvas works?
>>
>>
>> // main.html
>> <canvas></canvas>
>> <script>
>> var canvas = document.getElementsByTagName('canvas')[0];
>> var worker = new Worker('clock.js');
>> var proxy = canvas.transferControlToProxy());
>> worker.postMessage(proxy, [proxy]);
>>
>> setTimeout(function() {
>> canvas.width = 200; // does this work? What happens?
>>
>
> You resize the output surface that the image coming from the worker will
> be drawn into. This is different than changing the buffer used for drawing.
>
> }, 4000);
>> </script>
>>
>> // clock.js worker
>> onmessage = function (event) {
>> var context = new CanvasRenderingContext2d();
>> event.data.setContext(context);
>> setInterval(function () {
>> context.width = 400; // Can I do this? What happens when I do?
>>
>
> You resize the buffer that's inside of the worker.
>
> - E
>
More information about the whatwg
mailing list