pt
pt copied to clipboard
Clearer documentation and API for initializing CanvasSpace
I find the documentation for CanvasSpace to be unclear about how to initialize it and call its display() method. The CanvasSpace's id attribute is briefly explained as: "an id property which refers to the "id" attribute of the canvas element in DOM. If no canvas element with this id is found, a new canvas element will be created." While the display method's parent_id attribute is described as: "the DOM element into which the canvas element should be appended".
So right now to select/obtain the canvas element you want to use for pt, you need to write something like CanvasSpace('canvasId').display('#canvasContainer'). I found it very easy to get confused and get it wrong, so I'm just suggesting to add one or two example usages there. And maybe highlight the fact that by default, with no parameters specified, it will simply append a new canvas element to a container with id "pt".
Pt 0.2 has now a new constructor for CanvasSpace and SVGSpace to make it clearer. See if this works better for you. Thanks! http://williamngan.github.io/pt/docs/guide/migration.html http://williamngan.github.io/pt/docs/#func-CanvasSpace-CanvasSpace