frame.image 1.3.4 → 1.3.5
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/Designer.d.ts.map +1 -1
- package/dist/Designer.js +4 -6
- package/dist/Finish.d.ts.map +1 -1
- package/dist/Finish.js +20 -1
- package/dist/Point.d.ts +5 -0
- package/dist/Point.d.ts.map +1 -1
- package/dist/Point.js +11 -0
- package/dist/Polygon.d.ts +15 -0
- package/dist/Polygon.d.ts.map +1 -1
- package/dist/Polygon.js +23 -0
- package/package.json +2 -2
package/dist/Designer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Designer.d.ts","sourceRoot":"","sources":["../src/Designer.tsx"],"names":[],"mappings":"AAaA,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,
|
|
1
|
+
{"version":3,"file":"Designer.d.ts","sourceRoot":"","sources":["../src/Designer.tsx"],"names":[],"mappings":"AAaA,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,2CA2JA"}
|
package/dist/Designer.js
CHANGED
|
@@ -37,8 +37,6 @@ export function Designer(props) {
|
|
|
37
37
|
vertical: 0,
|
|
38
38
|
});
|
|
39
39
|
const [catmullRomPoints, setCatmullRomPoints] = useState(undefined);
|
|
40
|
-
const [SH, setSH] = useState(0);
|
|
41
|
-
const [SL, setSL] = useState(0);
|
|
42
40
|
const styleStates = {
|
|
43
41
|
position: 'absolute',
|
|
44
42
|
top: '50%',
|
|
@@ -72,19 +70,19 @@ export function Designer(props) {
|
|
|
72
70
|
setRotationAngle(0);
|
|
73
71
|
sendCommand(ACTION.RESET);
|
|
74
72
|
};
|
|
75
|
-
function onCloseScaleForm(
|
|
73
|
+
function onCloseScaleForm() {
|
|
76
74
|
// if (cont) {
|
|
77
75
|
// props.command(ACTION.SCALE_FORM);
|
|
78
76
|
// }
|
|
79
77
|
// setShowModalScaleForm(false);
|
|
80
78
|
}
|
|
81
79
|
function handleCloseScaleFormCancel() {
|
|
82
|
-
onCloseScaleForm(
|
|
80
|
+
onCloseScaleForm();
|
|
83
81
|
}
|
|
84
82
|
function handleCloseScaleFormContinue(length, height) {
|
|
85
83
|
currentMachine.context.length = length;
|
|
86
84
|
currentMachine.context.height = height;
|
|
87
|
-
onCloseScaleForm(
|
|
85
|
+
onCloseScaleForm();
|
|
88
86
|
}
|
|
89
87
|
const onClose = (pol) => () => {
|
|
90
88
|
const catmullRomPolygonRT1 = pol.createCatmullRomPoints(128);
|
|
@@ -102,5 +100,5 @@ export function Designer(props) {
|
|
|
102
100
|
flexDirection: 'row',
|
|
103
101
|
alignItems: 'flex-start',
|
|
104
102
|
gap: 2,
|
|
105
|
-
}, children: [_jsx(DrawCanvas, { machine: currentMachine, command: sendCommand, width: width, height: height, status: { status, setStatus }, show: show, axis: { axis, setAxis }, imageUrl: imageUrl, coords: { coords, setCoords }, imageCoords: { imageCoords, setImageCoords }, rotation: { rotationAngle, setRotationAngle }, catmullRomPoints: { catmullRomPoints, setCatmullRomPoints } }), _jsx(ScaleForm, { title: "Apply Scale", currentPoints: currentMachine.context.nrPoints, onCloseCancel: handleCloseScaleFormCancel, onCloseContinue: handleCloseScaleFormContinue, sl:
|
|
103
|
+
}, children: [_jsx(DrawCanvas, { machine: currentMachine, command: sendCommand, width: width, height: height, status: { status, setStatus }, show: show, axis: { axis, setAxis }, imageUrl: imageUrl, coords: { coords, setCoords }, imageCoords: { imageCoords, setImageCoords }, rotation: { rotationAngle, setRotationAngle }, catmullRomPoints: { catmullRomPoints, setCatmullRomPoints } }), _jsx(ScaleForm, { title: "Apply Scale", currentPoints: currentMachine.context.nrPoints, onCloseCancel: handleCloseScaleFormCancel, onCloseContinue: handleCloseScaleFormContinue, sl: 0, sh: 0 })] }), _jsx(Finish, { universeCenter: universeCenter, nrPoints: nrPoints, coords: { coords, setCoords }, onClose: onClose })] }));
|
|
106
104
|
}
|
package/dist/Finish.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Finish.d.ts","sourceRoot":"","sources":["../src/Finish.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,wBAAgB,MAAM,CAAC,KAAK,EAAE;IAC5B,cAAc,EAAE,KAAK,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;CACvC,
|
|
1
|
+
{"version":3,"file":"Finish.d.ts","sourceRoot":"","sources":["../src/Finish.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,wBAAgB,MAAM,CAAC,KAAK,EAAE;IAC5B,cAAc,EAAE,KAAK,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;CACvC,2CAiIA"}
|
package/dist/Finish.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Button } from '@mui/material';
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
+
import { Polygon } from './Polygon';
|
|
4
5
|
import { Point } from './Point';
|
|
5
6
|
export function Finish(props) {
|
|
6
7
|
const [originalCoords, setOriginalCoords] = useState(undefined);
|
|
7
8
|
const styleButton = {
|
|
9
|
+
display: 'flex',
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
gap: 2,
|
|
8
12
|
position: 'absolute',
|
|
9
13
|
top: '78%',
|
|
10
14
|
left: '50%',
|
|
@@ -48,5 +52,20 @@ export function Finish(props) {
|
|
|
48
52
|
setOriginalCoords(undefined);
|
|
49
53
|
}
|
|
50
54
|
};
|
|
51
|
-
return (_jsxs(Box, { id: "boxButtons", sx: styleButton, children: [_jsx(Button, { variant: "contained", disabled: originalCoords !== undefined, onClick: onTransform,
|
|
55
|
+
return (_jsxs(Box, { id: "boxButtons", sx: styleButton, children: [_jsx(Button, { variant: "contained", disabled: originalCoords !== undefined, onClick: onTransform, children: "Start Transformation" }), _jsx(Button, { variant: "contained", disabled: originalCoords === undefined, onClick: onReset, sx: { mr: 2 }, children: "Reset to Original" }), _jsx(Button, { variant: "contained", disabled: originalCoords === undefined, onClick: props.onClose(props.coords.coords), children: "Create RT1" }), _jsx(Button, { variant: "contained", onClick: () => {
|
|
56
|
+
props.coords.coords.save('frame.image.json');
|
|
57
|
+
}, children: "Save Points" }), _jsxs(Button, { variant: "contained", component: "label", children: ["Load Points", _jsx("input", { type: "file", accept: "application/json", hidden: true, onChange: async (e) => {
|
|
58
|
+
const file = e.target.files?.[0];
|
|
59
|
+
if (!file)
|
|
60
|
+
return;
|
|
61
|
+
const text = await file.text();
|
|
62
|
+
try {
|
|
63
|
+
const newPolygon = Polygon.fromJSON(JSON.parse(text));
|
|
64
|
+
props.coords.setCoords(newPolygon);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
alert(`Failed to load points from ${file.name}.`);
|
|
68
|
+
}
|
|
69
|
+
e.target.value = '';
|
|
70
|
+
} })] })] }));
|
|
52
71
|
}
|
package/dist/Point.d.ts
CHANGED
|
@@ -4,8 +4,13 @@ export declare class Point {
|
|
|
4
4
|
private xOrigin;
|
|
5
5
|
private yOrigin;
|
|
6
6
|
static drawBox(context: CanvasRenderingContext2D, p1: Point, p2: Point, color: string): void;
|
|
7
|
+
static fromJSON(json: Point, origin?: Point): Point;
|
|
7
8
|
constructor(x: number, y: number, origin?: Point);
|
|
8
9
|
clone(): Point;
|
|
10
|
+
toJSON(): {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
9
14
|
get X(): number;
|
|
10
15
|
get Y(): number;
|
|
11
16
|
get Origin(): Point;
|
package/dist/Point.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point.d.ts","sourceRoot":"","sources":["../src/Point.ts"],"names":[],"mappings":"AAAA,qBAAa,KAAK;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IAExB,MAAM,CAAC,OAAO,CACZ,OAAO,EAAE,wBAAwB,EACjC,EAAE,EAAE,KAAK,EACT,EAAE,EAAE,KAAK,EACT,KAAK,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"Point.d.ts","sourceRoot":"","sources":["../src/Point.ts"],"names":[],"mappings":"AAAA,qBAAa,KAAK;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IAExB,MAAM,CAAC,OAAO,CACZ,OAAO,EAAE,wBAAwB,EACjC,EAAE,EAAE,KAAK,EACT,EAAE,EAAE,KAAK,EACT,KAAK,EAAE,MAAM;IAaf,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,KAAK;gBAM/B,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK;IAOhD,KAAK,IAAI,KAAK;IAId,MAAM,IAAI;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IAOlC,IAAI,CAAC,WAEJ;IAED,IAAI,CAAC,WAEJ;IAED,IAAI,MAAM,IAAI,KAAK,CAElB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM;IAW/B,IAAI,CACF,OAAO,EAAE,wBAAwB,EACjC,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,EACD,MAAM,SAAI,GACT,IAAI;IAsBP,SAAS,CACP,OAAO,EAAE,wBAAwB,EACjC,KAAK,SAAU,EACf,MAAM,SAAK,EACX,SAAS,SAAI,GACZ,IAAI;IAiBP,QAAQ,CACN,OAAO,EAAE,wBAAwB,EACjC,KAAK,EAAE,KAAK,EACZ,KAAK,SAAU,EACf,SAAS,SAAI,GACZ,IAAI;IASP,OAAO,CAAC,MAAM,SAAI,GAAG,KAAK;CAQ3B"}
|
package/dist/Point.js
CHANGED
|
@@ -9,6 +9,11 @@ export class Point {
|
|
|
9
9
|
context.lineWidth = 3;
|
|
10
10
|
context.strokeRect(p1.X + p1.Origin.X, p1.Y + p1.Origin.Y, p2.X - p1.X, p2.Y - p1.Y);
|
|
11
11
|
}
|
|
12
|
+
static fromJSON(json, origin) {
|
|
13
|
+
const x = json.x;
|
|
14
|
+
const y = json.y;
|
|
15
|
+
return new Point(x, y, origin);
|
|
16
|
+
}
|
|
12
17
|
constructor(x, y, origin) {
|
|
13
18
|
this.xOrigin = origin ? origin.X : 0;
|
|
14
19
|
this.yOrigin = origin ? origin.Y : 0;
|
|
@@ -18,6 +23,12 @@ export class Point {
|
|
|
18
23
|
clone() {
|
|
19
24
|
return new Point(this.X, this.Y, this.Origin);
|
|
20
25
|
}
|
|
26
|
+
toJSON() {
|
|
27
|
+
return {
|
|
28
|
+
x: this.X,
|
|
29
|
+
y: this.Y,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
21
32
|
get X() {
|
|
22
33
|
return this.x;
|
|
23
34
|
}
|
package/dist/Polygon.d.ts
CHANGED
|
@@ -6,8 +6,23 @@ export declare class Polygon {
|
|
|
6
6
|
private xMax;
|
|
7
7
|
private yMin;
|
|
8
8
|
private yMax;
|
|
9
|
+
static fromJSON(json: {
|
|
10
|
+
points: Point[];
|
|
11
|
+
universeCenter: Point;
|
|
12
|
+
}): Polygon;
|
|
9
13
|
constructor(points: Point[], universeCenter: Point);
|
|
10
14
|
clone(): Polygon;
|
|
15
|
+
toJSON(): {
|
|
16
|
+
points: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}[];
|
|
20
|
+
universeCenter: {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
save(file: string): void;
|
|
11
26
|
get Length(): number;
|
|
12
27
|
get Points(): Point[];
|
|
13
28
|
get XYPoints(): {
|
package/dist/Polygon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Polygon.d.ts","sourceRoot":"","sources":["../src/Polygon.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;
|
|
1
|
+
{"version":3,"file":"Polygon.d.ts","sourceRoot":"","sources":["../src/Polygon.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC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AAG,OAAO;IAQ/D,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAU7C,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,OAAO;IAyBjE,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IAYtC,SAAS,IAAI,MAAM;IAuBnB,SAAS,IAAI,MAAM;IAOnB,WAAW,IAAI,MAAM;IASrB,uBAAuB,IAAI,IAAI;IAwB/B,UAAU,CACR,OAAO,EAAE,wBAAwB,EACjC,eAAe,EAAE,OAAO,EACxB,KAAK,SAAW,GACf,IAAI;IAsBP,WAAW,CACT,OAAO,EAAE,wBAAwB,EACjC,KAAK,SAAQ,EACb,YAAY,SAAM,GACjB,IAAI;IAuBP,UAAU,CAAC,OAAO,EAAE,wBAAwB,EAAE,KAAK,SAAU,GAAG,IAAI;CAMrE"}
|
package/dist/Polygon.js
CHANGED
|
@@ -8,6 +8,11 @@ export class Polygon {
|
|
|
8
8
|
xMax;
|
|
9
9
|
yMin;
|
|
10
10
|
yMax;
|
|
11
|
+
static fromJSON(json) {
|
|
12
|
+
const universeCenter = Point.fromJSON(json.universeCenter);
|
|
13
|
+
const points = json.points.map((point) => Point.fromJSON(point, universeCenter));
|
|
14
|
+
return new Polygon(points, universeCenter);
|
|
15
|
+
}
|
|
11
16
|
constructor(points, universeCenter) {
|
|
12
17
|
this.points = points;
|
|
13
18
|
this.xMin = Math.min(...points.map((point) => point.X));
|
|
@@ -20,6 +25,24 @@ export class Polygon {
|
|
|
20
25
|
const clonedPoints = this.points.map((point) => point.clone());
|
|
21
26
|
return new Polygon(clonedPoints, this.universeCenter);
|
|
22
27
|
}
|
|
28
|
+
toJSON() {
|
|
29
|
+
return {
|
|
30
|
+
points: this.points.map((point) => point.toJSON()),
|
|
31
|
+
universeCenter: this.universeCenter.toJSON(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
save(file) {
|
|
35
|
+
const json = JSON.stringify(this.toJSON());
|
|
36
|
+
const blob = new Blob([json], { type: 'application/json' });
|
|
37
|
+
const url = URL.createObjectURL(blob);
|
|
38
|
+
const a = document.createElement('a');
|
|
39
|
+
a.href = url;
|
|
40
|
+
a.download = file;
|
|
41
|
+
document.body.appendChild(a);
|
|
42
|
+
a.click();
|
|
43
|
+
document.body.removeChild(a);
|
|
44
|
+
URL.revokeObjectURL(url);
|
|
45
|
+
}
|
|
23
46
|
get Length() {
|
|
24
47
|
return this.points.length;
|
|
25
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frame.image",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "A React component for drawing a frame on a canvas element.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Christian.Todd@rodenstock.com",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
40
40
|
"eslint-plugin-react-refresh": "^0.4.19",
|
|
41
41
|
"globals": "^16.3.0",
|
|
42
|
-
"typedoc": "^0.28.
|
|
42
|
+
"typedoc": "^0.28.12",
|
|
43
43
|
"typescript": "~5.9.2",
|
|
44
44
|
"typescript-eslint": "^8.41.0",
|
|
45
45
|
"vite": "^7.1.3"
|