williamngan/pts

will pts provide an api to render in existing canvas provided by the user?

Ma-Y opened this issue · 2 comments

Ma-Y commented

user html (user will decide where to put it)(some times there's some state issue if it is put elsewhere)


<canvas id="user-canvas">
</canvas>

pts
var space = Pts.SpaceContextOnExistingCanvas(..getElementById(...)..)

Hi @Ma-Y - I'm not entirely sure what you mean. I'm guessing one of these two options:

  1. If you just want to use an existing canvas, you can pass the canvas id directly. ie, space = new CanvasSpace('#user-canvas'), or pass the element directly like space = new CanvasSpace( canvas_element )

  2. If you have the canvas context but don't want to create a CanvasSpace, you can access the drawing functions in CanvasForm by passing the context to instantiate it. ie, form = new CanvasForm( ctx )

Ma-Y commented

Thanks that's exactly what i need.