[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] using the same context with multiple canvases






On Sat, Nov 17, 2012 at 4:23 PM, Ian Hickson <ian@hixie.ch> wrote:
On Sat, 17 Nov 2012, Gregg Tavares (社ç~T¨) wrote:
>
> Why would I want to do this? Because making paths is time consuming.
> Assume my path requires 1000 lines. Why would I want to have to repeat
> that N times?

This is a solved problem with the last batch of API additions:

   var path = new Path();
   for (var i = 0; i < 1000; ++i) {
     path.moveTo(...);
     path.lineTo(...);
   }

   c1.setContext(ctx);
   ctx.stroke(path);
   c2.setContext(ctx);
   ctx.stroke(path);
   c3.setContext(ctx);
   ctx.stroke(path);


However, when do you ever just draw a single path to three bitmaps,
though?

Both Adobe Illustrator and Photoshop (which also supports vector layers)
allow multiple simultaneous views into a single document so you can have
a zoomed view and a full view at the same time.

It would be nice if trying to write similar functionality as a Web app wasn't
twice as slow because of the APi design

examples:
http://www.jumpingjackrabbit.com/blog-entry/web-designers-trick-101
http://www.photoshopessentials.com/photo-editing/dual-view/

 
In all the cases I've ever used canvas, there's been multiple
paths, changes to the line width, changes to the fill and strokes styles,
text, transforms, etc. Are you saying you'd want to iterate through the
canvases between each drawing operation just so you could reuse those
styles without having to set them on two different contexts or run the
same code for two canvases? That seems weird.


> This is especially important in WebGL where you're trying to draw a top,
> front, side and perspective view.

Sure. See my e-mail to the WHATWG list -- the spec is intentionally
written so that this can be done for WebGL.

Why be different? Surely if that ability is good for WebGL it's also good for Canvas2d.
See above.
 

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