abstract-image 13.0.60 → 13.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/CHANGELOG.md +4 -0
- package/README.md +4 -9
- package/lib/__stories__/react-svg-export/example-1.stories.d.ts +2 -2
- package/lib/__stories__/react-svg-export/example-1.stories.d.ts.map +1 -1
- package/lib/__stories__/react-svg-export/example-1.stories.js.map +1 -1
- package/lib/__stories__/svg-export/example-1.stories.d.ts +2 -2
- package/lib/__stories__/svg-export/example-1.stories.d.ts.map +1 -1
- package/lib/__stories__/svg-export/example-1.stories.js.map +1 -1
- package/lib/abstract-image-jsx/index.d.ts +2 -3
- package/lib/abstract-image-jsx/index.d.ts.map +1 -1
- package/lib/abstract-image-jsx/index.js +11 -8
- package/lib/abstract-image-jsx/index.js.map +1 -1
- package/lib/dynamic-image/components.d.ts +1 -1
- package/lib/dynamic-image/components.d.ts.map +1 -1
- package/lib/dynamic-image/components.js +3 -4
- package/lib/dynamic-image/components.js.map +1 -1
- package/lib/dynamic-image/dynamic-image.d.ts.map +1 -1
- package/lib/dynamic-image/dynamic-image.js +3 -7
- package/lib/dynamic-image/dynamic-image.js.map +1 -1
- package/lib/dynamic-image/utils.d.ts +2 -1
- package/lib/dynamic-image/utils.d.ts.map +1 -1
- package/lib/dynamic-image/utils.js.map +1 -1
- package/lib/exporters/dxf2d-export-image.d.ts +3 -2
- package/lib/exporters/dxf2d-export-image.d.ts.map +1 -1
- package/lib/exporters/dxf2d-export-image.js +16 -26
- package/lib/exporters/dxf2d-export-image.js.map +1 -1
- package/lib/exporters/eps-export-image.d.ts +1 -2
- package/lib/exporters/eps-export-image.d.ts.map +1 -1
- package/lib/exporters/eps-export-image.js +6 -29
- package/lib/exporters/eps-export-image.js.map +1 -1
- package/lib/exporters/react-svg-export-image.d.ts.map +1 -1
- package/lib/exporters/react-svg-export-image.js +10 -10
- package/lib/exporters/react-svg-export-image.js.map +1 -1
- package/lib/exporters/svg-export-image.d.ts.map +1 -1
- package/lib/exporters/svg-export-image.js +8 -6
- package/lib/exporters/svg-export-image.js.map +1 -1
- package/lib/model/abstract-image.d.ts +1 -1
- package/lib/model/abstract-image.d.ts.map +1 -1
- package/lib/model/abstract-image.js.map +1 -1
- package/lib/model/color.d.ts.map +1 -1
- package/lib/model/color.js +3 -5
- package/lib/model/color.js.map +1 -1
- package/lib/model/component.d.ts +3 -5
- package/lib/model/component.d.ts.map +1 -1
- package/lib/model/component.js +1 -1
- package/lib/model/component.js.map +1 -1
- package/lib/model/point.js +1 -1
- package/lib/model/size.js +1 -1
- package/package.json +17 -17
- package/src/__stories__/react-svg-export/example-1.stories.tsx +4 -14
- package/src/__stories__/svg-export/example-1.stories.tsx +4 -15
- package/src/abstract-image-jsx/index.ts +27 -32
- package/src/dynamic-image/components.ts +6 -19
- package/src/dynamic-image/dynamic-image.ts +6 -24
- package/src/dynamic-image/utils.ts +7 -5
- package/src/exporters/dxf2d-export-image.ts +26 -69
- package/src/exporters/eps-export-image.ts +19 -31
- package/src/exporters/react-svg-export-image.tsx +26 -51
- package/src/exporters/svg-export-image.ts +11 -16
- package/src/index.ts +1 -1
- package/src/model/abstract-image.ts +2 -7
- package/src/model/color.ts +4 -13
- package/src/model/component.ts +5 -13
- package/src/model/point.ts +1 -1
- package/src/model/size.ts +1 -1
package/src/model/color.ts
CHANGED
|
@@ -10,15 +10,11 @@ export function fromArgb(a: number, r: number, g: number, b: number): Color {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function toString6Hex(color: Color): string {
|
|
13
|
-
return (
|
|
14
|
-
("00" + color.r.toString(16)).substr(-2) +
|
|
15
|
-
("00" + color.g.toString(16)).substr(-2) +
|
|
16
|
-
("00" + color.b.toString(16)).substr(-2)
|
|
17
|
-
);
|
|
13
|
+
return ("00" + color.r.toString(16)).substr(-2) + ("00" + color.g.toString(16)).substr(-2) + ("00" + color.b.toString(16)).substr(-2);
|
|
18
14
|
}
|
|
19
15
|
|
|
20
16
|
export function fromString(s: string): Color | undefined {
|
|
21
|
-
if (s
|
|
17
|
+
if (s?.length !== 9 || !s.startsWith("#")) {
|
|
22
18
|
return undefined;
|
|
23
19
|
}
|
|
24
20
|
|
|
@@ -27,7 +23,7 @@ export function fromString(s: string): Color | undefined {
|
|
|
27
23
|
const g: number = parseInt(s.substring(5, 5 + 2), 16);
|
|
28
24
|
const b: number = parseInt(s.substring(7, 7 + 2), 16);
|
|
29
25
|
|
|
30
|
-
if (isNaN(a) || isNaN(r) || isNaN(g) || isNaN(b)) {
|
|
26
|
+
if (Number.isNaN(a) || Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
31
27
|
return undefined;
|
|
32
28
|
}
|
|
33
29
|
|
|
@@ -37,12 +33,7 @@ export function fromString(s: string): Color | undefined {
|
|
|
37
33
|
export function fromString2(s: string, def?: Color): Color {
|
|
38
34
|
if (s.startsWith("#")) {
|
|
39
35
|
if (s.length === 9) {
|
|
40
|
-
return fromArgb(
|
|
41
|
-
parseInt(s.slice(1, 3), 16),
|
|
42
|
-
parseInt(s.slice(3, 5), 16),
|
|
43
|
-
parseInt(s.slice(5, 7), 16),
|
|
44
|
-
parseInt(s.slice(7, 9), 16)
|
|
45
|
-
);
|
|
36
|
+
return fromArgb(parseInt(s.slice(1, 3), 16), parseInt(s.slice(3, 5), 16), parseInt(s.slice(5, 7), 16), parseInt(s.slice(7, 9), 16));
|
|
46
37
|
}
|
|
47
38
|
return fromArgb(255, parseInt(s.slice(1, 3), 16), parseInt(s.slice(3, 5), 16), parseInt(s.slice(5, 7), 16));
|
|
48
39
|
}
|
package/src/model/component.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { createPoint } from "./point.js";
|
|
1
|
+
import type { AbstractImage } from "./abstract-image.js";
|
|
3
2
|
import type { Color } from "./color.js";
|
|
4
3
|
import type { DashStyle } from "./dash-style.js";
|
|
5
4
|
import { solidLine } from "./dash-style.js";
|
|
6
|
-
import type {
|
|
5
|
+
import type { Point } from "./point.js";
|
|
6
|
+
import { createPoint } from "./point.js";
|
|
7
7
|
import type { Size } from "./size.js";
|
|
8
8
|
|
|
9
9
|
export type Component = BinaryImage | Ellipse | Line | PolyLine | Polygon | Rectangle | Text | SubImage | Group;
|
|
@@ -22,9 +22,7 @@ export function createGroup(name: string, children: Array<Component>): Group {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Embed a foreign binary image in any suported format.
|
|
27
|
-
*/
|
|
25
|
+
/** Embed a foreign binary image in any suported format. */
|
|
28
26
|
|
|
29
27
|
export type BinaryFormat = "svg" | "png" | "dxf";
|
|
30
28
|
|
|
@@ -49,13 +47,7 @@ export interface ImageUrl {
|
|
|
49
47
|
readonly url: string;
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
export function createBinaryImage(
|
|
53
|
-
topLeft: Point,
|
|
54
|
-
bottomRight: Point,
|
|
55
|
-
format: BinaryFormat,
|
|
56
|
-
data: ImageData,
|
|
57
|
-
id?: string
|
|
58
|
-
): BinaryImage {
|
|
50
|
+
export function createBinaryImage(topLeft: Point, bottomRight: Point, format: BinaryFormat, data: ImageData, id?: string): BinaryImage {
|
|
59
51
|
return {
|
|
60
52
|
type: "binaryimage",
|
|
61
53
|
topLeft: topLeft,
|
package/src/model/point.ts
CHANGED