Accessing Viewport State
The read-only viewport transform state can be accessed via the viewport
property of the canvas
.
const element = document.getElementById('canvas'); const canvas = new CanvasBuilder(element) .build(); console.log(canvas.viewport);
The viewport
object provides two methods:
get the state of the viewport matrix
const viewportMatrix = canvas.viewport.getViewportMatrix();
get the state of the content matrix
const contentMatrix = canvas.viewport.getContentMatrix();