@embedpdf/models 1.0.22 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -238,47 +238,26 @@ function boundingRect(rects) {
238
238
  }
239
239
  };
240
240
  }
241
- const makeMatrix = (rectangle, rotation, scaleFactor) => {
242
- const { width, height } = rectangle.size;
241
+ function buildUserToDeviceMatrix(rect, rotation, outW, outH) {
242
+ const L = rect.origin.x;
243
+ const B = rect.origin.y;
244
+ const W = rect.size.width;
245
+ const H = rect.size.height;
246
+ const sx0 = outW / W;
247
+ const sy0 = outH / H;
248
+ const sx90 = outW / H;
249
+ const sy90 = outH / W;
243
250
  switch (rotation) {
244
251
  case 0:
245
- return {
246
- a: scaleFactor,
247
- b: 0,
248
- c: 0,
249
- d: -scaleFactor,
250
- e: 0,
251
- f: height * scaleFactor
252
- };
253
- case 1:
254
- return {
255
- a: 0,
256
- b: scaleFactor,
257
- c: scaleFactor,
258
- d: 0,
259
- e: 0,
260
- f: 0
261
- };
262
- case 2:
263
- return {
264
- a: -scaleFactor,
265
- b: 0,
266
- c: 0,
267
- d: scaleFactor,
268
- e: width * scaleFactor,
269
- f: 0
270
- };
252
+ return { a: sx0, b: 0, c: 0, d: sy0, e: -sx0 * L, f: -sy0 * B };
271
253
  case 3:
272
- return {
273
- a: 0,
274
- b: -scaleFactor,
275
- c: -scaleFactor,
276
- d: 0,
277
- e: height * scaleFactor,
278
- f: width * scaleFactor
279
- };
254
+ return { a: 0, b: -sy90, c: sx90, d: 0, e: -sx90 * B, f: sy90 * (L + W) };
255
+ case 2:
256
+ return { a: -sx0, b: 0, c: 0, d: -sy0, e: sx0 * (L + W), f: sy0 * (B + H) };
257
+ case 1:
258
+ return { a: 0, b: sy90, c: -sx90, d: 0, e: sx90 * (B + H), f: -sy90 * L };
280
259
  }
281
- };
260
+ }
282
261
  class NoopLogger {
283
262
  /** {@inheritDoc Logger.debug} */
284
263
  debug() {
@@ -1819,6 +1798,7 @@ export {
1819
1798
  blendModeSelectOptions,
1820
1799
  blendModeToCss,
1821
1800
  boundingRect,
1801
+ buildUserToDeviceMatrix,
1822
1802
  calculateAngle,
1823
1803
  calculateDegree,
1824
1804
  combinePdfColorWithAlpha,
@@ -1837,7 +1817,6 @@ export {
1837
1817
  getTextAlignmentInfo,
1838
1818
  ignore,
1839
1819
  isUuidV4,
1840
- makeMatrix,
1841
1820
  makeStandardFont,
1842
1821
  namesToFlags,
1843
1822
  pdfAlphaColorToWebAlphaColor,