dytools-capture-engine 1.3.2 → 1.3.3

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.cjs CHANGED
@@ -1347,7 +1347,13 @@ var CaptureEngine = class {
1347
1347
  z.Required ?? false,
1348
1348
  z.DataType ?? null,
1349
1349
  z.ExcludeFromOutput ?? false,
1350
- z.DefaultValueIfEmpty ?? null
1350
+ z.DefaultValueIfEmpty ?? null,
1351
+ {
1352
+ zoneColor: this.options.anchorZoneColor,
1353
+ ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1354
+ anchorPointColor: this.options.anchorZoneAnchorPointColor,
1355
+ zoneAdditionalChildrenColor: this.options.anchorZoneAdditionalChildrenColor
1356
+ }
1351
1357
  );
1352
1358
  if (z.AnchorLocation) anchor.anchorLocation = z.AnchorLocation;
1353
1359
  if (z.GroupChildrenInSubRecord !== void 0) anchor.groupChildren = z.GroupChildrenInSubRecord;
@@ -1378,7 +1384,11 @@ var CaptureEngine = class {
1378
1384
  z.Required ?? false,
1379
1385
  z.DataType ?? null,
1380
1386
  z.ExcludeFromOutput ?? false,
1381
- z.DefaultValueIfEmpty ?? null
1387
+ z.DefaultValueIfEmpty ?? null,
1388
+ {
1389
+ zoneColor: this.options.anchorChildZoneColor,
1390
+ ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1391
+ }
1382
1392
  );
1383
1393
  }
1384
1394
  return new SimpleZone(
@@ -1391,7 +1401,11 @@ var CaptureEngine = class {
1391
1401
  z.Required ?? false,
1392
1402
  z.DataType ?? null,
1393
1403
  z.ExcludeFromOutput ?? false,
1394
- z.DefaultValueIfEmpty ?? null
1404
+ z.DefaultValueIfEmpty ?? null,
1405
+ {
1406
+ zoneColor: this.options.simpleZoneColor,
1407
+ ocrMatchColor: this.options.simpleZoneOcrMatchColor
1408
+ }
1395
1409
  );
1396
1410
  }
1397
1411
  get name() {
@@ -1662,12 +1676,18 @@ var CaptureEngine = class {
1662
1676
  get height() {
1663
1677
  return this.engine.height;
1664
1678
  }
1665
- async setBackgroundImage(imageOrUrl) {
1679
+ async setBackgroundImage(imageOrUrl, adjustZoom = true) {
1666
1680
  this.hideOcr();
1667
1681
  let preWidth = this.width;
1668
1682
  let preHeight = this.height;
1669
1683
  await this.engine.setBackgroundImage(imageOrUrl);
1670
1684
  if (preWidth !== this.width || preHeight !== this.height) {
1685
+ if (adjustZoom) {
1686
+ let widthChange = this.width / preWidth;
1687
+ let heightChange = this.height / preHeight;
1688
+ let change = Math.max(widthChange, heightChange);
1689
+ this.setZoom(this.zoom / change, new import_dytools_geometry.Point(this.width / 2, this.height / 2));
1690
+ }
1671
1691
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1672
1692
  }
1673
1693
  }
package/dist/index.d.cts CHANGED
@@ -506,7 +506,7 @@ declare class CaptureEngine {
506
506
  setPan(x: number, y: number): void;
507
507
  get width(): number;
508
508
  get height(): number;
509
- setBackgroundImage(imageOrUrl: string | File | Blob): Promise<void>;
509
+ setBackgroundImage(imageOrUrl: string | File | Blob, adjustZoom?: boolean): Promise<void>;
510
510
  switchMode(name: string): void;
511
511
  get mode(): string;
512
512
  setZoneExamples(zoneExamples: ZoneExample[] | null, setMissingExamplesToNull?: boolean): void;
package/dist/index.d.ts CHANGED
@@ -506,7 +506,7 @@ declare class CaptureEngine {
506
506
  setPan(x: number, y: number): void;
507
507
  get width(): number;
508
508
  get height(): number;
509
- setBackgroundImage(imageOrUrl: string | File | Blob): Promise<void>;
509
+ setBackgroundImage(imageOrUrl: string | File | Blob, adjustZoom?: boolean): Promise<void>;
510
510
  switchMode(name: string): void;
511
511
  get mode(): string;
512
512
  setZoneExamples(zoneExamples: ZoneExample[] | null, setMissingExamplesToNull?: boolean): void;
package/dist/index.js CHANGED
@@ -1331,7 +1331,13 @@ var CaptureEngine = class {
1331
1331
  z.Required ?? false,
1332
1332
  z.DataType ?? null,
1333
1333
  z.ExcludeFromOutput ?? false,
1334
- z.DefaultValueIfEmpty ?? null
1334
+ z.DefaultValueIfEmpty ?? null,
1335
+ {
1336
+ zoneColor: this.options.anchorZoneColor,
1337
+ ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1338
+ anchorPointColor: this.options.anchorZoneAnchorPointColor,
1339
+ zoneAdditionalChildrenColor: this.options.anchorZoneAdditionalChildrenColor
1340
+ }
1335
1341
  );
1336
1342
  if (z.AnchorLocation) anchor.anchorLocation = z.AnchorLocation;
1337
1343
  if (z.GroupChildrenInSubRecord !== void 0) anchor.groupChildren = z.GroupChildrenInSubRecord;
@@ -1362,7 +1368,11 @@ var CaptureEngine = class {
1362
1368
  z.Required ?? false,
1363
1369
  z.DataType ?? null,
1364
1370
  z.ExcludeFromOutput ?? false,
1365
- z.DefaultValueIfEmpty ?? null
1371
+ z.DefaultValueIfEmpty ?? null,
1372
+ {
1373
+ zoneColor: this.options.anchorChildZoneColor,
1374
+ ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1375
+ }
1366
1376
  );
1367
1377
  }
1368
1378
  return new SimpleZone(
@@ -1375,7 +1385,11 @@ var CaptureEngine = class {
1375
1385
  z.Required ?? false,
1376
1386
  z.DataType ?? null,
1377
1387
  z.ExcludeFromOutput ?? false,
1378
- z.DefaultValueIfEmpty ?? null
1388
+ z.DefaultValueIfEmpty ?? null,
1389
+ {
1390
+ zoneColor: this.options.simpleZoneColor,
1391
+ ocrMatchColor: this.options.simpleZoneOcrMatchColor
1392
+ }
1379
1393
  );
1380
1394
  }
1381
1395
  get name() {
@@ -1646,12 +1660,18 @@ var CaptureEngine = class {
1646
1660
  get height() {
1647
1661
  return this.engine.height;
1648
1662
  }
1649
- async setBackgroundImage(imageOrUrl) {
1663
+ async setBackgroundImage(imageOrUrl, adjustZoom = true) {
1650
1664
  this.hideOcr();
1651
1665
  let preWidth = this.width;
1652
1666
  let preHeight = this.height;
1653
1667
  await this.engine.setBackgroundImage(imageOrUrl);
1654
1668
  if (preWidth !== this.width || preHeight !== this.height) {
1669
+ if (adjustZoom) {
1670
+ let widthChange = this.width / preWidth;
1671
+ let heightChange = this.height / preHeight;
1672
+ let change = Math.max(widthChange, heightChange);
1673
+ this.setZoom(this.zoom / change, new Point(this.width / 2, this.height / 2));
1674
+ }
1655
1675
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1656
1676
  }
1657
1677
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dytools-capture-engine",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "An editor allowing the creation of templates for ocr capture.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",