Re: [whatwg] Canvas in Workers

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?
    }, 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?
       context.clearRect(0, 0, context.width, context.height);
       context.fillText(0, 100, new Date());
       context.commit();
     }, 1000);
   };





On Sat, Nov 17, 2012 at 10:23 AM, Rick Waldron <waldron.rick@gmail.com>wrote:

> On Fri, Nov 16, 2012 at 4:48 PM, Ian Hickson <ian@hixie.ch> wrote:
>
> > On Fri, 16 Nov 2012, Rick Waldron wrote:
> > > On Fri, Nov 16, 2012 at 4:11 PM, Ian Hickson <ian@hixie.ch> wrote:
> > > > On Fri, 16 Nov 2012, Rick Waldron wrote:
> > > > > On Fri, Nov 16, 2012 at 3:25 PM, Ian Hickson <ian@hixie.ch> wrote:
> > > > > >
> > > > > >     var proxy = canvas.transferControlToProxy());
> > > > >
> > > > > <bikeshed>
> > > > >
> > > > > Proxy with a capital P is an API in ES6 for creating Proxy objects.
> > > > > While I recognize that this is obviously just a conceptual sketch
> of
> > > > > your idea and that you're merely following the camel case
> tradition,
> > now
> > > > > is probably the best time to be informed of potential naming
> > conflicts.
> > > >
> > > > The word Proxy is used all over the place on the Web platform, I'm
> not
> > too
> > > > worried about that. Right now the object returned above is
> > "CanvasProxy",
> > > > which is the kind of proxy that it refers to. I'm certainly open to
> > > > another name, any suggestions?
> > >
> > > CanvasProxy is a fine disambiguation.
> >
> > Do you think we should rename the method above to say that too?
> >
> > "canvas.transferControlToCanvasProxy()" is a bit verbose. :-)
> >
> > I had shortened it to just "canvas.transferControlToProxy" on the
> >
>
> Is there any other thing that control can be transferred to?
> canvas.transferControl() would be sufficient...
>
> Rick
>
>
> > assumption that the fact that it was called on a canvas would
> disambiguate
> > that it was a canvas proxy, but I'm certainly open to other suggestions.
> >
> > --
> > Ian Hickson               U+1047E                )\._.,--....,'``.    fL
> > http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
> > Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
> >
>

Received on Monday, 19 November 2012 05:28:29 UTC