fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
19 lines (18 loc) • 738 B
JavaScript
//#region src/util/internals/applyCanvasTransform.ts
/**
* Set the transform of the passed context to the same of a specific Canvas or StaticCanvas.
* setTransform is used since this utility will RESET the ctx transform to the basic value
* of retina scaling and viewport transform
* It is not meant to be added to other transforms, it is used internally to preapre canvases to draw
* @param ctx
* @param canvas
*/
const applyCanvasTransform = (ctx, canvas) => {
const scale = canvas.getRetinaScaling();
ctx.setTransform(scale, 0, 0, scale, 0, 0);
const v = canvas.viewportTransform;
ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);
};
//#endregion
export { applyCanvasTransform };
//# sourceMappingURL=applyCanvasTransform.mjs.map