W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2012

Re: [whatwg] Canvas in Workers

From: Elliott Sprehn <esprehn@chromium.org>
Date: Mon, 19 Nov 2012 13:33:40 -0500
Message-ID: <CAO9Q3iLfrHp8mS7Bg9aLzwT81f87NLad5Z=W5JE5FWs4cEbqjQ@mail.gmail.com>
To: Gregg Tavares (社用) <gman@google.com>
Cc: Rick Waldron <waldron.rick@gmail.com>, Ian Hickson <ian@hixie.ch>, WHAT Working Group <whatwg@whatwg.org>
On Mon, Nov 19, 2012 at 12:26 AM, Gregg Tavares (社用) <gman@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
Received on Monday, 19 November 2012 20:45:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:11 GMT