@hadi77ir/pdfme-svg 0.1.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/README.md +63 -0
- package/dist/applyparseattributes.d.ts +6 -0
- package/dist/applyparseattributes.d.ts.map +1 -0
- package/dist/applyparseattributes.js +333 -0
- package/dist/applyparseattributes.js.map +1 -0
- package/dist/context/attributestate.d.ts +34 -0
- package/dist/context/attributestate.d.ts.map +1 -0
- package/dist/context/attributestate.js +109 -0
- package/dist/context/attributestate.js.map +1 -0
- package/dist/context/context.d.ts +59 -0
- package/dist/context/context.d.ts.map +1 -0
- package/dist/context/context.js +46 -0
- package/dist/context/context.js.map +1 -0
- package/dist/context/referenceshandler.d.ts +15 -0
- package/dist/context/referenceshandler.d.ts.map +1 -0
- package/dist/context/referenceshandler.js +31 -0
- package/dist/context/referenceshandler.js.map +1 -0
- package/dist/context/stylesheets.d.ts +13 -0
- package/dist/context/stylesheets.d.ts.map +1 -0
- package/dist/context/stylesheets.js +163 -0
- package/dist/context/stylesheets.js.map +1 -0
- package/dist/context/textmeasure.d.ts +19 -0
- package/dist/context/textmeasure.d.ts.map +1 -0
- package/dist/context/textmeasure.js +93 -0
- package/dist/context/textmeasure.js.map +1 -0
- package/dist/context/viewport.d.ts +6 -0
- package/dist/context/viewport.d.ts.map +1 -0
- package/dist/context/viewport.js +7 -0
- package/dist/context/viewport.js.map +1 -0
- package/dist/fill/ColorFill.d.ts +10 -0
- package/dist/fill/ColorFill.d.ts.map +1 -0
- package/dist/fill/ColorFill.js +10 -0
- package/dist/fill/ColorFill.js.map +1 -0
- package/dist/fill/Fill.d.ts +14 -0
- package/dist/fill/Fill.d.ts.map +1 -0
- package/dist/fill/Fill.js +2 -0
- package/dist/fill/Fill.js.map +1 -0
- package/dist/fill/GradientFill.d.ts +11 -0
- package/dist/fill/GradientFill.d.ts.map +1 -0
- package/dist/fill/GradientFill.js +37 -0
- package/dist/fill/GradientFill.js.map +1 -0
- package/dist/fill/PatternFill.d.ts +11 -0
- package/dist/fill/PatternFill.d.ts.map +1 -0
- package/dist/fill/PatternFill.js +67 -0
- package/dist/fill/PatternFill.js.map +1 -0
- package/dist/fill/parseFill.d.ts +4 -0
- package/dist/fill/parseFill.d.ts.map +1 -0
- package/dist/fill/parseFill.js +61 -0
- package/dist/fill/parseFill.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +232 -0
- package/dist/index.js.map +1 -0
- package/dist/jspdf-shim.d.ts +132 -0
- package/dist/jspdf-shim.d.ts.map +1 -0
- package/dist/jspdf-shim.js +744 -0
- package/dist/jspdf-shim.js.map +1 -0
- package/dist/jspdf.d.ts +2 -0
- package/dist/jspdf.d.ts.map +1 -0
- package/dist/jspdf.js +2 -0
- package/dist/jspdf.js.map +1 -0
- package/dist/markerlist.d.ts +24 -0
- package/dist/markerlist.d.ts.map +1 -0
- package/dist/markerlist.js +47 -0
- package/dist/markerlist.js.map +1 -0
- package/dist/nodes/anchor.d.ts +6 -0
- package/dist/nodes/anchor.d.ts.map +1 -0
- package/dist/nodes/anchor.js +15 -0
- package/dist/nodes/anchor.js.map +1 -0
- package/dist/nodes/circle.d.ts +11 -0
- package/dist/nodes/circle.d.ts.map +1 -0
- package/dist/nodes/circle.js +17 -0
- package/dist/nodes/circle.js.map +1 -0
- package/dist/nodes/clippath.d.ts +10 -0
- package/dist/nodes/clippath.d.ts.map +1 -0
- package/dist/nodes/clippath.js +48 -0
- package/dist/nodes/clippath.js.map +1 -0
- package/dist/nodes/containernode.d.ts +8 -0
- package/dist/nodes/containernode.d.ts.map +1 -0
- package/dist/nodes/containernode.js +13 -0
- package/dist/nodes/containernode.js.map +1 -0
- package/dist/nodes/ellipse.d.ts +9 -0
- package/dist/nodes/ellipse.d.ts.map +1 -0
- package/dist/nodes/ellipse.js +14 -0
- package/dist/nodes/ellipse.js.map +1 -0
- package/dist/nodes/ellipsebase.d.ts +14 -0
- package/dist/nodes/ellipsebase.d.ts.map +1 -0
- package/dist/nodes/ellipsebase.js +30 -0
- package/dist/nodes/ellipsebase.js.map +1 -0
- package/dist/nodes/geometrynode.d.ts +19 -0
- package/dist/nodes/geometrynode.d.ts.map +1 -0
- package/dist/nodes/geometrynode.js +213 -0
- package/dist/nodes/geometrynode.js.map +1 -0
- package/dist/nodes/gradient.d.ts +28 -0
- package/dist/nodes/gradient.d.ts.map +1 -0
- package/dist/nodes/gradient.js +87 -0
- package/dist/nodes/gradient.js.map +1 -0
- package/dist/nodes/graphicsnode.d.ts +4 -0
- package/dist/nodes/graphicsnode.d.ts.map +1 -0
- package/dist/nodes/graphicsnode.js +4 -0
- package/dist/nodes/graphicsnode.js.map +1 -0
- package/dist/nodes/group.d.ts +8 -0
- package/dist/nodes/group.d.ts.map +1 -0
- package/dist/nodes/group.js +11 -0
- package/dist/nodes/group.js.map +1 -0
- package/dist/nodes/image.d.ts +23 -0
- package/dist/nodes/image.d.ts.map +1 -0
- package/dist/nodes/image.js +152 -0
- package/dist/nodes/image.js.map +1 -0
- package/dist/nodes/line.d.ts +13 -0
- package/dist/nodes/line.d.ts.map +1 -0
- package/dist/nodes/line.js +30 -0
- package/dist/nodes/line.js.map +1 -0
- package/dist/nodes/lineargradient.d.ts +7 -0
- package/dist/nodes/lineargradient.d.ts.map +1 -0
- package/dist/nodes/lineargradient.js +15 -0
- package/dist/nodes/lineargradient.js.map +1 -0
- package/dist/nodes/marker.d.ts +11 -0
- package/dist/nodes/marker.d.ts.map +1 -0
- package/dist/nodes/marker.js +70 -0
- package/dist/nodes/marker.js.map +1 -0
- package/dist/nodes/nonrenderednode.d.ts +11 -0
- package/dist/nodes/nonrenderednode.d.ts.map +1 -0
- package/dist/nodes/nonrenderednode.js +15 -0
- package/dist/nodes/nonrenderednode.js.map +1 -0
- package/dist/nodes/path.d.ts +12 -0
- package/dist/nodes/path.d.ts.map +1 -0
- package/dist/nodes/path.js +75 -0
- package/dist/nodes/path.js.map +1 -0
- package/dist/nodes/pattern.d.ts +11 -0
- package/dist/nodes/pattern.d.ts.map +1 -0
- package/dist/nodes/pattern.js +39 -0
- package/dist/nodes/pattern.js.map +1 -0
- package/dist/nodes/polygon.d.ts +6 -0
- package/dist/nodes/polygon.d.ts.map +1 -0
- package/dist/nodes/polygon.js +7 -0
- package/dist/nodes/polygon.js.map +1 -0
- package/dist/nodes/polyline.d.ts +6 -0
- package/dist/nodes/polyline.d.ts.map +1 -0
- package/dist/nodes/polyline.js +7 -0
- package/dist/nodes/polyline.js.map +1 -0
- package/dist/nodes/radialgradient.d.ts +7 -0
- package/dist/nodes/radialgradient.d.ts.map +1 -0
- package/dist/nodes/radialgradient.js +21 -0
- package/dist/nodes/radialgradient.js.map +1 -0
- package/dist/nodes/rect.d.ts +12 -0
- package/dist/nodes/rect.d.ts.map +1 -0
- package/dist/nodes/rect.js +50 -0
- package/dist/nodes/rect.js.map +1 -0
- package/dist/nodes/renderednode.d.ts +7 -0
- package/dist/nodes/renderednode.d.ts.map +1 -0
- package/dist/nodes/renderednode.js +43 -0
- package/dist/nodes/renderednode.js.map +1 -0
- package/dist/nodes/svg.d.ts +21 -0
- package/dist/nodes/svg.d.ts.map +1 -0
- package/dist/nodes/svg.js +175 -0
- package/dist/nodes/svg.js.map +1 -0
- package/dist/nodes/svgnode.d.ts +18 -0
- package/dist/nodes/svgnode.d.ts.map +1 -0
- package/dist/nodes/svgnode.js +30 -0
- package/dist/nodes/svgnode.js.map +1 -0
- package/dist/nodes/symbol.d.ts +10 -0
- package/dist/nodes/symbol.d.ts.map +1 -0
- package/dist/nodes/symbol.js +62 -0
- package/dist/nodes/symbol.js.map +1 -0
- package/dist/nodes/text.d.ts +13 -0
- package/dist/nodes/text.d.ts.map +1 -0
- package/dist/nodes/text.js +172 -0
- package/dist/nodes/text.js.map +1 -0
- package/dist/nodes/traverse.d.ts +15 -0
- package/dist/nodes/traverse.d.ts.map +1 -0
- package/dist/nodes/traverse.js +47 -0
- package/dist/nodes/traverse.js.map +1 -0
- package/dist/nodes/use.d.ts +15 -0
- package/dist/nodes/use.d.ts.map +1 -0
- package/dist/nodes/use.js +99 -0
- package/dist/nodes/use.js.map +1 -0
- package/dist/nodes/void.d.ts +11 -0
- package/dist/nodes/void.d.ts.map +1 -0
- package/dist/nodes/void.js +19 -0
- package/dist/nodes/void.js.map +1 -0
- package/dist/parse.d.ts +5 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +96 -0
- package/dist/parse.js.map +1 -0
- package/dist/svg2pdf.d.ts +10 -0
- package/dist/svg2pdf.d.ts.map +1 -0
- package/dist/svg2pdf.js +49 -0
- package/dist/svg2pdf.js.map +1 -0
- package/dist/textchunk.d.ts +36 -0
- package/dist/textchunk.d.ts.map +1 -0
- package/dist/textchunk.js +144 -0
- package/dist/textchunk.js.map +1 -0
- package/dist/utils/applyclippath.d.ts +6 -0
- package/dist/utils/applyclippath.d.ts.map +1 -0
- package/dist/utils/applyclippath.js +20 -0
- package/dist/utils/applyclippath.js.map +1 -0
- package/dist/utils/bbox.d.ts +6 -0
- package/dist/utils/bbox.d.ts.map +1 -0
- package/dist/utils/bbox.js +62 -0
- package/dist/utils/bbox.js.map +1 -0
- package/dist/utils/constants.d.ts +7 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +17 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/fonts.d.ts +14 -0
- package/dist/utils/fonts.d.ts.map +1 -0
- package/dist/utils/fonts.js +59 -0
- package/dist/utils/fonts.js.map +1 -0
- package/dist/utils/geometry.d.ts +11 -0
- package/dist/utils/geometry.d.ts.map +1 -0
- package/dist/utils/geometry.js +26 -0
- package/dist/utils/geometry.js.map +1 -0
- package/dist/utils/misc.d.ts +12 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/dist/utils/misc.js +26 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/node.d.ts +9 -0
- package/dist/utils/node.d.ts.map +1 -0
- package/dist/utils/node.js +58 -0
- package/dist/utils/node.js.map +1 -0
- package/dist/utils/parsing.d.ts +13 -0
- package/dist/utils/parsing.d.ts.map +1 -0
- package/dist/utils/parsing.js +41 -0
- package/dist/utils/parsing.js.map +1 -0
- package/dist/utils/path.d.ts +39 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +86 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/rgbcolor.d.ts +15 -0
- package/dist/utils/rgbcolor.d.ts.map +1 -0
- package/dist/utils/rgbcolor.js +297 -0
- package/dist/utils/rgbcolor.js.map +1 -0
- package/dist/utils/text.d.ts +15 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +57 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/transform.d.ts +5 -0
- package/dist/utils/transform.d.ts.map +1 -0
- package/dist/utils/transform.js +113 -0
- package/dist/utils/transform.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { getAttribute } from './node';
|
|
2
|
+
export function getBoundingBoxByChildren(context, svgnode) {
|
|
3
|
+
if (getAttribute(svgnode.element, context.styleSheets, 'display') === 'none') {
|
|
4
|
+
return [0, 0, 0, 0];
|
|
5
|
+
}
|
|
6
|
+
let boundingBox = [];
|
|
7
|
+
svgnode.children.forEach(child => {
|
|
8
|
+
const nodeBox = child.getBoundingBox(context);
|
|
9
|
+
if (nodeBox[0] === 0 && nodeBox[1] === 0 && nodeBox[2] === 0 && nodeBox[3] === 0)
|
|
10
|
+
return;
|
|
11
|
+
const transform = child.computeNodeTransform(context);
|
|
12
|
+
// TODO: take into account rotation matrix
|
|
13
|
+
nodeBox[0] = nodeBox[0] * transform.sx + transform.tx;
|
|
14
|
+
nodeBox[1] = nodeBox[1] * transform.sy + transform.ty;
|
|
15
|
+
nodeBox[2] = nodeBox[2] * transform.sx;
|
|
16
|
+
nodeBox[3] = nodeBox[3] * transform.sy;
|
|
17
|
+
if (boundingBox.length === 0)
|
|
18
|
+
boundingBox = nodeBox;
|
|
19
|
+
else
|
|
20
|
+
boundingBox = [
|
|
21
|
+
Math.min(boundingBox[0], nodeBox[0]),
|
|
22
|
+
Math.min(boundingBox[1], nodeBox[1]),
|
|
23
|
+
Math.max(boundingBox[0] + boundingBox[2], nodeBox[0] + nodeBox[2]) -
|
|
24
|
+
Math.min(boundingBox[0], nodeBox[0]),
|
|
25
|
+
Math.max(boundingBox[1] + boundingBox[3], nodeBox[1] + nodeBox[3]) -
|
|
26
|
+
Math.min(boundingBox[1], nodeBox[1])
|
|
27
|
+
];
|
|
28
|
+
});
|
|
29
|
+
return boundingBox.length === 0 ? [0, 0, 0, 0] : boundingBox;
|
|
30
|
+
}
|
|
31
|
+
export function defaultBoundingBox(element, context) {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
const pf = parseFloat;
|
|
34
|
+
// TODO: check if there are other possible coordinate attributes
|
|
35
|
+
const x1 = pf(element.getAttribute('x1')) ||
|
|
36
|
+
pf(getAttribute(element, context.styleSheets, 'x')) ||
|
|
37
|
+
pf(getAttribute(element, context.styleSheets, 'cx')) -
|
|
38
|
+
pf(getAttribute(element, context.styleSheets, 'r')) ||
|
|
39
|
+
0;
|
|
40
|
+
const x2 = pf(element.getAttribute('x2')) ||
|
|
41
|
+
x1 + pf(getAttribute(element, context.styleSheets, 'width')) ||
|
|
42
|
+
pf(getAttribute(element, context.styleSheets, 'cx')) +
|
|
43
|
+
pf(getAttribute(element, context.styleSheets, 'r')) ||
|
|
44
|
+
0;
|
|
45
|
+
const y1 = pf(element.getAttribute('y1')) ||
|
|
46
|
+
pf(getAttribute(element, context.styleSheets, 'y')) ||
|
|
47
|
+
pf(getAttribute(element, context.styleSheets, 'cy')) -
|
|
48
|
+
pf(getAttribute(element, context.styleSheets, 'r')) ||
|
|
49
|
+
0;
|
|
50
|
+
const y2 = pf(element.getAttribute('y2')) ||
|
|
51
|
+
y1 + pf(getAttribute(element, context.styleSheets, 'height')) ||
|
|
52
|
+
pf(getAttribute(element, context.styleSheets, 'cy')) +
|
|
53
|
+
pf(getAttribute(element, context.styleSheets, 'r')) ||
|
|
54
|
+
0;
|
|
55
|
+
return [
|
|
56
|
+
Math.min(x1, x2),
|
|
57
|
+
Math.min(y1, y2),
|
|
58
|
+
Math.max(x1, x2) - Math.min(x1, x2),
|
|
59
|
+
Math.max(y1, y2) - Math.min(y1, y2)
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=bbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bbox.js","sourceRoot":"","sources":["../../src/utils/bbox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAIrC,MAAM,UAAU,wBAAwB,CAAC,OAAgB,EAAE,OAAgB;IACzE,IAAI,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,KAAK,MAAM,EAAE,CAAC;QAC7E,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACrB,CAAC;IACD,IAAI,WAAW,GAAa,EAAE,CAAA;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC/B,MAAM,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;QAC7C,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;YAAE,OAAM;QACxF,MAAM,SAAS,GAAG,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;QACrD,0CAA0C;QAC1C,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,E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,MAAM,EAAE,GACN,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC9B,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC7D,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YAClD,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QACrD,CAAC,CAAA;IACH,OAAO;QACL,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;QAChB,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;QAChB,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;QACnC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;KACpC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TextBaseLine } from './misc';
|
|
2
|
+
export declare const iriReference: RegExp;
|
|
3
|
+
export declare const alignmentBaselineMap: {
|
|
4
|
+
[key: string]: TextBaseLine;
|
|
5
|
+
};
|
|
6
|
+
export declare const svgNamespaceURI = "http://www.w3.org/2000/svg";
|
|
7
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC,eAAO,MAAM,YAAY,QAA+B,CAAA;AAExD,eAAO,MAAM,oBAAoB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAa/D,CAAA;AAED,eAAO,MAAM,eAAe,+BAA+B,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const iriReference = /url\(["']?#([^"']+)["']?\)/;
|
|
2
|
+
export const alignmentBaselineMap = {
|
|
3
|
+
bottom: 'bottom',
|
|
4
|
+
'text-bottom': 'bottom',
|
|
5
|
+
top: 'top',
|
|
6
|
+
'text-top': 'top',
|
|
7
|
+
hanging: 'hanging',
|
|
8
|
+
middle: 'middle',
|
|
9
|
+
central: 'middle',
|
|
10
|
+
center: 'middle',
|
|
11
|
+
mathematical: 'middle',
|
|
12
|
+
ideographic: 'ideographic',
|
|
13
|
+
alphabetic: 'alphabetic',
|
|
14
|
+
baseline: 'alphabetic'
|
|
15
|
+
};
|
|
16
|
+
export const svgNamespaceURI = 'http://www.w3.org/2000/svg';
|
|
17
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG,4BAA4B,CAAA;AAExD,MAAM,CAAC,MAAM,oBAAoB,GAAoC;IACnE,MAAM,EAAE,QAAQ;IAChB,aAAa,EAAE,QAAQ;IACvB,GAAG,EAAE,KAAK;IACV,UAAU,EAAE,KAAK;IACjB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,QAAQ;IACjB,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,QAAQ;IACtB,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,YAAY;CACvB,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {AttributeState} attributeState
|
|
3
|
+
* @param {string[]} fontFamilies
|
|
4
|
+
* @return {string}
|
|
5
|
+
*/
|
|
6
|
+
import { AttributeState } from '../context/attributestate';
|
|
7
|
+
import { Context } from '../context/context';
|
|
8
|
+
export type FontFamily = string;
|
|
9
|
+
export declare const fontAliases: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function findFirstAvailableFontFamily(attributeState: AttributeState, fontFamilies: FontFamily[], context: Context): FontFamily;
|
|
13
|
+
export declare function combineFontStyleAndFontWeight(fontStyle: string, fontWeight: number | string): string;
|
|
14
|
+
//# sourceMappingURL=fonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/utils/fonts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAG5C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAE/B,eAAO,MAAM,WAAW,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAYhD,CAAA;AAED,wBAAgB,4BAA4B,CAC1C,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,UAAU,EAAE,EAC1B,OAAO,EAAE,OAAO,GACf,UAAU,CA6BZ;AAOD,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAAG,MAAM,GAC1B,MAAM,CAkBR"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsPDF } from 'jspdf';
|
|
2
|
+
export const fontAliases = {
|
|
3
|
+
'sans-serif': 'helvetica',
|
|
4
|
+
verdana: 'helvetica',
|
|
5
|
+
arial: 'helvetica',
|
|
6
|
+
fixed: 'courier',
|
|
7
|
+
monospace: 'courier',
|
|
8
|
+
terminal: 'courier',
|
|
9
|
+
serif: 'times',
|
|
10
|
+
cursive: 'times',
|
|
11
|
+
fantasy: 'times'
|
|
12
|
+
};
|
|
13
|
+
export function findFirstAvailableFontFamily(attributeState, fontFamilies, context) {
|
|
14
|
+
const fontType = combineFontStyleAndFontWeight(attributeState.fontStyle, attributeState.fontWeight);
|
|
15
|
+
const availableFonts = context.pdf.getFontList();
|
|
16
|
+
let firstAvailable = '';
|
|
17
|
+
const fontIsAvailable = fontFamilies.some(font => {
|
|
18
|
+
const availableStyles = availableFonts[font];
|
|
19
|
+
if (availableStyles && availableStyles.indexOf(fontType) >= 0) {
|
|
20
|
+
firstAvailable = font;
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
font = font.toLowerCase();
|
|
24
|
+
if (fontAliases.hasOwnProperty(font)) {
|
|
25
|
+
firstAvailable = font;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
});
|
|
30
|
+
if (!fontIsAvailable) {
|
|
31
|
+
firstAvailable = 'times';
|
|
32
|
+
}
|
|
33
|
+
return firstAvailable;
|
|
34
|
+
}
|
|
35
|
+
const isJsPDF23 = (() => {
|
|
36
|
+
const parts = jsPDF.version.split('.');
|
|
37
|
+
return parseFloat(parts[0]) === 2 && parseFloat(parts[1]) === 3;
|
|
38
|
+
})();
|
|
39
|
+
export function combineFontStyleAndFontWeight(fontStyle, fontWeight) {
|
|
40
|
+
if (isJsPDF23) {
|
|
41
|
+
return fontWeight == 400
|
|
42
|
+
? fontStyle == 'italic'
|
|
43
|
+
? 'italic'
|
|
44
|
+
: 'normal'
|
|
45
|
+
: fontWeight == 700 && fontStyle !== 'italic'
|
|
46
|
+
? 'bold'
|
|
47
|
+
: fontStyle + '' + fontWeight;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return fontWeight == 400 || fontWeight === 'normal'
|
|
51
|
+
? fontStyle === 'italic'
|
|
52
|
+
? 'italic'
|
|
53
|
+
: 'normal'
|
|
54
|
+
: (fontWeight == 700 || fontWeight === 'bold') && fontStyle === 'normal'
|
|
55
|
+
? 'bold'
|
|
56
|
+
: (fontWeight == 700 ? 'bold' : fontWeight) + '' + fontStyle;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=fonts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.js","sourceRoot":"","sources":["../../src/utils/fonts.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAI7B,MAAM,CAAC,MAAM,WAAW,GAA8B;IACpD,YAAY,EAAE,WAAW;IACzB,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,WAAW;IAElB,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,SAAS;IAEnB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,OAAO;CACjB,CAAA;AAED,MAAM,UAAU,4BAA4B,CAC1C,cAA8B,EAC9B,YAA0B,EAC1B,OAAgB;IAEhB,MAAM,QAAQ,GAAG,6BAA6B,CAC5C,cAAc,CAAC,SAAS,EACxB,cAAc,CAAC,UAAU,CAC1B,CAAA;IAED,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAA;IAChD,IAAI,cAAc,GAAG,EAAE,CAAA;IACvB,MAAM,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC/C,MAAM,eAAe,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QAC5C,IAAI,eAAe,IAAI,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9D,cAAc,GAAG,IAAI,CAAA;YACrB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;QACzB,IAAI,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,cAAc,GAAG,IAAI,CAAA;YACrB,O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;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Matrix } from 'jspdf';
|
|
2
|
+
export type Point = number[];
|
|
3
|
+
export type Rect = number[];
|
|
4
|
+
export declare function getAngle(from: Point, to: Point): number;
|
|
5
|
+
export declare const cToQ: number;
|
|
6
|
+
export declare function toCubic(from: Point, to: Point): Point;
|
|
7
|
+
export declare function normalize(v: Point): Point;
|
|
8
|
+
export declare function getDirectionVector(from: Point, to: Point): Point;
|
|
9
|
+
export declare function addVectors(v1: Point, v2: Point): Point;
|
|
10
|
+
export declare function multVecMatrix(vec: Point, matrix: Matrix): Point;
|
|
11
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/utils/geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAE9B,MAAM,MAAM,KAAK,GAAG,MAAM,EAAE,CAAA;AAC5B,MAAM,MAAM,IAAI,GAAG,MAAM,EAAE,CAAA;AAE3B,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAEvD;AAED,eAAO,MAAM,IAAI,QAAQ,CAAA;AAEzB,wBAAgB,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,KAAK,CAErD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAGzC;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,KAAK,CAGhE;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,KAAK,CAEtD;AAGD,wBAAgB,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAI/D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function getAngle(from, to) {
|
|
2
|
+
return Math.atan2(to[1] - from[1], to[0] - from[0]);
|
|
3
|
+
}
|
|
4
|
+
export const cToQ = 2 / 3; // ratio to convert quadratic bezier curves to cubic ones
|
|
5
|
+
// transforms a cubic bezier control point to a quadratic one: returns from + (2/3) * (to - from)
|
|
6
|
+
export function toCubic(from, to) {
|
|
7
|
+
return [cToQ * (to[0] - from[0]) + from[0], cToQ * (to[1] - from[1]) + from[1]];
|
|
8
|
+
}
|
|
9
|
+
export function normalize(v) {
|
|
10
|
+
const length = Math.sqrt(v[0] * v[0] + v[1] * v[1]);
|
|
11
|
+
return [v[0] / length, v[1] / length];
|
|
12
|
+
}
|
|
13
|
+
export function getDirectionVector(from, to) {
|
|
14
|
+
const v = [to[0] - from[0], to[1] - from[1]];
|
|
15
|
+
return normalize(v);
|
|
16
|
+
}
|
|
17
|
+
export function addVectors(v1, v2) {
|
|
18
|
+
return [v1[0] + v2[0], v1[1] + v2[1]];
|
|
19
|
+
}
|
|
20
|
+
// multiplies a vector with a matrix: vec' = vec * matrix
|
|
21
|
+
export function multVecMatrix(vec, matrix) {
|
|
22
|
+
const x = vec[0];
|
|
23
|
+
const y = vec[1];
|
|
24
|
+
return [matrix.a * x + matrix.c * y + matrix.e, matrix.b * x + matrix.d * y + matrix.f];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/utils/geometry.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,QAAQ,CAAC,IAAW,EAAE,EAAS;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AACrD,CAAC;AAED,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AAC,GAAU,EAAE,MAAc;IACtD,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;IAChB,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;IAChB,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;AACzF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TextOptionsLight } from 'jspdf';
|
|
2
|
+
/**
|
|
3
|
+
* Convert em, px and bare number attributes to pixel values
|
|
4
|
+
* @param {string} value
|
|
5
|
+
* @param {number} pdfFontSize
|
|
6
|
+
*/
|
|
7
|
+
export declare function toPixels(value: string | null, pdfFontSize: number): number;
|
|
8
|
+
declare let tol: TextOptionsLight;
|
|
9
|
+
export type TextBaseLine = typeof tol.baseline;
|
|
10
|
+
export declare function mapAlignmentBaseline(value: string): TextBaseLine;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=misc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../src/utils/misc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAExC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAe1E;AAGD,QAAA,IAAI,GAAG,EAAE,gBAAgB,CAAA;AACzB,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,CAAC,QAAQ,CAAA;AAE9C,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAEhE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { alignmentBaselineMap } from './constants';
|
|
2
|
+
/**
|
|
3
|
+
* Convert em, px and bare number attributes to pixel values
|
|
4
|
+
* @param {string} value
|
|
5
|
+
* @param {number} pdfFontSize
|
|
6
|
+
*/
|
|
7
|
+
export function toPixels(value, pdfFontSize) {
|
|
8
|
+
let match;
|
|
9
|
+
// em
|
|
10
|
+
match = value && value.toString().match(/^([\-0-9.]+)em$/);
|
|
11
|
+
if (match) {
|
|
12
|
+
return parseFloat(match[1]) * pdfFontSize;
|
|
13
|
+
}
|
|
14
|
+
// pixels
|
|
15
|
+
match = value && value.toString().match(/^([\-0-9.]+)(px|)$/);
|
|
16
|
+
if (match) {
|
|
17
|
+
return parseFloat(match[1]);
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
// capture type...
|
|
22
|
+
let tol;
|
|
23
|
+
export function mapAlignmentBaseline(value) {
|
|
24
|
+
return alignmentBaselineMap[value] || 'alphabetic';
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=misc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.js","sourceRoot":"","sources":["../../src/utils/misc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAGlD;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAoB,EAAE,WAAmB;IAChE,IAAI,KAAK,CAAA;IAET,KAAK;IACL,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAC1D,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAA;IAC3C,CAAC;IAED,SAAS;IACT,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAA;IAC7D,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC;IACD,OAAO,CAAC,CAAA;AACV,CAAC;AAED,kBAAkB;AAClB,IAAI,GAAqB,CAAA;AAGzB,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,oBAAoB,CAAC,KAAK,CAAC,IAAI,YAAY,CAAA;AACpD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SvgNode } from '../nodes/svgnode';
|
|
2
|
+
import { Context } from '../context/context';
|
|
3
|
+
import { StyleSheets } from '../context/stylesheets';
|
|
4
|
+
export declare function nodeIs(node: Element, tagsString: string): boolean;
|
|
5
|
+
export declare function forEachChild(node: Element, fn: (n: number, e: Element) => void): void;
|
|
6
|
+
export declare function getAttribute(node: Element, styleSheets: StyleSheets, propertyNode: string, propertyCss?: string): string | undefined;
|
|
7
|
+
export declare function svgNodeIsVisible(svgNode: SvgNode, parentVisible: boolean, context: Context): boolean;
|
|
8
|
+
export declare function svgNodeAndChildrenVisible(svgNode: SvgNode, parentVisible: boolean, context: Context): boolean;
|
|
9
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/utils/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAUrF;AAGD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,MAAM,EACpB,WAAW,SAAe,GACzB,MAAM,GAAG,SAAS,CAcpB;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,OAAO,EACtB,OAAO,EAAE,OAAO,GACf,OAAO,CAaT;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,OAAO,EACtB,OAAO,EAAE,OAAO,GACf,OAAO,CAYT"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function nodeIs(node, tagsString) {
|
|
2
|
+
return tagsString.split(',').indexOf((node.nodeName || node.tagName).toLowerCase()) >= 0;
|
|
3
|
+
}
|
|
4
|
+
export function forEachChild(node, fn) {
|
|
5
|
+
// copy list of children, as the original might be modified
|
|
6
|
+
const children = [];
|
|
7
|
+
for (let i = 0; i < node.childNodes.length; i++) {
|
|
8
|
+
const childNode = node.childNodes[i];
|
|
9
|
+
if (childNode.nodeName.charAt(0) !== '#')
|
|
10
|
+
children.push(childNode);
|
|
11
|
+
}
|
|
12
|
+
for (let i = 0; i < children.length; i++) {
|
|
13
|
+
fn(i, children[i]);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// returns an attribute of a node, either from the node directly or from css
|
|
17
|
+
export function getAttribute(node, styleSheets, propertyNode, propertyCss = propertyNode) {
|
|
18
|
+
const attribute = node.style?.getPropertyValue(propertyCss);
|
|
19
|
+
if (attribute) {
|
|
20
|
+
return attribute;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const propertyValue = styleSheets.getPropertyValue(node, propertyCss);
|
|
24
|
+
if (propertyValue) {
|
|
25
|
+
return propertyValue;
|
|
26
|
+
}
|
|
27
|
+
else if (node.hasAttribute(propertyNode)) {
|
|
28
|
+
return node.getAttribute(propertyNode) || undefined;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function svgNodeIsVisible(svgNode, parentVisible, context) {
|
|
36
|
+
if (getAttribute(svgNode.element, context.styleSheets, 'display') === 'none') {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
let visible = parentVisible;
|
|
40
|
+
const visibility = getAttribute(svgNode.element, context.styleSheets, 'visibility');
|
|
41
|
+
if (visibility) {
|
|
42
|
+
visible = visibility !== 'hidden';
|
|
43
|
+
}
|
|
44
|
+
return visible;
|
|
45
|
+
}
|
|
46
|
+
export function svgNodeAndChildrenVisible(svgNode, parentVisible, context) {
|
|
47
|
+
let visible = svgNodeIsVisible(svgNode, parentVisible, context);
|
|
48
|
+
if (svgNode.element.childNodes.length === 0) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
svgNode.children.forEach(child => {
|
|
52
|
+
if (child.isVisible(visible, context)) {
|
|
53
|
+
visible = true;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return visible;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/utils/node.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,MAAM,CAAC,IAAa,EAAE,UAAkB;IACtD,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAA;AAC1F,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAa,EAAE,EAAmC;IAC7E,2DAA2D;IAC3D,MAAM,QAAQ,GAAG,EAAE,CAAA;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EA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,CAAA;IACd,CAAC;IAED,IAAI,OAAO,GAAG,aAAa,CAAA;IAE3B,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;IACnF,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,GAAG,UAAU,KAAK,QAAQ,CAAA;IACnC,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,OAAgB,EAChB,aAAsB,EACtB,OAAgB;IAEhB,IAAI,OAAO,GAAG,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;IAC/D,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC/B,IAAI,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;YACtC,OAAO,GAAG,IAAI,CAAA;QAChB,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parses a comma, sign and/or whitespace separated string of floats and returns
|
|
3
|
+
* the single floats in an array
|
|
4
|
+
*/
|
|
5
|
+
import { ContextColors } from '../context/attributestate';
|
|
6
|
+
import { RGBColor } from './rgbcolor';
|
|
7
|
+
export declare function parseFloats(str: string): number[];
|
|
8
|
+
/**
|
|
9
|
+
* extends RGBColor by rgba colors as RGBColor is not capable of it
|
|
10
|
+
* currentcolor: the color to return if colorString === 'currentcolor'
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseColor(colorString: string, contextColors: ContextColors | null): RGBColor;
|
|
13
|
+
//# sourceMappingURL=parsing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsing.d.ts","sourceRoot":"","sources":["../../src/utils/parsing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAQjD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,IAAI,GAAG,QAAQ,CA4B7F"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RGBColor } from './rgbcolor';
|
|
2
|
+
export function parseFloats(str) {
|
|
3
|
+
const floats = [];
|
|
4
|
+
const regex = /[+-]?(?:(?:\d+\.?\d*)|(?:\d*\.?\d+))(?:[eE][+-]?\d+)?/g;
|
|
5
|
+
let match;
|
|
6
|
+
while ((match = regex.exec(str))) {
|
|
7
|
+
floats.push(parseFloat(match[0]));
|
|
8
|
+
}
|
|
9
|
+
return floats;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* extends RGBColor by rgba colors as RGBColor is not capable of it
|
|
13
|
+
* currentcolor: the color to return if colorString === 'currentcolor'
|
|
14
|
+
*/
|
|
15
|
+
export function parseColor(colorString, contextColors) {
|
|
16
|
+
if (colorString === 'transparent') {
|
|
17
|
+
const transparent = new RGBColor('rgb(0,0,0)');
|
|
18
|
+
transparent.a = 0;
|
|
19
|
+
return transparent;
|
|
20
|
+
}
|
|
21
|
+
if (contextColors && colorString.toLowerCase() === 'currentcolor') {
|
|
22
|
+
return contextColors.color || new RGBColor('rgb(0,0,0)');
|
|
23
|
+
}
|
|
24
|
+
if (contextColors && colorString.toLowerCase() === 'context-stroke') {
|
|
25
|
+
return contextColors.contextStroke || new RGBColor('rgb(0,0,0)');
|
|
26
|
+
}
|
|
27
|
+
if (contextColors && colorString.toLowerCase() === 'context-fill') {
|
|
28
|
+
return contextColors.contextFill || new RGBColor('rgb(0,0,0)');
|
|
29
|
+
}
|
|
30
|
+
const match = /\s*rgba\(((?:[^,\)]*,){3}[^,\)]*)\)\s*/.exec(colorString);
|
|
31
|
+
if (match) {
|
|
32
|
+
const floats = parseFloats(match[1]);
|
|
33
|
+
const color = new RGBColor('rgb(' + floats.slice(0, 3).join(',') + ')');
|
|
34
|
+
color.a = floats[3];
|
|
35
|
+
return color;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return new RGBColor(colorString);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=parsing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsing.js","sourceRoot":"","sources":["../../src/utils/parsing.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,MAAM,GAAG,EAAE,CAAA;IACjB,MAAM,KAAK,GAAG,wDAAwD,CAAA;IACtE,IAAI,KAAK,CAAA;IACT,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnC,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,WAAmB,EAAE,aAAmC;IACjF,IAAI,WAAW,KAAK,aAAa,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,IAAI,QAAQ,CAAC,YAAY,CAAC,CAAA;QAC9C,WAAW,CAAC,CAAC,GAAG,CAAC,CAAA;QACjB,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,IAAI,aAAa,IAAI,WAAW,CAAC,WAAW,EAAE,KAAK,cAAc,EAAE,CAAC;QAClE,OAAO,aAAa,CAAC,KAAK,IAAI,IAAI,QAAQ,CAAC,YAAY,CAAC,CAAA;IAC1D,CAAC;IAED,IAAI,aAAa,IAAI,WAAW,CAAC,WAAW,EAAE,KAAK,gBAAgB,EAAE,CAAC;QACpE,OAAO,aAAa,CAAC,aAAa,IAAI,IAAI,QAAQ,CAAC,YAAY,CAAC,CAAA;IAClE,CAAC;IAED,IAAI,aAAa,IAAI,WAAW,CAAC,WAAW,EAAE,KAAK,cAAc,EAAE,CAAC;QAClE,OAAO,aAAa,CAAC,WAAW,IAAI,IAAI,QAAQ,CAAC,YAAY,CAAC,CAAA;IAChE,CAAC;IAED,MAAM,KAAK,GAAG,wCAAwC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACxE,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QACpC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;QACvE,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;QACnB,OAAO,KAAK,CAAA;IACd,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAA;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Context } from '../context/context';
|
|
2
|
+
import { Matrix } from 'jspdf';
|
|
3
|
+
export declare class Path {
|
|
4
|
+
segments: Segment[];
|
|
5
|
+
constructor();
|
|
6
|
+
moveTo(x: number, y: number): Path;
|
|
7
|
+
lineTo(x: number, y: number): Path;
|
|
8
|
+
curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): Path;
|
|
9
|
+
close(): Path;
|
|
10
|
+
/**
|
|
11
|
+
* Transforms the path in place
|
|
12
|
+
*/
|
|
13
|
+
transform(matrix: Matrix): void;
|
|
14
|
+
draw(context: Context): void;
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class Segment {
|
|
17
|
+
}
|
|
18
|
+
export declare class MoveTo implements Segment {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
constructor(x: number, y: number);
|
|
22
|
+
}
|
|
23
|
+
export declare class LineTo implements Segment {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
constructor(x: number, y: number);
|
|
27
|
+
}
|
|
28
|
+
export declare class CurveTo implements Segment {
|
|
29
|
+
x1: number;
|
|
30
|
+
y1: number;
|
|
31
|
+
x2: number;
|
|
32
|
+
y2: number;
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
constructor(x1: number, y1: number, x2: number, y2: number, x: number, y: number);
|
|
36
|
+
}
|
|
37
|
+
export declare class Close implements Segment {
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAE9B,qBAAa,IAAI;IACf,QAAQ,EAAE,OAAO,EAAE,CAAA;;IAMnB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAIlC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAIlC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAInF,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAmB/B,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAc7B;AAED,8BAAsB,OAAO;CAAG;AAEhC,qBAAa,MAAO,YAAW,OAAO;IACpC,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;gBACG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;CAIjC;AAED,qBAAa,MAAO,YAAW,OAAO;IACpC,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;gBACG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;CAIjC;AAED,qBAAa,OAAQ,YAAW,OAAO;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;gBACG,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;CAQjF;AAED,qBAAa,KAAM,YAAW,OAAO;CAAG"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { multVecMatrix } from './geometry';
|
|
2
|
+
export class Path {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.segments = [];
|
|
5
|
+
}
|
|
6
|
+
moveTo(x, y) {
|
|
7
|
+
this.segments.push(new MoveTo(x, y));
|
|
8
|
+
return this;
|
|
9
|
+
}
|
|
10
|
+
lineTo(x, y) {
|
|
11
|
+
this.segments.push(new LineTo(x, y));
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
curveTo(x1, y1, x2, y2, x, y) {
|
|
15
|
+
this.segments.push(new CurveTo(x1, y1, x2, y2, x, y));
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
close() {
|
|
19
|
+
this.segments.push(new Close());
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Transforms the path in place
|
|
24
|
+
*/
|
|
25
|
+
transform(matrix) {
|
|
26
|
+
this.segments.forEach(seg => {
|
|
27
|
+
if (seg instanceof MoveTo || seg instanceof LineTo || seg instanceof CurveTo) {
|
|
28
|
+
const p = multVecMatrix([seg.x, seg.y], matrix);
|
|
29
|
+
seg.x = p[0];
|
|
30
|
+
seg.y = p[1];
|
|
31
|
+
}
|
|
32
|
+
if (seg instanceof CurveTo) {
|
|
33
|
+
const p1 = multVecMatrix([seg.x1, seg.y1], matrix);
|
|
34
|
+
const p2 = multVecMatrix([seg.x2, seg.y2], matrix);
|
|
35
|
+
seg.x1 = p1[0];
|
|
36
|
+
seg.y1 = p1[1];
|
|
37
|
+
seg.x2 = p2[0];
|
|
38
|
+
seg.y2 = p2[1];
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
draw(context) {
|
|
43
|
+
const p = context.pdf;
|
|
44
|
+
this.segments.forEach(s => {
|
|
45
|
+
if (s instanceof MoveTo) {
|
|
46
|
+
p.moveTo(s.x, s.y);
|
|
47
|
+
}
|
|
48
|
+
else if (s instanceof LineTo) {
|
|
49
|
+
p.lineTo(s.x, s.y);
|
|
50
|
+
}
|
|
51
|
+
else if (s instanceof CurveTo) {
|
|
52
|
+
p.curveTo(s.x1, s.y1, s.x2, s.y2, s.x, s.y);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
p.close();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export class Segment {
|
|
61
|
+
}
|
|
62
|
+
export class MoveTo {
|
|
63
|
+
constructor(x, y) {
|
|
64
|
+
this.x = x;
|
|
65
|
+
this.y = y;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export class LineTo {
|
|
69
|
+
constructor(x, y) {
|
|
70
|
+
this.x = x;
|
|
71
|
+
this.y = y;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export class CurveTo {
|
|
75
|
+
constructor(x1, y1, x2, y2, x, y) {
|
|
76
|
+
this.x1 = x1;
|
|
77
|
+
this.y1 = y1;
|
|
78
|
+
this.x2 = x2;
|
|
79
|
+
this.y2 = y2;
|
|
80
|
+
this.x = x;
|
|
81
|
+
this.y = y;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export class Close {
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAG1C,MAAM,OAAO,IAAI;IAGf;QACE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;IACpB,CAAC;IAED,MAAM,CAAC,CAAS,EAAE,CAAS;QACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACpC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,CAAS,EAAE,CAAS;QACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACpC,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,CAAS,EAAE,CAAS;QAC1E,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACrD,OAAO,IAAI,CAAA;IAC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I,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;IACZ,CAAC;CACF;AAED,MAAM,OAAO,KAAK;CAAsB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class RGBColor {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
a?: number;
|
|
4
|
+
r: number;
|
|
5
|
+
g: number;
|
|
6
|
+
b: number;
|
|
7
|
+
private readonly simpleColors;
|
|
8
|
+
private colorDefs;
|
|
9
|
+
constructor(colorString?: string);
|
|
10
|
+
toRGB(): string;
|
|
11
|
+
toRGBA(): string;
|
|
12
|
+
toHex(): string;
|
|
13
|
+
getHelpXML(): HTMLUListElement;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=rgbcolor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rgbcolor.d.ts","sourceRoot":"","sources":["../../src/utils/rgbcolor.ts"],"names":[],"mappings":"AACA,qBAAa,QAAQ;IACZ,EAAE,EAAE,OAAO,CAAA;IAEX,CAAC,CAAC,EAAE,MAAM,CAAY;IACtB,CAAC,SAAI;IACL,CAAC,SAAI;IACL,CAAC,SAAI;IAEZ,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgC;IAE7D,OAAO,CAAC,SAAS,CAA6D;gBAElE,WAAW,CAAC,EAAE,MAAM;IA4OhC,KAAK;IAGL,MAAM;IAGN,KAAK;IAWL,UAAU;CAwCX"}
|