frame.image 1.2.1 → 1.3.1
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/App.d.ts.map +1 -1
- package/dist/App.js +1 -150
- package/dist/Center.js +1 -1
- package/dist/DrawCanvas.d.ts.map +1 -1
- package/dist/DrawCanvas.js +0 -2
- package/dist/ImageHandler.js +1 -1
- package/dist/ModalDesigner.d.ts +0 -13
- package/dist/ModalDesigner.d.ts.map +1 -1
- package/dist/ModalDesigner.js +48 -15
- package/dist/Scaling.js +1 -1
- package/dist/ShowOptions.js +1 -1
- package/dist/States.d.ts.map +1 -1
- package/dist/States.js +4 -11
- package/package.json +8 -8
package/dist/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AACA,OAAO,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AACA,OAAO,WAAW,CAAC;AAUnB,iBAAS,GAAG,4CAmHX;AAED,eAAe,GAAG,CAAC"}
|
package/dist/App.js
CHANGED
|
@@ -3,31 +3,21 @@ import { useState } from 'react';
|
|
|
3
3
|
import './App.css';
|
|
4
4
|
import { Point } from './Point';
|
|
5
5
|
import { Lens } from './Lens';
|
|
6
|
-
import { ShowOptions } from './ShowOptions';
|
|
7
6
|
import { Scaling } from './Scaling';
|
|
8
|
-
import { States } from './States';
|
|
9
|
-
import { ACTION, machine, STATUS } from 'frame.statemachine';
|
|
10
|
-
import { useMachine } from 'react-robot';
|
|
11
7
|
import { Polygon } from './Polygon';
|
|
12
8
|
import { Center } from './Center';
|
|
13
9
|
import { ImageHandler } from './ImageHandler';
|
|
14
10
|
import { ModalDesigner } from './ModalDesigner';
|
|
15
11
|
function App() {
|
|
16
|
-
const [currentMachine, sendCommand] = useMachine(machine);
|
|
17
12
|
const width = 1000;
|
|
18
13
|
const height = 600;
|
|
19
|
-
const nrPoints = 128;
|
|
20
14
|
const universeCenter = new Point(width / 2, height / 2);
|
|
21
15
|
const offset = 0;
|
|
22
|
-
const [dataUrl, setDataUrl] = useState(undefined);
|
|
23
16
|
const [modalDesigner, setModalDesigner] = useState(false);
|
|
24
|
-
const [axis, setAxis] = useState({});
|
|
25
17
|
const [imageCoords, setImageCoords] = useState({
|
|
26
18
|
horizontal: 0,
|
|
27
19
|
vertical: 0,
|
|
28
20
|
});
|
|
29
|
-
const [rotationAngle, setRotationAngle] = useState(0);
|
|
30
|
-
const [catmullRomPolygon, setCatmullRomPoints] = useState(undefined);
|
|
31
21
|
const [coords, setCoords] = useState(new Polygon([
|
|
32
22
|
// new Point(255.515625, 21.15625, universeCenter),
|
|
33
23
|
// new Point(225.515625, 94.15625, universeCenter),
|
|
@@ -79,148 +69,12 @@ function App() {
|
|
|
79
69
|
// new Point(249.5, -66, universeCenter),
|
|
80
70
|
// new Point(253.5, -29, universeCenter),
|
|
81
71
|
], universeCenter));
|
|
82
|
-
const [previousCenter, setPreviousCenter] = useState(new Point(0, 0, universeCenter));
|
|
83
|
-
const [isTransformed, setIsTransformed] = useState(false);
|
|
84
72
|
const [scaledSL, setScaledSL] = useState(undefined);
|
|
85
73
|
const [scaledSH, setScaledSH] = useState(undefined);
|
|
86
|
-
const [show, setShow] = useState({
|
|
87
|
-
catmullRomPoints: true,
|
|
88
|
-
catmullRom: true,
|
|
89
|
-
catmullRomCenter: true,
|
|
90
|
-
points: true,
|
|
91
|
-
polygon: false,
|
|
92
|
-
center: false,
|
|
93
|
-
box: false,
|
|
94
|
-
scaledBox: true,
|
|
95
|
-
background: true,
|
|
96
|
-
});
|
|
97
|
-
const [status, setStatus] = useState(STATUS.START);
|
|
98
74
|
// ----------------------------------------------------------------------
|
|
99
|
-
const onClickReset = () => {
|
|
100
|
-
setCoords(new Polygon([], universeCenter));
|
|
101
|
-
setCatmullRomPoints(undefined);
|
|
102
|
-
setDataUrl(undefined);
|
|
103
|
-
setAxis({ x1: undefined, x2: undefined });
|
|
104
|
-
setRotationAngle(0);
|
|
105
|
-
sendCommand(ACTION.RESET);
|
|
106
|
-
};
|
|
107
|
-
const onTransformToCenter = () => {
|
|
108
|
-
const transformed = coords.transform(coords.Center.x, coords.Center.y, universeCenter);
|
|
109
|
-
setPreviousCenter(coords.Center);
|
|
110
|
-
setCoords(transformed);
|
|
111
|
-
setIsTransformed(true);
|
|
112
|
-
};
|
|
113
|
-
const onRetransformBackToCenter = () => {
|
|
114
|
-
console.log(`onRetransformBackToCenter: [${previousCenter.X}, ${previousCenter.Y}]`);
|
|
115
|
-
console.log(`point 1: [${coords.at(0).X}, ${coords.at(0).Y}]`);
|
|
116
|
-
const transformed = coords.transform(-previousCenter.X, -previousCenter.Y, universeCenter);
|
|
117
|
-
console.log(`point 1 transformed: [${transformed.at(0).X}, ${transformed.at(0).Y}]`);
|
|
118
|
-
setCoords(transformed);
|
|
119
|
-
setIsTransformed(false);
|
|
120
|
-
};
|
|
121
|
-
const onTransformAgainToCenter = () => {
|
|
122
|
-
const center = coords.Center;
|
|
123
|
-
console.log(`onTransformAgainToCenter: [${center?.X}, ${center?.Y}]`);
|
|
124
|
-
const transformed = coords.transform(coords.Center.x, coords.Center.y, universeCenter);
|
|
125
|
-
setCoords(transformed);
|
|
126
|
-
};
|
|
127
|
-
const refine = (coordinates) => {
|
|
128
|
-
// 1) Transform to Center
|
|
129
|
-
const prevCenter = coordinates.Center;
|
|
130
|
-
let transformed = coordinates.transform(prevCenter.x, prevCenter.y, universeCenter);
|
|
131
|
-
// 2) Convert to Spline
|
|
132
|
-
const xCenter = (coordinates.XMax + coordinates.XMin) / 2;
|
|
133
|
-
const yCenter = (coordinates.YMax + coordinates.YMin) / 2;
|
|
134
|
-
const catmullRomPolygon = transformed.createCatmullRomPoints(nrPoints, new Point(xCenter, yCenter));
|
|
135
|
-
// catmullRomPolygon.assertEquiDistantAngles();
|
|
136
|
-
setCatmullRomPoints(catmullRomPolygon);
|
|
137
|
-
// catmullRomPolygon.assertEquiDistantAngles();
|
|
138
|
-
// 3) Reset Spline and adjust Points to new origin
|
|
139
|
-
if (catmullRomPolygon) {
|
|
140
|
-
setCoords(catmullRomPolygon);
|
|
141
|
-
// catmullRomPolygon.assertEquiDistantAngles();
|
|
142
|
-
}
|
|
143
|
-
setCatmullRomPoints(undefined);
|
|
144
|
-
const dist = Math.hypot(catmullRomPolygon.Center.X, catmullRomPolygon.Center.Y);
|
|
145
|
-
// 4) Retransform back to Center
|
|
146
|
-
transformed = catmullRomPolygon.transform(-prevCenter.X, -prevCenter.Y, universeCenter);
|
|
147
|
-
return { coords: transformed, dist };
|
|
148
|
-
};
|
|
149
|
-
const onStartTransformation = () => {
|
|
150
|
-
let distance = 1000;
|
|
151
|
-
let coordinates = coords;
|
|
152
|
-
while (distance > 0.01) {
|
|
153
|
-
// find the point with the minimum distance to the center
|
|
154
|
-
const { dist, coords } = refine(coordinates);
|
|
155
|
-
distance = dist;
|
|
156
|
-
coordinates = coords;
|
|
157
|
-
}
|
|
158
|
-
setCoords(coordinates);
|
|
159
|
-
};
|
|
160
|
-
const onConvertToSpline = () => {
|
|
161
|
-
console.log(`onClick`);
|
|
162
|
-
// coords.forEach((point, index) => {
|
|
163
|
-
// console.log(
|
|
164
|
-
// `coord ${index}: [${point.x}, ${point.y}] -> ${point.Radius}`
|
|
165
|
-
// );
|
|
166
|
-
// });
|
|
167
|
-
console.log(`---------------------------------------------------`);
|
|
168
|
-
const xMax = coords.XMax;
|
|
169
|
-
const xMin = coords.XMin;
|
|
170
|
-
const yMax = coords.YMax;
|
|
171
|
-
const yMin = coords.YMin;
|
|
172
|
-
console.log(`xMax: ${xMax}, xMin: ${xMin}`);
|
|
173
|
-
console.log(`yMax: ${yMax}, yMin: ${yMin}`);
|
|
174
|
-
console.log(`x extension: ${xMax - xMin}`);
|
|
175
|
-
console.log(`y extension: ${yMax - yMin}`);
|
|
176
|
-
const xCenter = (xMax + xMin) / 2;
|
|
177
|
-
const yCenter = (yMax + yMin) / 2;
|
|
178
|
-
console.log(`x center: ${xCenter}`);
|
|
179
|
-
console.log(`y center: ${yCenter}`);
|
|
180
|
-
console.log(`---------------------------------------------------`);
|
|
181
|
-
const catmullRomPolygon = coords.createCatmullRomPoints(nrPoints, new Point(xCenter, yCenter));
|
|
182
|
-
catmullRomPolygon.assertEquiDistantAngles();
|
|
183
|
-
// setCoords(pointArray);
|
|
184
|
-
setCatmullRomPoints(catmullRomPolygon);
|
|
185
|
-
catmullRomPolygon.assertEquiDistantAngles();
|
|
186
|
-
console.log(`spline has been created with equidistant angles`);
|
|
187
|
-
// console.log(`catmull rt1: ${rt1}`);
|
|
188
|
-
};
|
|
189
|
-
const onCreateRT1 = () => {
|
|
190
|
-
const catmullRomPolygon = coords.createCatmullRomPoints(128);
|
|
191
|
-
catmullRomPolygon.assertEquiDistantAngles();
|
|
192
|
-
const rt1 = catmullRomPolygon.createRT1();
|
|
193
|
-
setCoords(catmullRomPolygon);
|
|
194
|
-
console.log(`RT1: ${rt1}`);
|
|
195
|
-
};
|
|
196
75
|
const onOpenModalDesigner = () => {
|
|
197
76
|
setModalDesigner(true);
|
|
198
77
|
};
|
|
199
|
-
const onResetSplineToPoints = () => {
|
|
200
|
-
console.log(`reset spline to points`);
|
|
201
|
-
if (catmullRomPolygon) {
|
|
202
|
-
const center = catmullRomPolygon.Center;
|
|
203
|
-
console.log(`catmull center: [${center.X}, ${center.Y}]`);
|
|
204
|
-
// // now transform the points from the Catmull-Rom polygon
|
|
205
|
-
// const transformedPolygon = catmullRomPolygon.transform(
|
|
206
|
-
// center.X,
|
|
207
|
-
// center.Y,
|
|
208
|
-
// universeCenter
|
|
209
|
-
// );
|
|
210
|
-
// const newPointArray = transformedPolygon.Points.map((point, index) => {
|
|
211
|
-
// const currentPoint = new Point(
|
|
212
|
-
// point.X + center.X,
|
|
213
|
-
// point.Y + center.Y,
|
|
214
|
-
// universeCenter
|
|
215
|
-
// );
|
|
216
|
-
// return currentPoint;
|
|
217
|
-
// });
|
|
218
|
-
// setCoords(new Polygon(newPointArray, universeCenter));
|
|
219
|
-
setCoords(catmullRomPolygon);
|
|
220
|
-
catmullRomPolygon.assertEquiDistantAngles();
|
|
221
|
-
}
|
|
222
|
-
setCatmullRomPoints(undefined);
|
|
223
|
-
};
|
|
224
78
|
function onScale(sl, sh) {
|
|
225
79
|
console.log(`now it's time to scale`, sl, sh);
|
|
226
80
|
const extensions = Lens.getExtensions(coords.XYPoints);
|
|
@@ -228,9 +82,6 @@ function App() {
|
|
|
228
82
|
const shFactor = sh / extensions.y.extension;
|
|
229
83
|
setCoords(coords.scale(slFactor, shFactor));
|
|
230
84
|
}
|
|
231
|
-
return (_jsxs(_Fragment, { children: [_jsx("h3", { children: "frame.image" }), _jsx(
|
|
232
|
-
catmullRomPoints: catmullRomPolygon,
|
|
233
|
-
setCatmullRomPoints,
|
|
234
|
-
} })] }));
|
|
85
|
+
return (_jsxs(_Fragment, { children: [_jsx("h3", { children: "frame.image" }), _jsx(Scaling, { SL: scaledSL, setSL: setScaledSL, SH: scaledSH, setSH: setScaledSH, onScale: onScale }), _jsx(ImageHandler, { imageCoords: { imageCoords, setImageCoords } }), _jsx(Center, { coords: coords }), _jsx("button", { onClick: onOpenModalDesigner, children: "Designer" }), _jsx(ModalDesigner, { isOpen: modalDesigner, onClose: () => setModalDesigner(false) })] }));
|
|
235
86
|
}
|
|
236
87
|
export default App;
|
package/dist/Center.js
CHANGED
|
@@ -16,7 +16,7 @@ export function Center(props) {
|
|
|
16
16
|
? Math.round(props.coords.YMax * 1000) / 1000
|
|
17
17
|
: 1000; //'∞';
|
|
18
18
|
const radius = Math.round(Math.sqrt(x * x + y * y) * 1000) / 1000;
|
|
19
|
-
return (_jsx("div", { children: _jsxs("div", { style: {
|
|
19
|
+
return (_jsx("div", { id: "idCenter", children: _jsxs("div", { style: {
|
|
20
20
|
display: 'flex',
|
|
21
21
|
gap: '1rem',
|
|
22
22
|
justifyContent: 'center',
|
package/dist/DrawCanvas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawCanvas.d.ts","sourceRoot":"","sources":["../src/DrawCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAqD,MAAM,OAAO,CAAC;AAG/E,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,WAAW,EACX,UAAU,
|
|
1
|
+
{"version":3,"file":"DrawCanvas.d.ts","sourceRoot":"","sources":["../src/DrawCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAqD,MAAM,OAAO,CAAC;AAG/E,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,WAAW,EACX,UAAU,EACV,aAAa,EACb,KAAK,EACL,WAAW,EACZ,MAAM,SAAS,CAAC;AAIjB,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAChC,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;IACpB,gBAAgB,EAAE,qBAAqB,CAAC;IACxC,WAAW,EAAE,UAAU,CAAC;IACxB,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CA6fd"}
|
package/dist/DrawCanvas.js
CHANGED
|
@@ -315,14 +315,12 @@ export function DrawCanvas(props) {
|
|
|
315
315
|
break;
|
|
316
316
|
default: {
|
|
317
317
|
canvas.style.cursor = isDragging ? 'grabbing' : 'default';
|
|
318
|
-
const minIndex = props.coords.coords.findMinDistancePoint(point);
|
|
319
318
|
break;
|
|
320
319
|
}
|
|
321
320
|
}
|
|
322
321
|
}, [
|
|
323
322
|
getCurrentPoint,
|
|
324
323
|
props.axis.axis.x1,
|
|
325
|
-
props.coords.coords,
|
|
326
324
|
props.machine.name,
|
|
327
325
|
props.imageCoords,
|
|
328
326
|
isDragging,
|
package/dist/ImageHandler.js
CHANGED
|
@@ -31,5 +31,5 @@ export function ImageHandler(props) {
|
|
|
31
31
|
}));
|
|
32
32
|
setHorizontal((prev) => prev + 10);
|
|
33
33
|
};
|
|
34
|
-
return (_jsxs("div", { children: [_jsxs("h4", { style: { display: 'inline', marginRight: '16px' }, children: ["Image Coordinates: [", horizontal, ", ", vertical, "]"] }), _jsx("button", { onClick: onLeft, children: "left" }), _jsx("button", { onClick: onRight, children: "right" }), _jsx("button", { onClick: onUp, children: "up" }), _jsx("button", { onClick: onDown, children: "down" })] }));
|
|
34
|
+
return (_jsxs("div", { id: "idImageHandler", children: [_jsxs("h4", { style: { display: 'inline', marginRight: '16px' }, children: ["Image Coordinates: [", horizontal, ", ", vertical, "]"] }), _jsx("button", { onClick: onLeft, children: "left" }), _jsx("button", { onClick: onRight, children: "right" }), _jsx("button", { onClick: onUp, children: "up" }), _jsx("button", { onClick: onDown, children: "down" })] }));
|
|
35
35
|
}
|
package/dist/ModalDesigner.d.ts
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import { TAxisHook, TCatmullRomPointsHook, TCoordsHook, TImageHook, TRotationHook, TShowHook, TStatusHook } from './types';
|
|
2
1
|
export declare function ModalDesigner(props: {
|
|
3
2
|
isOpen: boolean;
|
|
4
3
|
onClose: () => void;
|
|
5
|
-
machine: any;
|
|
6
|
-
command: any;
|
|
7
|
-
onClickReset: () => void;
|
|
8
|
-
setDataUrl: (dataUrl: string) => void;
|
|
9
|
-
coords: TCoordsHook;
|
|
10
|
-
status: TStatusHook;
|
|
11
|
-
show: TShowHook;
|
|
12
|
-
axis: TAxisHook;
|
|
13
|
-
imageUrl?: string;
|
|
14
|
-
imageCoords: TImageHook;
|
|
15
|
-
rotation: TRotationHook;
|
|
16
|
-
catmullRomPoints: TCatmullRomPointsHook;
|
|
17
4
|
}): import("react/jsx-runtime").JSX.Element;
|
|
18
5
|
//# sourceMappingURL=ModalDesigner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalDesigner.d.ts","sourceRoot":"","sources":["../src/ModalDesigner.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ModalDesigner.d.ts","sourceRoot":"","sources":["../src/ModalDesigner.tsx"],"names":[],"mappings":"AAiDA,wBAAgB,aAAa,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,2CA4N5E"}
|
package/dist/ModalDesigner.js
CHANGED
|
@@ -2,10 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Modal, Box, Button } from '@mui/material';
|
|
3
3
|
import { States } from './States';
|
|
4
4
|
import { DrawCanvas } from './DrawCanvas';
|
|
5
|
+
import { Polygon } from './Polygon';
|
|
5
6
|
import { Point } from './Point';
|
|
6
7
|
import { ShowOptions } from './ShowOptions';
|
|
7
8
|
import { ScaleForm } from './ScaleForm';
|
|
8
9
|
import { useEffect, useState } from 'react';
|
|
10
|
+
import { useMachine } from 'react-robot';
|
|
11
|
+
import { ACTION, machine, STATUS } from 'frame.statemachine';
|
|
9
12
|
const width = 600;
|
|
10
13
|
const height = 400;
|
|
11
14
|
const styleStates = {
|
|
@@ -40,11 +43,33 @@ const styleButton = {
|
|
|
40
43
|
transform: 'translate(-50%, -50%)',
|
|
41
44
|
};
|
|
42
45
|
export function ModalDesigner(props) {
|
|
46
|
+
const [currentMachine, sendCommand] = useMachine(machine);
|
|
47
|
+
const nrPoints = 128;
|
|
48
|
+
const universeCenter = new Point(width / 2, height / 2);
|
|
43
49
|
const [originalCoords, setOriginalCoords] = useState(undefined);
|
|
50
|
+
const [coords, setCoords] = useState(new Polygon([], universeCenter));
|
|
51
|
+
const [axis, setAxis] = useState({});
|
|
52
|
+
const [rotationAngle, setRotationAngle] = useState(0);
|
|
53
|
+
const [imageCoords, setImageCoords] = useState({
|
|
54
|
+
horizontal: 0,
|
|
55
|
+
vertical: 0,
|
|
56
|
+
});
|
|
57
|
+
const [imageUrl, setDataUrl] = useState(undefined);
|
|
58
|
+
const [status, setStatus] = useState(STATUS.START);
|
|
59
|
+
const [show, setShow] = useState({
|
|
60
|
+
catmullRomPoints: true,
|
|
61
|
+
catmullRom: true,
|
|
62
|
+
catmullRomCenter: true,
|
|
63
|
+
points: true,
|
|
64
|
+
polygon: false,
|
|
65
|
+
center: false,
|
|
66
|
+
box: false,
|
|
67
|
+
scaledBox: true,
|
|
68
|
+
background: true,
|
|
69
|
+
});
|
|
70
|
+
const [catmullRomPoints, setCatmullRomPoints] = useState(undefined);
|
|
44
71
|
const [SH, setSH] = useState(0);
|
|
45
72
|
const [SL, setSL] = useState(0);
|
|
46
|
-
const nrPoints = 128;
|
|
47
|
-
const universeCenter = new Point(width / 2, height / 2);
|
|
48
73
|
function onCloseScaleForm(cont = true) {
|
|
49
74
|
// if (cont) {
|
|
50
75
|
// props.command(ACTION.SCALE_FORM);
|
|
@@ -55,8 +80,8 @@ export function ModalDesigner(props) {
|
|
|
55
80
|
onCloseScaleForm(false);
|
|
56
81
|
}
|
|
57
82
|
function handleCloseScaleFormContinue(length, height) {
|
|
58
|
-
|
|
59
|
-
|
|
83
|
+
currentMachine.context.length = length;
|
|
84
|
+
currentMachine.context.height = height;
|
|
60
85
|
onCloseScaleForm(true);
|
|
61
86
|
}
|
|
62
87
|
const refine = (coordinates) => {
|
|
@@ -78,42 +103,50 @@ export function ModalDesigner(props) {
|
|
|
78
103
|
transformed = catmullRomPolygon.transform(-prevCenter.X, -prevCenter.Y, universeCenter);
|
|
79
104
|
return { coords: transformed, dist };
|
|
80
105
|
};
|
|
106
|
+
const onClickReset = () => {
|
|
107
|
+
setCoords(new Polygon([], universeCenter));
|
|
108
|
+
// setCatmullRomPoints(undefined);
|
|
109
|
+
setDataUrl(undefined);
|
|
110
|
+
setAxis({ x1: undefined, x2: undefined });
|
|
111
|
+
setRotationAngle(0);
|
|
112
|
+
sendCommand(ACTION.RESET);
|
|
113
|
+
};
|
|
81
114
|
const onReset = () => {
|
|
82
115
|
if (originalCoords) {
|
|
83
|
-
|
|
116
|
+
setCoords(originalCoords);
|
|
84
117
|
setOriginalCoords(undefined);
|
|
85
118
|
}
|
|
86
119
|
};
|
|
87
120
|
const onTransform = () => {
|
|
88
121
|
let distance = 1000;
|
|
89
|
-
let coordinates =
|
|
90
|
-
setOriginalCoords(
|
|
122
|
+
let coordinates = coords;
|
|
123
|
+
setOriginalCoords(coords);
|
|
91
124
|
while (distance > 0.01) {
|
|
92
125
|
// find the point with the minimum distance to the center
|
|
93
126
|
const { dist, coords } = refine(coordinates);
|
|
94
127
|
distance = dist;
|
|
95
128
|
coordinates = coords;
|
|
96
129
|
}
|
|
97
|
-
|
|
130
|
+
setCoords(coordinates);
|
|
98
131
|
console.log(`ready`);
|
|
99
132
|
};
|
|
100
133
|
const onCreateRT1 = () => {
|
|
101
|
-
const catmullRomPolygon =
|
|
134
|
+
const catmullRomPolygon = coords.createCatmullRomPoints(128);
|
|
102
135
|
catmullRomPolygon.assertEquiDistantAngles();
|
|
103
136
|
const rt1 = catmullRomPolygon.createRT1();
|
|
104
|
-
|
|
137
|
+
setCoords(catmullRomPolygon);
|
|
105
138
|
console.log(`RT1: ${rt1}`);
|
|
106
139
|
props.onClose();
|
|
107
140
|
};
|
|
108
141
|
useEffect(() => {
|
|
109
|
-
setSH(
|
|
110
|
-
setSL(
|
|
111
|
-
}, [
|
|
112
|
-
return (_jsx(Modal, { open: props.isOpen, onClose: props.onClose, "aria-labelledby": "modal-title", "aria-describedby": "modal-description", children: _jsxs("div", { children: [_jsxs(Box, { id: "boxStates", sx: styleStates, display: "flex", flexDirection: "column", gap: 2, children: [_jsx(States, { machine:
|
|
142
|
+
setSH(coords.YMax - coords.YMin);
|
|
143
|
+
setSL(coords.XMax - coords.XMin);
|
|
144
|
+
}, [coords]);
|
|
145
|
+
return (_jsx(Modal, { open: props.isOpen, onClose: props.onClose, "aria-labelledby": "modal-title", "aria-describedby": "modal-description", children: _jsxs("div", { children: [_jsxs(Box, { id: "boxStates", sx: styleStates, display: "flex", flexDirection: "column", gap: 2, children: [_jsx(States, { machine: currentMachine, command: sendCommand, onClickReset: onClickReset, setDataUrl: setDataUrl, coords: { coords, setCoords } }), _jsx(ShowOptions, { show: show, setShow: setShow })] }), _jsxs(Box, { id: "boxCanvas", sx: {
|
|
113
146
|
...styleCanvas,
|
|
114
147
|
display: 'flex',
|
|
115
148
|
flexDirection: 'row',
|
|
116
149
|
alignItems: 'flex-start',
|
|
117
150
|
gap: 2,
|
|
118
|
-
}, children: [_jsx(DrawCanvas, { machine:
|
|
151
|
+
}, 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: SL, sh: SH })] }), _jsxs(Box, { id: "boxButtons", sx: styleButton, children: [_jsx(Button, { variant: "contained", disabled: originalCoords !== undefined, onClick: onTransform, sx: { mr: 2 }, 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: onCreateRT1, children: "Create RT1" })] })] }) }));
|
|
119
152
|
}
|
package/dist/Scaling.js
CHANGED
|
@@ -15,5 +15,5 @@ export function Scaling(props) {
|
|
|
15
15
|
function onConfirmSL() {
|
|
16
16
|
props.onScale(props.SL ?? 0, props.SH ?? 0);
|
|
17
17
|
}
|
|
18
|
-
return (_jsxs("div", { style: { margin: '16px 0' }, children: [_jsxs("label", { children: ["Length:", _jsx("input", { type: "number", min: "0", step: "any", placeholder: "Enter length", style: { width: 120 }, onChange: onChangeLength })] }), _jsxs("label", { children: ["Height:", _jsx("input", { type: "number", min: "0", step: "any", placeholder: "Enter height", style: { width: 120 }, onChange: onChangeHeight })] }), _jsx("button", { onClick: onConfirmSL, children: "Confirm SL and SH" })] }));
|
|
18
|
+
return (_jsxs("div", { id: "idScaling", style: { margin: '16px 0' }, children: [_jsxs("label", { children: ["Length:", _jsx("input", { type: "number", min: "0", step: "any", placeholder: "Enter length", style: { width: 120 }, onChange: onChangeLength })] }), _jsxs("label", { children: ["Height:", _jsx("input", { type: "number", min: "0", step: "any", placeholder: "Enter height", style: { width: 120 }, onChange: onChangeHeight })] }), _jsx("button", { onClick: onConfirmSL, children: "Confirm SL and SH" })] }));
|
|
19
19
|
}
|
package/dist/ShowOptions.js
CHANGED
|
@@ -17,7 +17,7 @@ export function ShowOptions(props) {
|
|
|
17
17
|
const handleCheckboxCatmullRomCenterChange = handleCheckboxChange('catmullRomCenter');
|
|
18
18
|
const handleCheckboxCatmullRomPointsChange = handleCheckboxChange('catmullRomPoints');
|
|
19
19
|
const handleCheckboxCatmullRomChange = handleCheckboxChange('catmullRom');
|
|
20
|
-
return (_jsxs("div", { children: [_jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: props.show.background, onChange: (e) => handleCheckboxBackgroundChange(e) }), "Background"] }), _jsxs("div", { style: {
|
|
20
|
+
return (_jsxs("div", { id: "idShowOptions", children: [_jsxs("label", { children: [_jsx("input", { type: "checkbox", checked: props.show.background, onChange: (e) => handleCheckboxBackgroundChange(e) }), "Background"] }), _jsxs("div", { style: {
|
|
21
21
|
background: 'lightgreen',
|
|
22
22
|
padding: '4px',
|
|
23
23
|
borderRadius: '4px',
|
package/dist/States.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"States.d.ts","sourceRoot":"","sources":["../src/States.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,GAAG,EAAoB,MAAM,OAAO,CAAC;AAM9C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,wBAAgB,MAAM,CAAC,KAAK,EAAE;IAC5B,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;IACb,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,WAAW,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"States.d.ts","sourceRoot":"","sources":["../src/States.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,GAAG,EAAoB,MAAM,OAAO,CAAC;AAM9C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,wBAAgB,MAAM,CAAC,KAAK,EAAE;IAC5B,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;IACb,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,WAAW,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAwLd"}
|
package/dist/States.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Input } from '@mui/material';
|
|
3
3
|
import { State, ACTION, StateModal, STATUS, getValidActions, } from 'frame.statemachine';
|
|
4
4
|
import { useRef, useState } from 'react';
|
|
@@ -13,10 +13,7 @@ export function States(props) {
|
|
|
13
13
|
const handleButtonClick = () => {
|
|
14
14
|
fileInputRef.current?.click();
|
|
15
15
|
};
|
|
16
|
-
function
|
|
17
|
-
console.log(`has been clicked: ${action}`);
|
|
18
|
-
}
|
|
19
|
-
function onClickReset(current, action) {
|
|
16
|
+
function onClickReset() {
|
|
20
17
|
props.onClickReset();
|
|
21
18
|
}
|
|
22
19
|
const handleFileChange = (event) => {
|
|
@@ -50,10 +47,6 @@ export function States(props) {
|
|
|
50
47
|
onCloseScaleForm(true);
|
|
51
48
|
}
|
|
52
49
|
// Scale form
|
|
53
|
-
const onClickScaleForm = (current, action) => {
|
|
54
|
-
console.log(`${action} button clicked`);
|
|
55
|
-
setShowModalScaleForm(true);
|
|
56
|
-
};
|
|
57
50
|
function onCloseScaleForm(cont = true) {
|
|
58
51
|
if (cont) {
|
|
59
52
|
props.command(ACTION.SCALE_FORM);
|
|
@@ -69,7 +62,7 @@ export function States(props) {
|
|
|
69
62
|
const onPerformCurrentAction = (action) => () => {
|
|
70
63
|
switch (action) {
|
|
71
64
|
case ACTION.RESET:
|
|
72
|
-
onClickReset(
|
|
65
|
+
onClickReset();
|
|
73
66
|
break;
|
|
74
67
|
case ACTION.LOAD_IMAGE:
|
|
75
68
|
handleButtonClick();
|
|
@@ -109,5 +102,5 @@ export function States(props) {
|
|
|
109
102
|
}
|
|
110
103
|
return isEnabled;
|
|
111
104
|
}
|
|
112
|
-
return (_jsxs(
|
|
105
|
+
return (_jsxs("div", { id: "idStates", children: [_jsxs(Box, { sx: { marginBottom: 2 }, children: [_jsx("div", { style: { fontWeight: 'bold', background: 'lightblue' }, children: props.machine.name }), _jsx("br", {}), _jsx(Input, { inputRef: fileInputRef, type: "file", inputProps: { accept: 'image/*' }, style: { display: 'none' }, onChange: handleFileChange, disabled: false }), _jsx(State, { status: STATUS.START, current: props.machine }), _jsx(State, { status: STATUS.IMAGE_LOADED, current: props.machine }), _jsx(State, { status: STATUS.X_AXIS_STARTED, current: props.machine }), _jsx(State, { status: STATUS.X_AXIS_FINISHED, current: props.machine }), _jsx(State, { status: STATUS.POINTS_DEFINED, label: `${props.machine.context.nrPoints} points defined`, current: props.machine, children: _jsx(StateModal, { isOpen: showModalPointsForm, onClose: onClosePointsForm, position: "top-right", children: _jsx(PointsForm, { title: "Import points", onCloseCancel: handleClosePointsFormCancel, onCloseContinue: handleClosePointsFormContinue }) }) }), _jsx(State, { status: STATUS.FORM_SCALED, current: props.machine, children: _jsx(StateModal, { isOpen: showModalScaleForm, onClose: onCloseScaleForm, position: "top-right", children: _jsx(ScaleForm, { title: "Apply Scale", currentPoints: props.machine.context.nrPoints, onCloseCancel: handleCloseScaleFormCancel, onCloseContinue: handleCloseScaleFormContinue }) }) }), _jsx(State, { status: STATUS.FORM_READY, label: `Form ready [${props.machine.context.length} x ${props.machine.context.height}]`, current: props.machine })] }), _jsx(Box, { sx: { display: 'flex', flexDirection: 'row', gap: 2 }, children: renderActions(getValidActions(props.machine, checkIfActionIsEnabled)) })] }));
|
|
113
106
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frame.image",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
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",
|
|
@@ -24,22 +24,22 @@
|
|
|
24
24
|
"@mui/material": "^7.3.1",
|
|
25
25
|
"frame.akima": "^1.2.0",
|
|
26
26
|
"frame.statemachine": "^1.1.2",
|
|
27
|
-
"react": "^
|
|
28
|
-
"react-dom": "^
|
|
27
|
+
"react": "^18.3.1",
|
|
28
|
+
"react-dom": "^18.3.1",
|
|
29
29
|
"react-robot": "^1.2.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@eslint/js": "^9.33.0",
|
|
33
|
-
"@types/react": "^
|
|
34
|
-
"@types/react-dom": "^
|
|
35
|
-
"@vitejs/plugin-react": "^5.0.
|
|
33
|
+
"@types/react": "^18.0.0",
|
|
34
|
+
"@types/react-dom": "^18.0.0",
|
|
35
|
+
"@vitejs/plugin-react": "^5.0.1",
|
|
36
36
|
"eslint": "^9.33.0",
|
|
37
37
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
38
38
|
"eslint-plugin-react-refresh": "^0.4.19",
|
|
39
39
|
"globals": "^16.3.0",
|
|
40
40
|
"typedoc": "^0.28.10",
|
|
41
41
|
"typescript": "~5.9.2",
|
|
42
|
-
"typescript-eslint": "^8.
|
|
43
|
-
"vite": "^7.1.
|
|
42
|
+
"typescript-eslint": "^8.40.0",
|
|
43
|
+
"vite": "^7.1.3"
|
|
44
44
|
}
|
|
45
45
|
}
|