M
MartinRinehart
I'm making a slider widget with a <canvas>.
First I draw the background. I'd like to save this drawing. Something
like:
slider.drawBackground();
slider.back = new ScreenArea( left, top, width, height );
Next, draw the pointer. When the user slides the slider, I'd like to
restore the saved background and then redraw the pointer. Any way of
doing this directly? Something like:
slider.back.restore();
slider.drawPointer();
I've been playing with indirection: using context.toDataURL() (after
drawing the background) but I haven't found a way to take that string
and use it to construct an Image object. What I want is:
slider.back = new Image( context.toDataURL() ); // in my dreams!
Or maybe:
slider.back = new Image( wid, hgt );
slider.back.src = context.toDataURL(); // still dreaming
First I draw the background. I'd like to save this drawing. Something
like:
slider.drawBackground();
slider.back = new ScreenArea( left, top, width, height );
Next, draw the pointer. When the user slides the slider, I'd like to
restore the saved background and then redraw the pointer. Any way of
doing this directly? Something like:
slider.back.restore();
slider.drawPointer();
I've been playing with indirection: using context.toDataURL() (after
drawing the background) but I haven't found a way to take that string
and use it to construct an Image object. What I want is:
slider.back = new Image( context.toDataURL() ); // in my dreams!
Or maybe:
slider.back = new Image( wid, hgt );
slider.back.src = context.toDataURL(); // still dreaming