@leapfrog/interactive-canvas 1.0.8 → 1.2.0
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.d.ts +1 -0
- package/dist/interactive-canvas.es.js +95 -50
- package/dist/interactive-canvas.js +95 -49
- package/dist/mutator/mutable-position.interface.d.ts +30 -0
- package/dist/object/abstract-canvas-object.d.ts +35 -0
- package/dist/object/impl/horizontal-rule.d.ts +0 -5
- package/dist/object/impl/image.d.ts +0 -5
- package/dist/object/impl/rectangle.d.ts +0 -5
- package/dist/object/impl/text.d.ts +0 -5
- package/dist/object/impl/vertical-rule.d.ts +0 -5
- package/dist/types/canvas-dimension-restrictions.interface.d.ts +1 -0
- package/dist/types/position.interface.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,30 @@ import { oc } from 'ts-optchain';
|
|
|
4
4
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
5
5
|
import { fabric } from 'fabric';
|
|
6
6
|
|
|
7
|
+
var PIXELS_PER_MM = 3.937;
|
|
8
|
+
var MillimeterDimensions = /** @class */ (function () {
|
|
9
|
+
function MillimeterDimensions(width, height) {
|
|
10
|
+
this.widthUnit = "mm";
|
|
11
|
+
this.heightUnit = "mm";
|
|
12
|
+
this.width = width;
|
|
13
|
+
this.widthMm = Math.max(0, width);
|
|
14
|
+
this.widthPx = round(this.widthMm * PIXELS_PER_MM);
|
|
15
|
+
this.height = height;
|
|
16
|
+
this.heightMm = Math.max(0, height);
|
|
17
|
+
this.heightPx = round(this.heightMm * PIXELS_PER_MM);
|
|
18
|
+
}
|
|
19
|
+
MillimeterDimensions.prototype.withSize = function (width, height) {
|
|
20
|
+
return new MillimeterDimensions(width, height);
|
|
21
|
+
};
|
|
22
|
+
MillimeterDimensions.prototype.widthPxToMm = function (px) {
|
|
23
|
+
return px / PIXELS_PER_MM;
|
|
24
|
+
};
|
|
25
|
+
MillimeterDimensions.prototype.heightPxToMm = function (px) {
|
|
26
|
+
return px / PIXELS_PER_MM;
|
|
27
|
+
};
|
|
28
|
+
return MillimeterDimensions;
|
|
29
|
+
}());
|
|
30
|
+
|
|
7
31
|
var PixelCanvasDimensions = /** @class */ (function () {
|
|
8
32
|
function PixelCanvasDimensions(width, height) {
|
|
9
33
|
this.widthUnit = "px";
|
|
@@ -27,7 +51,7 @@ var PixelCanvasDimensions = /** @class */ (function () {
|
|
|
27
51
|
|
|
28
52
|
var COLUMN_WIDTH_MM = 41;
|
|
29
53
|
var GUTTER_WIDTH_MM = 3;
|
|
30
|
-
var PIXELS_PER_MM = 3.937;
|
|
54
|
+
var PIXELS_PER_MM$1 = 3.937;
|
|
31
55
|
var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
32
56
|
function Print6ColCanvasDimensions(width, height) {
|
|
33
57
|
this.widthUnit = "column(s)";
|
|
@@ -37,26 +61,26 @@ var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
|
37
61
|
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
|
|
38
62
|
this.columnsTotalMm = width * COLUMN_WIDTH_MM;
|
|
39
63
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
40
|
-
this.widthPx = round(this.widthMm * PIXELS_PER_MM);
|
|
64
|
+
this.widthPx = round(this.widthMm * PIXELS_PER_MM$1);
|
|
41
65
|
this.height = height;
|
|
42
66
|
this.heightMm = Math.max(0, height * 10);
|
|
43
|
-
this.heightPx = round(this.heightMm * PIXELS_PER_MM);
|
|
67
|
+
this.heightPx = round(this.heightMm * PIXELS_PER_MM$1);
|
|
44
68
|
}
|
|
45
69
|
Print6ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
46
70
|
return new Print6ColCanvasDimensions(width, height);
|
|
47
71
|
};
|
|
48
72
|
Print6ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
49
|
-
return px / PIXELS_PER_MM;
|
|
73
|
+
return px / PIXELS_PER_MM$1;
|
|
50
74
|
};
|
|
51
75
|
Print6ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
52
|
-
return px / PIXELS_PER_MM;
|
|
76
|
+
return px / PIXELS_PER_MM$1;
|
|
53
77
|
};
|
|
54
78
|
return Print6ColCanvasDimensions;
|
|
55
79
|
}());
|
|
56
80
|
|
|
57
81
|
var COLUMN_WIDTH_MM$1 = 30.8772;
|
|
58
82
|
var GUTTER_WIDTH_MM$1 = 2.1053;
|
|
59
|
-
var PIXELS_PER_MM$
|
|
83
|
+
var PIXELS_PER_MM$2 = 3.937;
|
|
60
84
|
var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
61
85
|
function Print8ColCanvasDimensions(width, height) {
|
|
62
86
|
this.widthUnit = "column(s)";
|
|
@@ -66,19 +90,19 @@ var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
|
66
90
|
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM$1;
|
|
67
91
|
this.columnsTotalMm = width * COLUMN_WIDTH_MM$1;
|
|
68
92
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
69
|
-
this.widthPx = round(this.widthMm * PIXELS_PER_MM$
|
|
93
|
+
this.widthPx = round(this.widthMm * PIXELS_PER_MM$2);
|
|
70
94
|
this.height = height;
|
|
71
95
|
this.heightMm = Math.max(0, height * 10);
|
|
72
|
-
this.heightPx = round(this.heightMm * PIXELS_PER_MM$
|
|
96
|
+
this.heightPx = round(this.heightMm * PIXELS_PER_MM$2);
|
|
73
97
|
}
|
|
74
98
|
Print8ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
75
99
|
return new Print8ColCanvasDimensions(width, height);
|
|
76
100
|
};
|
|
77
101
|
Print8ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
78
|
-
return px / PIXELS_PER_MM$
|
|
102
|
+
return px / PIXELS_PER_MM$2;
|
|
79
103
|
};
|
|
80
104
|
Print8ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
81
|
-
return px / PIXELS_PER_MM$
|
|
105
|
+
return px / PIXELS_PER_MM$2;
|
|
82
106
|
};
|
|
83
107
|
return Print8ColCanvasDimensions;
|
|
84
108
|
}());
|
|
@@ -296,6 +320,8 @@ var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
|
296
320
|
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
297
321
|
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
298
322
|
return;
|
|
323
|
+
if (oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
324
|
+
return;
|
|
299
325
|
var currentDimensions = canvas.getDimensions();
|
|
300
326
|
var baseDimensions = canvas.getBaseDimensions();
|
|
301
327
|
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(ObjectType.TEXT))
|
|
@@ -457,6 +483,8 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
457
483
|
});
|
|
458
484
|
};
|
|
459
485
|
StackObjectsLayoutFunction.prototype.adjustCanvasSize = function (canvas, requiredHeight) {
|
|
486
|
+
if (oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
487
|
+
return;
|
|
460
488
|
var dimensions = canvas.getDimensions();
|
|
461
489
|
var targetDimensions = canvas.getDimensions().withSize(dimensions.width, MIN_MAGNITUDE);
|
|
462
490
|
while (targetDimensions.heightPx < requiredHeight) {
|
|
@@ -816,6 +844,55 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
816
844
|
this.canvas.notifyObjectListChanged();
|
|
817
845
|
this.updateFabricObjectBehavior();
|
|
818
846
|
};
|
|
847
|
+
/**
|
|
848
|
+
* @override
|
|
849
|
+
* @inheritDoc
|
|
850
|
+
*/
|
|
851
|
+
AbstractCanvasObject.prototype.setLeft = function (left) {
|
|
852
|
+
this.setPosition({ left: left });
|
|
853
|
+
};
|
|
854
|
+
/**
|
|
855
|
+
* @override
|
|
856
|
+
* @inheritDoc
|
|
857
|
+
*/
|
|
858
|
+
AbstractCanvasObject.prototype.setTop = function (top) {
|
|
859
|
+
this.setPosition({ top: top });
|
|
860
|
+
};
|
|
861
|
+
/**
|
|
862
|
+
* @override
|
|
863
|
+
* @inheritDoc
|
|
864
|
+
*/
|
|
865
|
+
AbstractCanvasObject.prototype.setHeight = function (height) {
|
|
866
|
+
this.setPosition({ height: height });
|
|
867
|
+
};
|
|
868
|
+
/**
|
|
869
|
+
* @override
|
|
870
|
+
* @inheritDoc
|
|
871
|
+
*/
|
|
872
|
+
AbstractCanvasObject.prototype.setWidth = function (width) {
|
|
873
|
+
this.setPosition({ width: width });
|
|
874
|
+
};
|
|
875
|
+
/**
|
|
876
|
+
* @override
|
|
877
|
+
* @inheritDoc
|
|
878
|
+
*/
|
|
879
|
+
AbstractCanvasObject.prototype.setAngle = function (angle) {
|
|
880
|
+
this.setPosition({ angle: angle });
|
|
881
|
+
};
|
|
882
|
+
/**
|
|
883
|
+
* @override
|
|
884
|
+
* @inheritDoc
|
|
885
|
+
*/
|
|
886
|
+
AbstractCanvasObject.prototype.setScaleX = function (scale) {
|
|
887
|
+
this.setPosition({ scaleX: scale });
|
|
888
|
+
};
|
|
889
|
+
/**
|
|
890
|
+
* @override
|
|
891
|
+
* @inheritDoc
|
|
892
|
+
*/
|
|
893
|
+
AbstractCanvasObject.prototype.setScaleY = function (scale) {
|
|
894
|
+
this.setPosition({ scaleY: scale });
|
|
895
|
+
};
|
|
819
896
|
/**
|
|
820
897
|
* Get the underlying fabric object.
|
|
821
898
|
* (Internal use only, do not expose this outside the canvas module).
|
|
@@ -833,6 +910,13 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
833
910
|
this.fabricObject.set({ width: position.width / scale.x });
|
|
834
911
|
if (position.height != undefined)
|
|
835
912
|
this.fabricObject.set({ height: position.height / scale.y });
|
|
913
|
+
if (position.angle != undefined)
|
|
914
|
+
this.fabricObject.set({ angle: position.angle });
|
|
915
|
+
if (position.scaleX != undefined)
|
|
916
|
+
this.fabricObject.set({ scaleX: position.scaleX });
|
|
917
|
+
if (position.scaleY != undefined)
|
|
918
|
+
this.fabricObject.set({ scaleY: position.scaleY });
|
|
919
|
+
this.canvas.notifyObjectListChanged();
|
|
836
920
|
};
|
|
837
921
|
AbstractCanvasObject.prototype.setCoords = function () {
|
|
838
922
|
this.fabricObject.setCoords();
|
|
@@ -1254,14 +1338,6 @@ var HorizontalRule = /** @class */ (function (_super) {
|
|
|
1254
1338
|
HorizontalRule.prototype.centerVertically = function () {
|
|
1255
1339
|
_super.prototype.centerVerticallyInternal.call(this);
|
|
1256
1340
|
};
|
|
1257
|
-
/**
|
|
1258
|
-
* @override
|
|
1259
|
-
* @inheritDoc
|
|
1260
|
-
*/
|
|
1261
|
-
HorizontalRule.prototype.setHeight = function (height) {
|
|
1262
|
-
this.setPosition({ height: height });
|
|
1263
|
-
this.canvas.notifyObjectListChanged();
|
|
1264
|
-
};
|
|
1265
1341
|
/**
|
|
1266
1342
|
* @override
|
|
1267
1343
|
* @inheritDoc
|
|
@@ -1366,14 +1442,6 @@ var Image = /** @class */ (function (_super) {
|
|
|
1366
1442
|
Image.prototype.centerVertically = function () {
|
|
1367
1443
|
_super.prototype.centerVerticallyInternal.call(this);
|
|
1368
1444
|
};
|
|
1369
|
-
/**
|
|
1370
|
-
* @override
|
|
1371
|
-
* @inheritDoc
|
|
1372
|
-
*/
|
|
1373
|
-
Image.prototype.setHeight = function (height) {
|
|
1374
|
-
this.setPosition({ height: height });
|
|
1375
|
-
this.canvas.notifyObjectListChanged();
|
|
1376
|
-
};
|
|
1377
1445
|
/**
|
|
1378
1446
|
* @override
|
|
1379
1447
|
* @inheritDoc
|
|
@@ -1508,14 +1576,6 @@ var Rectangle = /** @class */ (function (_super) {
|
|
|
1508
1576
|
Rectangle.prototype.centerVertically = function () {
|
|
1509
1577
|
_super.prototype.centerVerticallyInternal.call(this);
|
|
1510
1578
|
};
|
|
1511
|
-
/**
|
|
1512
|
-
* @override
|
|
1513
|
-
* @inheritDoc
|
|
1514
|
-
*/
|
|
1515
|
-
Rectangle.prototype.setHeight = function (height) {
|
|
1516
|
-
this.setPosition({ height: height });
|
|
1517
|
-
this.canvas.notifyObjectListChanged();
|
|
1518
|
-
};
|
|
1519
1579
|
/**
|
|
1520
1580
|
* @override
|
|
1521
1581
|
* @inheritDoc
|
|
@@ -1809,13 +1869,6 @@ var Text = /** @class */ (function (_super) {
|
|
|
1809
1869
|
Text.prototype.centerVertically = function () {
|
|
1810
1870
|
_super.prototype.centerVerticallyInternal.call(this);
|
|
1811
1871
|
};
|
|
1812
|
-
/**
|
|
1813
|
-
* @override
|
|
1814
|
-
* @inheritDoc
|
|
1815
|
-
*/
|
|
1816
|
-
Text.prototype.setHeight = function (height) {
|
|
1817
|
-
//no-op
|
|
1818
|
-
};
|
|
1819
1872
|
/**
|
|
1820
1873
|
* @override
|
|
1821
1874
|
* @inheritDoc
|
|
@@ -2207,14 +2260,6 @@ var VerticalRule = /** @class */ (function (_super) {
|
|
|
2207
2260
|
VerticalRule.prototype.centerVertically = function () {
|
|
2208
2261
|
_super.prototype.centerVerticallyInternal.call(this);
|
|
2209
2262
|
};
|
|
2210
|
-
/**
|
|
2211
|
-
* @override
|
|
2212
|
-
* @inheritDoc
|
|
2213
|
-
*/
|
|
2214
|
-
VerticalRule.prototype.setHeight = function (height) {
|
|
2215
|
-
this.setPosition({ height: height });
|
|
2216
|
-
this.canvas.notifyObjectListChanged();
|
|
2217
|
-
};
|
|
2218
2263
|
/**
|
|
2219
2264
|
* @override
|
|
2220
2265
|
* @inheritDoc
|
|
@@ -3222,4 +3267,4 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3222
3267
|
return InteractiveCanvas;
|
|
3223
3268
|
}(AbstractInteractiveCanvas));
|
|
3224
3269
|
|
|
3225
|
-
export { AbstractCanvasObject, AbstractInteractiveCanvas, AbstractLayoutManager, AdvancedLayoutManager, Border, CanvasObjectData, Cutoff, DefaultCanvasProfile, Font, FontLibrary, HeadlessInteractiveCanvas, HorizontalRule, Image, ImageType, InteractiveCanvas, LayoutManager, ObjectType, PixelCanvasDimensions, Print6ColCanvasDimensions, Print8ColCanvasDimensions, Rectangle, SelectionData, StandardLayoutManager, Text, UNKNOWN_FONT, UnknownFont, VerticalRule, isMutableBackgroundColor, isMutableColor, isMutableImage, isMutablePosition, isMutableText, isMutableTextStyle };
|
|
3270
|
+
export { AbstractCanvasObject, AbstractInteractiveCanvas, AbstractLayoutManager, AdvancedLayoutManager, Border, CanvasObjectData, Cutoff, DefaultCanvasProfile, Font, FontLibrary, HeadlessInteractiveCanvas, HorizontalRule, Image, ImageType, InteractiveCanvas, LayoutManager, MillimeterDimensions, ObjectType, PixelCanvasDimensions, Print6ColCanvasDimensions, Print8ColCanvasDimensions, Rectangle, SelectionData, StandardLayoutManager, Text, UNKNOWN_FONT, UnknownFont, VerticalRule, isMutableBackgroundColor, isMutableColor, isMutableImage, isMutablePosition, isMutableText, isMutableTextStyle };
|
|
@@ -7,6 +7,30 @@ var tsOptchain = require('ts-optchain');
|
|
|
7
7
|
var rxjs = require('rxjs');
|
|
8
8
|
var fabric = require('fabric');
|
|
9
9
|
|
|
10
|
+
var PIXELS_PER_MM = 3.937;
|
|
11
|
+
var MillimeterDimensions = /** @class */ (function () {
|
|
12
|
+
function MillimeterDimensions(width, height) {
|
|
13
|
+
this.widthUnit = "mm";
|
|
14
|
+
this.heightUnit = "mm";
|
|
15
|
+
this.width = width;
|
|
16
|
+
this.widthMm = Math.max(0, width);
|
|
17
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
|
|
18
|
+
this.height = height;
|
|
19
|
+
this.heightMm = Math.max(0, height);
|
|
20
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
|
|
21
|
+
}
|
|
22
|
+
MillimeterDimensions.prototype.withSize = function (width, height) {
|
|
23
|
+
return new MillimeterDimensions(width, height);
|
|
24
|
+
};
|
|
25
|
+
MillimeterDimensions.prototype.widthPxToMm = function (px) {
|
|
26
|
+
return px / PIXELS_PER_MM;
|
|
27
|
+
};
|
|
28
|
+
MillimeterDimensions.prototype.heightPxToMm = function (px) {
|
|
29
|
+
return px / PIXELS_PER_MM;
|
|
30
|
+
};
|
|
31
|
+
return MillimeterDimensions;
|
|
32
|
+
}());
|
|
33
|
+
|
|
10
34
|
var PixelCanvasDimensions = /** @class */ (function () {
|
|
11
35
|
function PixelCanvasDimensions(width, height) {
|
|
12
36
|
this.widthUnit = "px";
|
|
@@ -30,7 +54,7 @@ var PixelCanvasDimensions = /** @class */ (function () {
|
|
|
30
54
|
|
|
31
55
|
var COLUMN_WIDTH_MM = 41;
|
|
32
56
|
var GUTTER_WIDTH_MM = 3;
|
|
33
|
-
var PIXELS_PER_MM = 3.937;
|
|
57
|
+
var PIXELS_PER_MM$1 = 3.937;
|
|
34
58
|
var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
35
59
|
function Print6ColCanvasDimensions(width, height) {
|
|
36
60
|
this.widthUnit = "column(s)";
|
|
@@ -40,26 +64,26 @@ var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
|
40
64
|
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
|
|
41
65
|
this.columnsTotalMm = width * COLUMN_WIDTH_MM;
|
|
42
66
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
43
|
-
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
|
|
67
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$1);
|
|
44
68
|
this.height = height;
|
|
45
69
|
this.heightMm = Math.max(0, height * 10);
|
|
46
|
-
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
|
|
70
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$1);
|
|
47
71
|
}
|
|
48
72
|
Print6ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
49
73
|
return new Print6ColCanvasDimensions(width, height);
|
|
50
74
|
};
|
|
51
75
|
Print6ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
52
|
-
return px / PIXELS_PER_MM;
|
|
76
|
+
return px / PIXELS_PER_MM$1;
|
|
53
77
|
};
|
|
54
78
|
Print6ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
55
|
-
return px / PIXELS_PER_MM;
|
|
79
|
+
return px / PIXELS_PER_MM$1;
|
|
56
80
|
};
|
|
57
81
|
return Print6ColCanvasDimensions;
|
|
58
82
|
}());
|
|
59
83
|
|
|
60
84
|
var COLUMN_WIDTH_MM$1 = 30.8772;
|
|
61
85
|
var GUTTER_WIDTH_MM$1 = 2.1053;
|
|
62
|
-
var PIXELS_PER_MM$
|
|
86
|
+
var PIXELS_PER_MM$2 = 3.937;
|
|
63
87
|
var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
64
88
|
function Print8ColCanvasDimensions(width, height) {
|
|
65
89
|
this.widthUnit = "column(s)";
|
|
@@ -69,19 +93,19 @@ var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
|
69
93
|
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM$1;
|
|
70
94
|
this.columnsTotalMm = width * COLUMN_WIDTH_MM$1;
|
|
71
95
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
72
|
-
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$
|
|
96
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$2);
|
|
73
97
|
this.height = height;
|
|
74
98
|
this.heightMm = Math.max(0, height * 10);
|
|
75
|
-
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$
|
|
99
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$2);
|
|
76
100
|
}
|
|
77
101
|
Print8ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
78
102
|
return new Print8ColCanvasDimensions(width, height);
|
|
79
103
|
};
|
|
80
104
|
Print8ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
81
|
-
return px / PIXELS_PER_MM$
|
|
105
|
+
return px / PIXELS_PER_MM$2;
|
|
82
106
|
};
|
|
83
107
|
Print8ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
84
|
-
return px / PIXELS_PER_MM$
|
|
108
|
+
return px / PIXELS_PER_MM$2;
|
|
85
109
|
};
|
|
86
110
|
return Print8ColCanvasDimensions;
|
|
87
111
|
}());
|
|
@@ -299,6 +323,8 @@ var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
|
299
323
|
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
300
324
|
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
301
325
|
return;
|
|
326
|
+
if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
327
|
+
return;
|
|
302
328
|
var currentDimensions = canvas.getDimensions();
|
|
303
329
|
var baseDimensions = canvas.getBaseDimensions();
|
|
304
330
|
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
|
|
@@ -459,6 +485,8 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
459
485
|
});
|
|
460
486
|
};
|
|
461
487
|
StackObjectsLayoutFunction.prototype.adjustCanvasSize = function (canvas, requiredHeight) {
|
|
488
|
+
if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
489
|
+
return;
|
|
462
490
|
var dimensions = canvas.getDimensions();
|
|
463
491
|
var targetDimensions = canvas.getDimensions().withSize(dimensions.width, MIN_MAGNITUDE);
|
|
464
492
|
while (targetDimensions.heightPx < requiredHeight) {
|
|
@@ -818,6 +846,55 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
818
846
|
this.canvas.notifyObjectListChanged();
|
|
819
847
|
this.updateFabricObjectBehavior();
|
|
820
848
|
};
|
|
849
|
+
/**
|
|
850
|
+
* @override
|
|
851
|
+
* @inheritDoc
|
|
852
|
+
*/
|
|
853
|
+
AbstractCanvasObject.prototype.setLeft = function (left) {
|
|
854
|
+
this.setPosition({ left: left });
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* @override
|
|
858
|
+
* @inheritDoc
|
|
859
|
+
*/
|
|
860
|
+
AbstractCanvasObject.prototype.setTop = function (top) {
|
|
861
|
+
this.setPosition({ top: top });
|
|
862
|
+
};
|
|
863
|
+
/**
|
|
864
|
+
* @override
|
|
865
|
+
* @inheritDoc
|
|
866
|
+
*/
|
|
867
|
+
AbstractCanvasObject.prototype.setHeight = function (height) {
|
|
868
|
+
this.setPosition({ height: height });
|
|
869
|
+
};
|
|
870
|
+
/**
|
|
871
|
+
* @override
|
|
872
|
+
* @inheritDoc
|
|
873
|
+
*/
|
|
874
|
+
AbstractCanvasObject.prototype.setWidth = function (width) {
|
|
875
|
+
this.setPosition({ width: width });
|
|
876
|
+
};
|
|
877
|
+
/**
|
|
878
|
+
* @override
|
|
879
|
+
* @inheritDoc
|
|
880
|
+
*/
|
|
881
|
+
AbstractCanvasObject.prototype.setAngle = function (angle) {
|
|
882
|
+
this.setPosition({ angle: angle });
|
|
883
|
+
};
|
|
884
|
+
/**
|
|
885
|
+
* @override
|
|
886
|
+
* @inheritDoc
|
|
887
|
+
*/
|
|
888
|
+
AbstractCanvasObject.prototype.setScaleX = function (scale) {
|
|
889
|
+
this.setPosition({ scaleX: scale });
|
|
890
|
+
};
|
|
891
|
+
/**
|
|
892
|
+
* @override
|
|
893
|
+
* @inheritDoc
|
|
894
|
+
*/
|
|
895
|
+
AbstractCanvasObject.prototype.setScaleY = function (scale) {
|
|
896
|
+
this.setPosition({ scaleY: scale });
|
|
897
|
+
};
|
|
821
898
|
/**
|
|
822
899
|
* Get the underlying fabric object.
|
|
823
900
|
* (Internal use only, do not expose this outside the canvas module).
|
|
@@ -835,6 +912,13 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
835
912
|
this.fabricObject.set({ width: position.width / scale.x });
|
|
836
913
|
if (position.height != undefined)
|
|
837
914
|
this.fabricObject.set({ height: position.height / scale.y });
|
|
915
|
+
if (position.angle != undefined)
|
|
916
|
+
this.fabricObject.set({ angle: position.angle });
|
|
917
|
+
if (position.scaleX != undefined)
|
|
918
|
+
this.fabricObject.set({ scaleX: position.scaleX });
|
|
919
|
+
if (position.scaleY != undefined)
|
|
920
|
+
this.fabricObject.set({ scaleY: position.scaleY });
|
|
921
|
+
this.canvas.notifyObjectListChanged();
|
|
838
922
|
};
|
|
839
923
|
AbstractCanvasObject.prototype.setCoords = function () {
|
|
840
924
|
this.fabricObject.setCoords();
|
|
@@ -1256,14 +1340,6 @@ var HorizontalRule = /** @class */ (function (_super) {
|
|
|
1256
1340
|
HorizontalRule.prototype.centerVertically = function () {
|
|
1257
1341
|
_super.prototype.centerVerticallyInternal.call(this);
|
|
1258
1342
|
};
|
|
1259
|
-
/**
|
|
1260
|
-
* @override
|
|
1261
|
-
* @inheritDoc
|
|
1262
|
-
*/
|
|
1263
|
-
HorizontalRule.prototype.setHeight = function (height) {
|
|
1264
|
-
this.setPosition({ height: height });
|
|
1265
|
-
this.canvas.notifyObjectListChanged();
|
|
1266
|
-
};
|
|
1267
1343
|
/**
|
|
1268
1344
|
* @override
|
|
1269
1345
|
* @inheritDoc
|
|
@@ -1368,14 +1444,6 @@ var Image = /** @class */ (function (_super) {
|
|
|
1368
1444
|
Image.prototype.centerVertically = function () {
|
|
1369
1445
|
_super.prototype.centerVerticallyInternal.call(this);
|
|
1370
1446
|
};
|
|
1371
|
-
/**
|
|
1372
|
-
* @override
|
|
1373
|
-
* @inheritDoc
|
|
1374
|
-
*/
|
|
1375
|
-
Image.prototype.setHeight = function (height) {
|
|
1376
|
-
this.setPosition({ height: height });
|
|
1377
|
-
this.canvas.notifyObjectListChanged();
|
|
1378
|
-
};
|
|
1379
1447
|
/**
|
|
1380
1448
|
* @override
|
|
1381
1449
|
* @inheritDoc
|
|
@@ -1510,14 +1578,6 @@ var Rectangle = /** @class */ (function (_super) {
|
|
|
1510
1578
|
Rectangle.prototype.centerVertically = function () {
|
|
1511
1579
|
_super.prototype.centerVerticallyInternal.call(this);
|
|
1512
1580
|
};
|
|
1513
|
-
/**
|
|
1514
|
-
* @override
|
|
1515
|
-
* @inheritDoc
|
|
1516
|
-
*/
|
|
1517
|
-
Rectangle.prototype.setHeight = function (height) {
|
|
1518
|
-
this.setPosition({ height: height });
|
|
1519
|
-
this.canvas.notifyObjectListChanged();
|
|
1520
|
-
};
|
|
1521
1581
|
/**
|
|
1522
1582
|
* @override
|
|
1523
1583
|
* @inheritDoc
|
|
@@ -1811,13 +1871,6 @@ var Text = /** @class */ (function (_super) {
|
|
|
1811
1871
|
Text.prototype.centerVertically = function () {
|
|
1812
1872
|
_super.prototype.centerVerticallyInternal.call(this);
|
|
1813
1873
|
};
|
|
1814
|
-
/**
|
|
1815
|
-
* @override
|
|
1816
|
-
* @inheritDoc
|
|
1817
|
-
*/
|
|
1818
|
-
Text.prototype.setHeight = function (height) {
|
|
1819
|
-
//no-op
|
|
1820
|
-
};
|
|
1821
1874
|
/**
|
|
1822
1875
|
* @override
|
|
1823
1876
|
* @inheritDoc
|
|
@@ -2209,14 +2262,6 @@ var VerticalRule = /** @class */ (function (_super) {
|
|
|
2209
2262
|
VerticalRule.prototype.centerVertically = function () {
|
|
2210
2263
|
_super.prototype.centerVerticallyInternal.call(this);
|
|
2211
2264
|
};
|
|
2212
|
-
/**
|
|
2213
|
-
* @override
|
|
2214
|
-
* @inheritDoc
|
|
2215
|
-
*/
|
|
2216
|
-
VerticalRule.prototype.setHeight = function (height) {
|
|
2217
|
-
this.setPosition({ height: height });
|
|
2218
|
-
this.canvas.notifyObjectListChanged();
|
|
2219
|
-
};
|
|
2220
2265
|
/**
|
|
2221
2266
|
* @override
|
|
2222
2267
|
* @inheritDoc
|
|
@@ -3236,6 +3281,7 @@ exports.HeadlessInteractiveCanvas = HeadlessInteractiveCanvas;
|
|
|
3236
3281
|
exports.HorizontalRule = HorizontalRule;
|
|
3237
3282
|
exports.Image = Image;
|
|
3238
3283
|
exports.InteractiveCanvas = InteractiveCanvas;
|
|
3284
|
+
exports.MillimeterDimensions = MillimeterDimensions;
|
|
3239
3285
|
exports.PixelCanvasDimensions = PixelCanvasDimensions;
|
|
3240
3286
|
exports.Print6ColCanvasDimensions = Print6ColCanvasDimensions;
|
|
3241
3287
|
exports.Print8ColCanvasDimensions = Print8ColCanvasDimensions;
|
|
@@ -8,11 +8,41 @@ export interface IMutablePosition extends ICanvasObject {
|
|
|
8
8
|
* Center the object vertically on the canvas.
|
|
9
9
|
*/
|
|
10
10
|
centerVertically(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Set the left value of the element.
|
|
13
|
+
* @param left New left value.
|
|
14
|
+
*/
|
|
15
|
+
setLeft(left: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* Set the top value of the element.
|
|
18
|
+
* @param top New top value.
|
|
19
|
+
*/
|
|
20
|
+
setTop(top: number): void;
|
|
11
21
|
/**
|
|
12
22
|
* Set the height of the element.
|
|
13
23
|
* @param height New height.
|
|
14
24
|
*/
|
|
15
25
|
setHeight(height: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Set the width of the element.
|
|
28
|
+
* @param width New width.
|
|
29
|
+
*/
|
|
30
|
+
setWidth(width: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* Set the angle of the element.
|
|
33
|
+
* @param angle New angle.
|
|
34
|
+
*/
|
|
35
|
+
setAngle(angle: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Set the x scale of the element.
|
|
38
|
+
* @param scale New scale.
|
|
39
|
+
*/
|
|
40
|
+
setScaleX(scale: number): void;
|
|
41
|
+
/**
|
|
42
|
+
* Set the y scale of the element.
|
|
43
|
+
* @param scale New scale.
|
|
44
|
+
*/
|
|
45
|
+
setScaleY(scale: number): void;
|
|
16
46
|
/**
|
|
17
47
|
* Nudge the object upward.
|
|
18
48
|
*/
|
|
@@ -123,6 +123,41 @@ export declare abstract class AbstractCanvasObject<T extends Object> implements
|
|
|
123
123
|
* @inheritDoc
|
|
124
124
|
*/
|
|
125
125
|
setPinToBottom(value?: boolean): void;
|
|
126
|
+
/**
|
|
127
|
+
* @override
|
|
128
|
+
* @inheritDoc
|
|
129
|
+
*/
|
|
130
|
+
setLeft(left: number): void;
|
|
131
|
+
/**
|
|
132
|
+
* @override
|
|
133
|
+
* @inheritDoc
|
|
134
|
+
*/
|
|
135
|
+
setTop(top: number): void;
|
|
136
|
+
/**
|
|
137
|
+
* @override
|
|
138
|
+
* @inheritDoc
|
|
139
|
+
*/
|
|
140
|
+
setHeight(height: number): void;
|
|
141
|
+
/**
|
|
142
|
+
* @override
|
|
143
|
+
* @inheritDoc
|
|
144
|
+
*/
|
|
145
|
+
setWidth(width: number): void;
|
|
146
|
+
/**
|
|
147
|
+
* @override
|
|
148
|
+
* @inheritDoc
|
|
149
|
+
*/
|
|
150
|
+
setAngle(angle: number): void;
|
|
151
|
+
/**
|
|
152
|
+
* @override
|
|
153
|
+
* @inheritDoc
|
|
154
|
+
*/
|
|
155
|
+
setScaleX(scale: number): void;
|
|
156
|
+
/**
|
|
157
|
+
* @override
|
|
158
|
+
* @inheritDoc
|
|
159
|
+
*/
|
|
160
|
+
setScaleY(scale: number): void;
|
|
126
161
|
/**
|
|
127
162
|
* Get the underlying fabric object.
|
|
128
163
|
* (Internal use only, do not expose this outside the canvas module).
|
|
@@ -157,11 +157,6 @@ export declare class Text extends AbstractCanvasObject<fabric.Textbox> implement
|
|
|
157
157
|
* @inheritDoc
|
|
158
158
|
*/
|
|
159
159
|
centerVertically(): void;
|
|
160
|
-
/**
|
|
161
|
-
* @override
|
|
162
|
-
* @inheritDoc
|
|
163
|
-
*/
|
|
164
|
-
setHeight(height: number): void;
|
|
165
160
|
/**
|
|
166
161
|
* @override
|
|
167
162
|
* @inheritDoc
|