fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
1 lines • 1.22 kB
Source Map (JSON)
{"version":3,"file":"applyCanvasTransform.min.mjs","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"],"names":["applyCanvasTransform","ctx","canvas","scale","getRetinaScaling","setTransform","v","viewportTransform","transform"],"mappings":"MAUaA,EAAuBA,CAClCC,EACAC,KAEA,MAAMC,EAAQD,EAAOE,mBACrBH,EAAII,aAAaF,EAAO,EAAG,EAAGA,EAAO,EAAG,GACxC,MAAMG,EAAIJ,EAAOK,kBACjBN,EAAIO,UAAUF,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAG"}