[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 8:33 PM, Ian Hickson <ian@hixie.ch> wrote:
On Sat, 17 Nov 2012, Rik Cabanier wrote:
> I think that the non-standard -webkit-canvas can do. See the example here:
> http://jsfiddle.net/hg3sq/4/
> The JS draws in the context once, but the same context is used multiple
> times and at different aspect ratios.
> Using this feature, you can make an Illustrator/Photoshop-style navigator,
> or provide multiple views into the same context.

You could do that with regular canvas too, just draw the one canvas and
paint it to each <canvas> you want to use it on. But the one you draw on
(whether using -webkit-canvas in CSS or using <canvas>) has to be the
biggest one, because in either case you're actually drawing a bitmap and
not a vector.

True, however, the backgrounds are not painted. They share the same context so there's no overhead off copying/pasting of bitmap data.
It's as if you say:
var ctx = Canvas1.getContext();

and all the drawing shows up in all three canvases.