fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
1 lines • 1.11 kB
Source Map (JSON)
{"version":3,"file":"applyCanvasTransform.min.mjs","names":[],"sources":["../../../../src/util/internals/applyCanvasTransform.ts"],"sourcesContent":["import type { StaticCanvas } from '../../canvas/StaticCanvas';\n\n/**\n * Set the transform of the passed context to the same of a specific Canvas or StaticCanvas.\n * setTransform is used since this utility will RESET the ctx transform to the basic value\n * of retina scaling and viewport transform\n * It is not meant to be added to other transforms, it is used internally to preapre canvases to draw\n * @param ctx\n * @param canvas\n */\nexport const applyCanvasTransform = (\n ctx: CanvasRenderingContext2D,\n canvas: StaticCanvas,\n) => {\n const scale = canvas.getRetinaScaling();\n ctx.setTransform(scale, 0, 0, scale, 0, 0);\n const v = canvas.viewportTransform;\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n};\n"],"mappings":"AAUA,MAAa,GACX,EACA,IAAA,CAEA,IAAM,EAAQ,EAAO,kBAAA,CACrB,EAAI,aAAa,EAAO,EAAG,EAAG,EAAO,EAAG,EAAA,CACxC,IAAM,EAAI,EAAO,kBACjB,EAAI,UAAU,EAAE,GAAI,EAAE,GAAI,EAAE,GAAI,EAAE,GAAI,EAAE,GAAI,EAAE,GAAA,EAAA,OAAA,KAAA"}