Computes and returns an affine transformation that makes toMakeVisible
visible and roughly centered on the screen.
the angle of the canvas in radians. This is the angle by which the canvas is rotated relative to the screen.
Returns an angle in the range (the same range as Vec3.angle).
Returns a Command that transforms the view such that toMakeVisible
is visible, and perhaps
centered in the viewport.
If the content is already roughly centered in the screen and at a reasonable zoom level, the resultant command does nothing.
Static
getReturns the size of a grid cell (in canvas units) as used by snapToGrid.
Static
roundRounds the given point
to a multiple of 10 such that it is within tolerance
of
its original location. This is useful for preparing data for base-10 conversion.
Static
roundStatic
transforma command that transforms the canvas by transform
.
For example, Viewport.transformBy(moveRight).apply(editor)
would move the canvas to the right
(and thus the viewport to the left):
import { Editor, Viewport, Mat33, Vec2 } from 'js-draw'; const editor = new Editor(document.body); const moveRight = Mat33.translation(Vec2.unitX.times(500)); // Move the **canvas** right by 500 units: Viewport.transformBy(moveRight).apply(editor);
Get the screen's visible region transformed into canvas space.