plotboilerplate 1.24.0 → 1.26.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 +14 -1
- package/dist/index.esm.js +433 -162
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/plotboilerplate.browser.min.js +1 -1
- package/dist/plotboilerplate.browser.min.js.map +1 -1
- package/dist/plotboilerplate.js +12312 -12041
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +9 -5
- package/src/cjs/Bounds.d.ts +79 -25
- package/src/cjs/Bounds.js +102 -29
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/CircleSector.d.ts +3 -0
- package/src/cjs/CircleSector.js +28 -1
- package/src/cjs/CircleSector.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +37 -6
- package/src/cjs/PlotBoilerplate.js +222 -116
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Polygon.d.ts +26 -7
- package/src/cjs/Polygon.js +56 -10
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/Triangle.js +2 -2
- package/src/cjs/Triangle.js.map +1 -1
- package/src/cjs/Vertex.d.ts +15 -3
- package/src/cjs/Vertex.js +18 -1
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +2 -1
- package/src/cjs/drawutilssvg.js +9 -3
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/interfaces/core.d.ts +28 -0
- package/src/cjs/interfaces/core.js +2 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/utils/LissajousFigure.d.ts +34 -0
- package/src/cjs/utils/LissajousFigure.js +100 -0
- package/src/cjs/utils/LissajousFigure.js.map +1 -0
- package/src/cjs/utils/PerlinNoise.d.ts +19 -0
- package/src/cjs/utils/PerlinNoise.js +352 -0
- package/src/cjs/utils/PerlinNoise.js.map +1 -0
- package/src/cjs/utils/SVGPathUtils.d.ts +22 -0
- package/src/cjs/utils/SVGPathUtils.js +45 -0
- package/src/cjs/utils/SVGPathUtils.js.map +1 -0
- package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
- package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js +270 -0
- package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
- package/src/cjs/utils/datastructures/Color.d.ts +147 -1
- package/src/cjs/utils/datastructures/Color.js +385 -41
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- package/src/cjs/utils/datastructures/ColorGradient.d.ts +79 -0
- package/src/cjs/utils/datastructures/ColorGradient.js +171 -0
- package/src/cjs/utils/datastructures/ColorGradient.js.map +1 -0
- package/src/cjs/utils/datastructures/DataGrid2d.d.ts +6 -0
- package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
- package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js +155 -0
- package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +3 -3
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
- package/src/cjs/utils/datastructures/GeometryMesh.d.ts +49 -0
- package/src/cjs/utils/datastructures/GeometryMesh.js +58 -0
- package/src/cjs/utils/datastructures/GeometryMesh.js.map +1 -0
- package/src/cjs/utils/detectDarkMode.js +16 -7
- package/src/cjs/utils/detectDarkMode.js.map +1 -1
- package/src/cjs/utils/dom/components/ColorGradientPicker.d.ts +246 -0
- package/src/cjs/utils/dom/components/ColorGradientPicker.js +667 -0
- package/src/cjs/utils/dom/components/ColorGradientPicker.js.map +1 -0
- package/src/cjs/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
- package/src/cjs/utils/dom/components/ColorGradientPickerJSX.js +520 -0
- package/src/cjs/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
- package/src/cjs/utils/dom/components/ColorGradientSelector.d.ts +118 -0
- package/src/cjs/utils/dom/components/ColorGradientSelector.js +327 -0
- package/src/cjs/utils/dom/components/ColorGradientSelector.js.map +1 -0
- package/src/cjs/utils/dom/components/Test.d.ts +7 -0
- package/src/cjs/utils/dom/components/Test.js +30 -0
- package/src/cjs/utils/dom/components/Test.js.map +1 -0
- package/src/cjs/utils/dom/guiSizeToggler.js +1 -1
- package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -1
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +9 -3
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +20 -13
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/cjs/utils/helpers/CircleHelper.d.ts +10 -1
- package/src/cjs/utils/helpers/CircleHelper.js +13 -2
- package/src/cjs/utils/helpers/CircleHelper.js.map +1 -1
- package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +2 -2
- package/src/cjs/utils/helpers/CircleSectorHelper.js +1 -0
- package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
- package/src/cjs/utils/helpers/TriangleHelper.d.ts +57 -0
- package/src/cjs/utils/helpers/TriangleHelper.js +83 -0
- package/src/cjs/utils/helpers/TriangleHelper.js.map +1 -0
- package/src/cjs/utils/helpers/VEllipseHelper.d.ts +6 -4
- package/src/cjs/utils/helpers/VEllipseHelper.js +4 -2
- package/src/cjs/utils/helpers/VEllipseHelper.js.map +1 -1
- package/src/cjs/utils/helpers/VEllipseSectorHelper.d.ts +3 -2
- package/src/cjs/utils/helpers/VEllipseSectorHelper.js +1 -0
- package/src/cjs/utils/helpers/VEllipseSectorHelper.js.map +1 -1
- package/src/cjs/utils/parsers/LinearColorGradientParser.d.ts +78 -0
- package/src/cjs/utils/parsers/LinearColorGradientParser.js +224 -0
- package/src/cjs/utils/parsers/LinearColorGradientParser.js.map +1 -0
- package/src/cjs/utils/parsers/svg/types.d.ts +8 -8
- package/src/createDemoDrawables.js +1 -0
- package/src/esm/Bounds.d.ts +79 -25
- package/src/esm/Bounds.js +102 -29
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/CircleSector.d.ts +3 -0
- package/src/esm/CircleSector.js +28 -1
- package/src/esm/CircleSector.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +37 -6
- package/src/esm/PlotBoilerplate.js +222 -116
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Polygon.d.ts +26 -7
- package/src/esm/Polygon.js +53 -10
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/Triangle.js +2 -2
- package/src/esm/Triangle.js.map +1 -1
- package/src/esm/Vertex.d.ts +15 -3
- package/src/esm/Vertex.js +18 -1
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +2 -1
- package/src/esm/drawutilssvg.js +9 -3
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/interfaces/core.d.ts +28 -0
- package/src/esm/interfaces/core.js +2 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/utils/LissajousFigure.d.ts +34 -0
- package/src/esm/utils/LissajousFigure.js +95 -0
- package/src/esm/utils/LissajousFigure.js.map +1 -0
- package/src/esm/utils/PerlinNoise.d.ts +19 -0
- package/src/esm/utils/PerlinNoise.js +346 -0
- package/src/esm/utils/PerlinNoise.js.map +1 -0
- package/src/esm/utils/SVGPathUtils.d.ts +22 -0
- package/src/esm/utils/SVGPathUtils.js +42 -0
- package/src/esm/utils/SVGPathUtils.js.map +1 -0
- package/src/esm/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
- package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js +266 -0
- package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
- package/src/esm/utils/datastructures/Color.d.ts +147 -1
- package/src/esm/utils/datastructures/Color.js +386 -42
- package/src/esm/utils/datastructures/Color.js.map +1 -1
- package/src/esm/utils/datastructures/ColorGradient.d.ts +79 -0
- package/src/esm/utils/datastructures/ColorGradient.js +166 -0
- package/src/esm/utils/datastructures/ColorGradient.js.map +1 -0
- package/src/esm/utils/datastructures/DataGrid2d.d.ts +6 -0
- package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
- package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js +150 -0
- package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.js +3 -3
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
- package/src/esm/utils/datastructures/GeometryMesh.d.ts +49 -0
- package/src/esm/utils/datastructures/GeometryMesh.js +53 -0
- package/src/esm/utils/datastructures/GeometryMesh.js.map +1 -0
- package/src/esm/utils/detectDarkMode.js +16 -7
- package/src/esm/utils/detectDarkMode.js.map +1 -1
- package/src/esm/utils/dom/components/ColorGradientPicker.d.ts +246 -0
- package/src/esm/utils/dom/components/ColorGradientPicker.js +743 -0
- package/src/esm/utils/dom/components/ColorGradientPicker.js.map +1 -0
- package/src/esm/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
- package/src/esm/utils/dom/components/ColorGradientPickerJSX.js +582 -0
- package/src/esm/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
- package/src/esm/utils/dom/components/ColorGradientSelector.d.ts +118 -0
- package/src/esm/utils/dom/components/ColorGradientSelector.js +339 -0
- package/src/esm/utils/dom/components/ColorGradientSelector.js.map +1 -0
- package/src/esm/utils/dom/components/Test.d.ts +7 -0
- package/src/esm/utils/dom/components/Test.js +26 -0
- package/src/esm/utils/dom/components/Test.js.map +1 -0
- package/src/esm/utils/dom/guiSizeToggler.js +1 -1
- package/src/esm/utils/dom/guiSizeToggler.js.map +1 -1
- package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +9 -3
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js +20 -13
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/esm/utils/helpers/CircleHelper.d.ts +10 -1
- package/src/esm/utils/helpers/CircleHelper.js +13 -2
- package/src/esm/utils/helpers/CircleHelper.js.map +1 -1
- package/src/esm/utils/helpers/CircleSectorHelper.d.ts +2 -2
- package/src/esm/utils/helpers/CircleSectorHelper.js +1 -0
- package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
- package/src/esm/utils/helpers/TriangleHelper.d.ts +57 -0
- package/src/esm/utils/helpers/TriangleHelper.js +78 -0
- package/src/esm/utils/helpers/TriangleHelper.js.map +1 -0
- package/src/esm/utils/helpers/VEllipseHelper.d.ts +6 -4
- package/src/esm/utils/helpers/VEllipseHelper.js +4 -2
- package/src/esm/utils/helpers/VEllipseHelper.js.map +1 -1
- package/src/esm/utils/helpers/VEllipseSectorHelper.d.ts +3 -2
- package/src/esm/utils/helpers/VEllipseSectorHelper.js +1 -0
- package/src/esm/utils/helpers/VEllipseSectorHelper.js.map +1 -1
- package/src/esm/utils/parsers/LinearColorGradientParser.d.ts +78 -0
- package/src/esm/utils/parsers/LinearColorGradientParser.js +217 -0
- package/src/esm/utils/parsers/LinearColorGradientParser.js.map +1 -0
- package/src/esm/utils/parsers/svg/types.d.ts +8 -8
- package/src/external.d.ts +9 -0
- package/src/ts/Bounds.ts +107 -22
- package/src/ts/CircleSector.ts +39 -6
- package/src/ts/PlotBoilerplate.ts +233 -105
- package/src/ts/Polygon.ts +68 -14
- package/src/ts/Triangle.ts +2 -2
- package/src/ts/Vertex.ts +21 -3
- package/src/ts/drawutilssvg.ts +8 -3
- package/src/ts/interfaces/core.ts +31 -0
- package/src/ts/utils/LissajousFigure.ts +110 -0
- package/src/ts/utils/PerlinNoise.ts +368 -0
- package/src/ts/utils/SVGPathUtils.ts +55 -0
- package/src/ts/utils/algorithms/pixelCornersToRoundPaths.ts +379 -0
- package/src/ts/utils/datastructures/Color.ts +423 -44
- package/src/ts/utils/datastructures/ColorGradient.ts +196 -0
- package/src/ts/utils/datastructures/DataGrid2d.ts +7 -0
- package/src/ts/utils/datastructures/DataGrid2dArrayMatrix.ts +182 -0
- package/src/ts/utils/datastructures/DataGrid2dListAdapter.ts +4 -11
- package/src/ts/utils/datastructures/GeometryMesh.ts +79 -0
- package/src/ts/utils/detectDarkMode.ts +17 -8
- package/src/ts/utils/dom/components/ColorGradientPicker.tsx +889 -0
- package/src/ts/utils/dom/components/ColorGradientSelector.tsx +452 -0
- package/src/ts/utils/dom/components/Test.tsx +44 -0
- package/src/ts/utils/dom/components/_ColorGradientPicker_raw.ts_ +392 -0
- package/src/ts/utils/dom/guiSizeToggler.ts +1 -1
- package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +25 -15
- package/src/ts/utils/helpers/CircleHelper.ts +17 -3
- package/src/ts/utils/helpers/CircleSectorHelper.ts +4 -2
- package/src/ts/utils/helpers/TriangleHelper.ts +102 -0
- package/src/ts/utils/helpers/VEllipseHelper.ts +6 -4
- package/src/ts/utils/helpers/VEllipseSectorHelper.ts +3 -2
- package/src/ts/utils/parsers/LinearColorGradientParser.ts +297 -0
- package/src/ts/utils/parsers/svg/types.ts +8 -8
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A script to convert any boolean matrix to rounded paths.
|
|
3
|
+
*
|
|
4
|
+
* @author Ikaros Kappler
|
|
5
|
+
* @date 2025-10-17 (ported to Typescript from a demo-script)
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { Bounds } from "../../Bounds";
|
|
9
|
+
import { DataGrid2dArrayMatrix } from "../datastructures/DataGrid2dArrayMatrix";
|
|
10
|
+
const LEFT_BORDER = 0;
|
|
11
|
+
const TOP_BORDER = 1;
|
|
12
|
+
const RIGHT_BORDER = 2;
|
|
13
|
+
const BOTTOM_BORDER = 3;
|
|
14
|
+
/**
|
|
15
|
+
* Computes an array of paths from the given boolean matrix.
|
|
16
|
+
*
|
|
17
|
+
* @param {DataGrid2dArrayMatrix<boolean>} matrix
|
|
18
|
+
* @param {PixelCornerPathOptions} options
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export const pixelCornersToRoundPaths = (matrix, options) => {
|
|
22
|
+
const paths = [];
|
|
23
|
+
const visitedLeftBorderMatrix = new DataGrid2dArrayMatrix(matrix.xSegmentCount, matrix.ySegmentCount, false);
|
|
24
|
+
const origin = options && options.origin ? options.origin : { x: 0, y: 0 };
|
|
25
|
+
const squareSize = options && typeof options.squareSize === "number" ? options.squareSize : 10;
|
|
26
|
+
const gapSize = options && typeof options.gapSize === "number" ? options.gapSize : 2;
|
|
27
|
+
const curveFactor = options && typeof options.curveFactor === "number" ? options.curveFactor : 0.666;
|
|
28
|
+
// Find an unvisited pixel with a free left neighbour
|
|
29
|
+
const condition = (value, x, y, _matrix) => {
|
|
30
|
+
return (value === true &&
|
|
31
|
+
visitedLeftBorderMatrix.get(x, y) === false &&
|
|
32
|
+
// is left neighbour free?
|
|
33
|
+
(x - 1 < 0 || _matrix.get(x - 1, y) === false));
|
|
34
|
+
};
|
|
35
|
+
// Just to be sure the while loop terminates after a maximum number of iterations.
|
|
36
|
+
const safetyLimit = matrix.xSegmentCount * matrix.ySegmentCount + 1;
|
|
37
|
+
// The next unvisited pixel position.
|
|
38
|
+
var nonVisitedPosition;
|
|
39
|
+
var i = 0;
|
|
40
|
+
while ((nonVisitedPosition = matrix.find(condition)) && i++ < safetyLimit) {
|
|
41
|
+
// console.log("nonVisitedPosition", nonVisitedPosition);
|
|
42
|
+
// Condition: if a point was found then its left neighbour is empty.
|
|
43
|
+
// So by this the current pixel's left bound is definitely a path start.
|
|
44
|
+
const squareBox = getSquareBox(origin, squareSize, gapSize, nonVisitedPosition.xIndex, nonVisitedPosition.yIndex);
|
|
45
|
+
const west = squareBox.getWestPoint();
|
|
46
|
+
// A starting point was found: Initialize the next path.
|
|
47
|
+
var pathData = [
|
|
48
|
+
// Start point
|
|
49
|
+
"M",
|
|
50
|
+
west.x,
|
|
51
|
+
west.y
|
|
52
|
+
];
|
|
53
|
+
// Now from this point starting (left pixel corner) construct the next sequence of path commands.
|
|
54
|
+
__constructPath(pathData, matrix, visitedLeftBorderMatrix, nonVisitedPosition, LEFT_BORDER, origin, squareSize, gapSize, curveFactor);
|
|
55
|
+
paths.push(pathData);
|
|
56
|
+
// console.log("pathData", pathData);
|
|
57
|
+
}
|
|
58
|
+
return paths;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Construct a bounding box representing the visual square bounds for the given pixel.
|
|
62
|
+
*
|
|
63
|
+
* @param {XYCoords} origin - The origin to build the paths from (upper left corner of the graphics).
|
|
64
|
+
* @param {number} squareSize - The number of pixels to use to represent a pixel square.
|
|
65
|
+
* @param {number} gapSize - The number of pixels to use for gaps between squares.
|
|
66
|
+
* @param {number} x - The x position inside the data grid (matrix offset).
|
|
67
|
+
* @param {number} y - They position inside the data grid (matrix offset).
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
const getSquareBox = (origin, squareSize, gapSize, x, y) => {
|
|
71
|
+
return new Bounds({
|
|
72
|
+
x: origin.x + x * (squareSize + gapSize),
|
|
73
|
+
y: origin.y + y * (squareSize + gapSize)
|
|
74
|
+
}, {
|
|
75
|
+
x: origin.x + x * (squareSize + gapSize) + squareSize,
|
|
76
|
+
y: origin.y + y * (squareSize + gapSize) + squareSize
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Lerp between these two numbers using the passed lerp amount (usually a value in 0.0-1.0).
|
|
81
|
+
*
|
|
82
|
+
* @param {number} a
|
|
83
|
+
* @param {number} b
|
|
84
|
+
* @param {number} lerpFactor
|
|
85
|
+
* @returns {number}
|
|
86
|
+
*/
|
|
87
|
+
const lerp = (a, b, lerpFactor) => {
|
|
88
|
+
return a + (b - a) * lerpFactor;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Construct a path command for a cubic Bézier curve.
|
|
92
|
+
*
|
|
93
|
+
* @param {SVGPathParams} pathData
|
|
94
|
+
* @param {XYCoords} start
|
|
95
|
+
* @param {XYCoords} controlA
|
|
96
|
+
* @param {XYCoords} controlB
|
|
97
|
+
* @param {XYCoords} end
|
|
98
|
+
* @param {number} curveFactor
|
|
99
|
+
*/
|
|
100
|
+
const addRoundCorner = (pathData, start, controlA, controlB, end, curveFactor) => {
|
|
101
|
+
pathData.push("C", lerp(start.x, controlA.x, curveFactor), lerp(start.y, controlA.y, curveFactor), lerp(end.x, controlB.x, curveFactor), lerp(end.y, controlB.y, curveFactor), end.x, end.y);
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Construct a new path command for a straight line.
|
|
105
|
+
*
|
|
106
|
+
* @param {SVGPathParams} pathData
|
|
107
|
+
* @param {XYCoords} target
|
|
108
|
+
*/
|
|
109
|
+
const addStraightLine = (pathData, target) => {
|
|
110
|
+
pathData.push("L", target.x, target.y);
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* A helper function for constructing the next path, beginning at the passed matrix position.
|
|
114
|
+
*
|
|
115
|
+
* Note the path will be created at the left border of the given 'pixel', constructe
|
|
116
|
+
* in clockwise order.
|
|
117
|
+
*
|
|
118
|
+
* @param {SVGPathParams} pathData
|
|
119
|
+
* @param {DataGrid2dArrayMatrix<boolean>} matrix - The data matrix to use.
|
|
120
|
+
* @param {DataGrid2dArrayMatrix<boolean>} visitedLeftBordersMatrix - A helper matrix to keep track of visited pixels.
|
|
121
|
+
* @param {RasterPosition} startingPosition
|
|
122
|
+
* @param {number} startingBorderDirection
|
|
123
|
+
* @param {XYCoords} origin
|
|
124
|
+
* @param {number} squareSize
|
|
125
|
+
* @param {number} gapSize
|
|
126
|
+
* @param {number} curveFactor
|
|
127
|
+
*/
|
|
128
|
+
const __constructPath = (pathData, matrix, visitedLeftBordersMatrix, startingPosition, startingBorderDirection, origin, squareSize, gapSize, curveFactor) => {
|
|
129
|
+
// Pre: position's neighbour pixel at ehe given border direction is unset.
|
|
130
|
+
var isPathComplete = false;
|
|
131
|
+
const maxInterations = matrix.xSegmentCount * matrix.ySegmentCount * 4 + 1;
|
|
132
|
+
var i = 0;
|
|
133
|
+
var position = startingPosition;
|
|
134
|
+
var borderDirection = startingBorderDirection;
|
|
135
|
+
while (!isPathComplete && i++ < maxInterations) {
|
|
136
|
+
var x = position.xIndex;
|
|
137
|
+
var y = position.yIndex;
|
|
138
|
+
// console.log("x", x, "y", y, "borderDirection", borderDirection);
|
|
139
|
+
// Get the pixel's box bounds.
|
|
140
|
+
const squareBox = getSquareBox(origin, squareSize, gapSize, x, y);
|
|
141
|
+
// Find next step when walking 'clockwise'
|
|
142
|
+
if (borderDirection === LEFT_BORDER) {
|
|
143
|
+
// Only track visits on left borders. By this we can detect non-visited holes :)
|
|
144
|
+
visitedLeftBordersMatrix.set(x, y, true);
|
|
145
|
+
// We want to expand the left border
|
|
146
|
+
const west = squareBox.getWestPoint();
|
|
147
|
+
// Pixel in the north?
|
|
148
|
+
if (y - 1 < 0 || matrix.get(x, y - 1) === false) {
|
|
149
|
+
// Northwise pixel is empty
|
|
150
|
+
// -> construct round corner to right
|
|
151
|
+
addRoundCorner(pathData, west, squareBox.getNorthWestPoint(), squareBox.getNorthWestPoint(), squareBox.getNorthPoint(), curveFactor);
|
|
152
|
+
borderDirection = TOP_BORDER;
|
|
153
|
+
// Keep pixel position unchanged
|
|
154
|
+
}
|
|
155
|
+
else if (x - 1 >= 0 && matrix.get(x - 1, y - 1) === true) {
|
|
156
|
+
// Top neighbour pixel is set AND top-left pixel is set too.
|
|
157
|
+
// -> construct rounded edge to top-left.
|
|
158
|
+
const squareBoxNW = getSquareBox(origin, squareSize, gapSize, x - 1, y - 1);
|
|
159
|
+
addRoundCorner(pathData, west, squareBox.getNorthWestPoint(), squareBoxNW.getSouthEastPoint(), squareBoxNW.getSouthPoint(), curveFactor);
|
|
160
|
+
borderDirection = BOTTOM_BORDER;
|
|
161
|
+
position = { xIndex: x - 1, yIndex: y - 1 };
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
// Straight to top
|
|
165
|
+
const squareBoxN = getSquareBox(origin, squareSize, gapSize, x, y - 1);
|
|
166
|
+
addStraightLine(pathData, squareBoxN.getWestPoint());
|
|
167
|
+
position = { xIndex: x, yIndex: y - 1 };
|
|
168
|
+
// Keep borderDirection: LEFT_BORDER
|
|
169
|
+
// isPathComplete = true; // TODO
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else if (borderDirection === TOP_BORDER) {
|
|
173
|
+
// North pixel is definitely empty.
|
|
174
|
+
const north = squareBox.getNorthPoint();
|
|
175
|
+
if (x + 1 >= matrix.xSegmentCount || matrix.get(x + 1, y) === false) {
|
|
176
|
+
// Top border and right pixel is empty
|
|
177
|
+
// --> create rounded corner to right south
|
|
178
|
+
addRoundCorner(pathData, north, squareBox.getNorthEastPoint(), squareBox.getNorthEastPoint(), squareBox.getEastPoint(), curveFactor);
|
|
179
|
+
borderDirection = RIGHT_BORDER;
|
|
180
|
+
// Keep pixel position unchanged
|
|
181
|
+
}
|
|
182
|
+
else if (y - 1 < 0 || matrix.get(x + 1, y - 1) === false) {
|
|
183
|
+
// Top border and right pixel is set, and north-east pixel is clear.
|
|
184
|
+
// -> linear path to right
|
|
185
|
+
const squareBoxE = getSquareBox(origin, squareSize, gapSize, x + 1, y);
|
|
186
|
+
addStraightLine(pathData, squareBoxE.getNorthPoint());
|
|
187
|
+
position = { xIndex: x + 1, yIndex: y };
|
|
188
|
+
// Keep borderDirection TOP
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
// Last case: right neighbour is set and north-east pixel is set
|
|
192
|
+
//-> construct a rounded corner to east-north.
|
|
193
|
+
const squareBoxNE = getSquareBox(origin, squareSize, gapSize, x + 1, y - 1);
|
|
194
|
+
addRoundCorner(pathData, north, squareBox.getNorthEastPoint(), squareBoxNE.getSouthWestPoint(), squareBoxNE.getWestPoint(), curveFactor);
|
|
195
|
+
borderDirection = LEFT_BORDER;
|
|
196
|
+
position = { xIndex: x + 1, yIndex: y - 1 };
|
|
197
|
+
// isPathComplete = true; // TODO!!!
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else if (borderDirection === RIGHT_BORDER) {
|
|
201
|
+
// East pixel is definitely empty.
|
|
202
|
+
var east = squareBox.getEastPoint();
|
|
203
|
+
if (y + 1 >= matrix.ySegmentCount || matrix.get(x, y + 1) === false) {
|
|
204
|
+
// South pixel is empty.
|
|
205
|
+
// -> construct rounded corner to south-east
|
|
206
|
+
addRoundCorner(pathData, east, squareBox.getSouthEastPoint(), squareBox.getSouthEastPoint(), squareBox.getSouthPoint(), curveFactor);
|
|
207
|
+
borderDirection = BOTTOM_BORDER;
|
|
208
|
+
// Keep pixel position unchanged
|
|
209
|
+
}
|
|
210
|
+
else if (x + 1 < matrix.xSegmentCount && y + 1 < matrix.ySegmentCount && matrix.get(x + 1, y + 1) === true) {
|
|
211
|
+
// South pixel is set AND right lower pixel is set, too.
|
|
212
|
+
// -> construct round corner to south-east.
|
|
213
|
+
const squareBoxSE = getSquareBox(origin, squareSize, gapSize, x + 1, y + 1);
|
|
214
|
+
addRoundCorner(pathData, east, squareBox.getSouthEastPoint(), squareBoxSE.getNorthWestPoint(), squareBoxSE.getNorthPoint(), curveFactor);
|
|
215
|
+
borderDirection = TOP_BORDER;
|
|
216
|
+
position = { xIndex: x + 1, yIndex: y + 1 };
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
// South pixel is set and south-east pixel is clear.
|
|
220
|
+
// -> construct linear connection to south
|
|
221
|
+
const squareBoxS = getSquareBox(origin, squareSize, gapSize, x, y + 1);
|
|
222
|
+
addStraightLine(pathData, squareBoxS.getEastPoint());
|
|
223
|
+
position = { xIndex: x, yIndex: y + 1 };
|
|
224
|
+
// Keep borderDirection RIGHT
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else if (borderDirection === BOTTOM_BORDER) {
|
|
228
|
+
// Pre: south pixel is definitely empty
|
|
229
|
+
const south = squareBox.getSouthPoint();
|
|
230
|
+
if (x - 1 < 0 || matrix.get(x - 1, y) === false) {
|
|
231
|
+
// Left pixel is empty
|
|
232
|
+
// -> construct round corner to west-north
|
|
233
|
+
addRoundCorner(pathData, south, squareBox.getSouthWestPoint(), squareBox.getSouthWestPoint(), squareBox.getWestPoint(), curveFactor);
|
|
234
|
+
borderDirection = LEFT_BORDER;
|
|
235
|
+
}
|
|
236
|
+
else if (x - 1 >= 0 && y + 1 < matrix.ySegmentCount && matrix.get(x - 1, y + 1) === true) {
|
|
237
|
+
// Left pixel AND left lower pixel are set
|
|
238
|
+
// -> construct rounded edge to south-west
|
|
239
|
+
const squareBoxSW = getSquareBox(origin, squareSize, gapSize, x - 1, y + 1);
|
|
240
|
+
addRoundCorner(pathData, south, squareBox.getSouthWestPoint(), squareBoxSW.getNorthEastPoint(), squareBoxSW.getEastPoint(), curveFactor);
|
|
241
|
+
borderDirection = RIGHT_BORDER;
|
|
242
|
+
position = { xIndex: x - 1, yIndex: y + 1 };
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
// Left pixel is set AND south pixel is empty
|
|
246
|
+
// -> construct linear edge to left neighbour.
|
|
247
|
+
const squareBoxW = getSquareBox(origin, squareSize, gapSize, x - 1, y);
|
|
248
|
+
addStraightLine(pathData, squareBoxW.getSouthPoint());
|
|
249
|
+
position = { xIndex: x - 1, yIndex: y };
|
|
250
|
+
// Keep borderDirection BOTTOM
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
console.warn(`[Error] Cannot construct full rounded path; 'borderDirection' has wrong value (${borderDirection}).`);
|
|
255
|
+
isPathComplete = true;
|
|
256
|
+
}
|
|
257
|
+
// End condition reached?
|
|
258
|
+
if (startingPosition.xIndex === position.xIndex &&
|
|
259
|
+
startingPosition.yIndex === position.yIndex &&
|
|
260
|
+
startingBorderDirection === borderDirection) {
|
|
261
|
+
pathData.push("Z");
|
|
262
|
+
isPathComplete = true;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
//# sourceMappingURL=pixelCornersToRoundPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixelCornersToRoundPaths.js","sourceRoot":"","sources":["../../../ts/utils/algorithms/pixelCornersToRoundPaths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAEhF,MAAM,WAAW,GAAW,CAAC,CAAC;AAC9B,MAAM,UAAU,GAAW,CAAC,CAAC;AAC7B,MAAM,YAAY,GAAW,CAAC,CAAC;AAC/B,MAAM,aAAa,GAAW,CAAC,CAAC;AAShC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,MAAsC,EACtC,OAA+B,EACT,EAAE;IACxB,MAAM,KAAK,GAAyB,EAAE,CAAC;IACvC,MAAM,uBAAuB,GAAG,IAAI,qBAAqB,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAE7G,MAAM,MAAM,GAAa,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACrF,MAAM,UAAU,GAAW,OAAO,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IACvG,MAAM,OAAO,GAAW,OAAO,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7F,M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cAAc,GAAG,IAAI,CAAC;QACxB,CAAC;QAED,yBAAyB;QACzB,IACE,gBAAgB,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;YAC3C,gBAAgB,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;YAC3C,uBAAuB,KAAK,eAAe,EAC3C,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,cAAc,GAAG,IAAI,CAAC;QACxB,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -18,7 +18,12 @@
|
|
|
18
18
|
* @modified 2022-05-11 Fixed the `interpolate` function.
|
|
19
19
|
* @modified 2023-01-23 Added `Color.set(Color)` function to set all values (r,g,b,h,s,l,a) simultanoeusly.
|
|
20
20
|
* @modified 2024-03-10 Fixed some NaN type check for Typescript 5 compatibility.
|
|
21
|
-
* @
|
|
21
|
+
* @modified 2025-08-08 Fixed an issue in the static `makeRGB` method: values in [0..1] are now correctly reconized (1.0 was excluded).
|
|
22
|
+
* @modified 2025-08-08 Added static color instances (singletons): Color.Red, Color.Gold, Color.Yellow, Color.Green, Color.LimeGreen, Color.Blue, Color.MediumBlue, Color.Purple.
|
|
23
|
+
* @modified 2025-09-01 Adding all standard web colors. Source: https://en.wikipedia.org/wiki/Web_colors
|
|
24
|
+
* @modified 2025-09-01 Modifying the `Sanitizer.RGB` helper method: recognoizing 0 to 255 as valid values (not only 1 to 255).
|
|
25
|
+
* @modified 2025-09-01 Modifying the `Color.parse` method: recognizing CSS color strings now.
|
|
26
|
+
* @version 0.0.14
|
|
22
27
|
**/
|
|
23
28
|
/**
|
|
24
29
|
* @classdesc A color class, inspired by neolitec's Javascript class.
|
|
@@ -242,4 +247,145 @@ export declare class Color {
|
|
|
242
247
|
* @return {Color} A clone of this color (in RGB mode).
|
|
243
248
|
*/
|
|
244
249
|
interpolate(c: Color, t: number): Color;
|
|
250
|
+
static MediumVioletRed: Color;
|
|
251
|
+
static DeepPink: Color;
|
|
252
|
+
static PaleVioletRed: Color;
|
|
253
|
+
static HotPink: Color;
|
|
254
|
+
static LightPink: Color;
|
|
255
|
+
static Pink: Color;
|
|
256
|
+
static DarkRed: Color;
|
|
257
|
+
static Red: Color;
|
|
258
|
+
static Firebrick: Color;
|
|
259
|
+
static Crimson: Color;
|
|
260
|
+
static IndianRed: Color;
|
|
261
|
+
static LightCoral: Color;
|
|
262
|
+
static Salmon: Color;
|
|
263
|
+
static DarkSalmon: Color;
|
|
264
|
+
static LightSalmon: Color;
|
|
265
|
+
static OrangeRed: Color;
|
|
266
|
+
static Tomato: Color;
|
|
267
|
+
static DarkOrange: Color;
|
|
268
|
+
static Coral: Color;
|
|
269
|
+
static Orange: Color;
|
|
270
|
+
static DarkKhaki: Color;
|
|
271
|
+
static Gold: Color;
|
|
272
|
+
static Khaki: Color;
|
|
273
|
+
static PeachPuff: Color;
|
|
274
|
+
static Yellow: Color;
|
|
275
|
+
static PaleGoldenrod: Color;
|
|
276
|
+
static Moccasin: Color;
|
|
277
|
+
static PapayaWhip: Color;
|
|
278
|
+
static LightGoldenrodYellow: Color;
|
|
279
|
+
static LemonChiffon: Color;
|
|
280
|
+
static LightYellow: Color;
|
|
281
|
+
static Maroon: Color;
|
|
282
|
+
static Brown: Color;
|
|
283
|
+
static SaddleBrown: Color;
|
|
284
|
+
static Sienna: Color;
|
|
285
|
+
static Chocolate: Color;
|
|
286
|
+
static DarkGoldenrod: Color;
|
|
287
|
+
static Peru: Color;
|
|
288
|
+
static RosyBrown: Color;
|
|
289
|
+
static Goldenrod: Color;
|
|
290
|
+
static SandyBrown: Color;
|
|
291
|
+
static Tan: Color;
|
|
292
|
+
static Burlywood: Color;
|
|
293
|
+
static Wheat: Color;
|
|
294
|
+
static NavajoWhite: Color;
|
|
295
|
+
static Bisque: Color;
|
|
296
|
+
static BlanchedAlmond: Color;
|
|
297
|
+
static Cornsilk: Color;
|
|
298
|
+
static Indigo: Color;
|
|
299
|
+
static Purple: Color;
|
|
300
|
+
static DarkMagenta: Color;
|
|
301
|
+
static DarkViolet: Color;
|
|
302
|
+
static DarkSlateBlue: Color;
|
|
303
|
+
static BlueViolet: Color;
|
|
304
|
+
static DarkOrchid: Color;
|
|
305
|
+
static Fuchsia: Color;
|
|
306
|
+
static Magenta: Color;
|
|
307
|
+
static SlateBlue: Color;
|
|
308
|
+
static MediumSlateBlue: Color;
|
|
309
|
+
static MediumOrchid: Color;
|
|
310
|
+
static MediumPurple: Color;
|
|
311
|
+
static Orchid: Color;
|
|
312
|
+
static Violet: Color;
|
|
313
|
+
static Plum: Color;
|
|
314
|
+
static Thistle: Color;
|
|
315
|
+
static Lavender: Color;
|
|
316
|
+
static MidnightBlue: Color;
|
|
317
|
+
static Navy: Color;
|
|
318
|
+
static DarkBlue: Color;
|
|
319
|
+
static MediumBlue: Color;
|
|
320
|
+
static Blue: Color;
|
|
321
|
+
static RoyalBlue: Color;
|
|
322
|
+
static SteelBlue: Color;
|
|
323
|
+
static DodgerBlue: Color;
|
|
324
|
+
static DeepSkyBlue: Color;
|
|
325
|
+
static CornflowerBlue: Color;
|
|
326
|
+
static SkyBlue: Color;
|
|
327
|
+
static LightSkyBlue: Color;
|
|
328
|
+
static LightSteelBlue: Color;
|
|
329
|
+
static LightBlue: Color;
|
|
330
|
+
static PowderBlue: Color;
|
|
331
|
+
static Teal: Color;
|
|
332
|
+
static DarkCyan: Color;
|
|
333
|
+
static LightSeaGreen: Color;
|
|
334
|
+
static CadetBlue: Color;
|
|
335
|
+
static DarkTurquoise: Color;
|
|
336
|
+
static MediumTurquoise: Color;
|
|
337
|
+
static Turquoise: Color;
|
|
338
|
+
static Aqua: Color;
|
|
339
|
+
static Cyan: Color;
|
|
340
|
+
static Aquamarine: Color;
|
|
341
|
+
static PaleTurquoise: Color;
|
|
342
|
+
static LightCyan: Color;
|
|
343
|
+
static DarkGreen: Color;
|
|
344
|
+
static Green: Color;
|
|
345
|
+
static DarkOliveGreen: Color;
|
|
346
|
+
static ForestGreen: Color;
|
|
347
|
+
static SeaGreen: Color;
|
|
348
|
+
static Olive: Color;
|
|
349
|
+
static OliveDrab: Color;
|
|
350
|
+
static MediumSeaGreen: Color;
|
|
351
|
+
static LimeGreen: Color;
|
|
352
|
+
static Lime: Color;
|
|
353
|
+
static SpringGreen: Color;
|
|
354
|
+
static MediumSpringGreen: Color;
|
|
355
|
+
static DarkSeaGreen: Color;
|
|
356
|
+
static MediumAquamarine: Color;
|
|
357
|
+
static YellowGreen: Color;
|
|
358
|
+
static LawnGreen: Color;
|
|
359
|
+
static Chartreuse: Color;
|
|
360
|
+
static LightGreen: Color;
|
|
361
|
+
static GreenYellow: Color;
|
|
362
|
+
static PaleGreen: Color;
|
|
363
|
+
static MistyRose: Color;
|
|
364
|
+
static AntiqueWhite: Color;
|
|
365
|
+
static Linen: Color;
|
|
366
|
+
static Beige: Color;
|
|
367
|
+
static WhiteSmoke: Color;
|
|
368
|
+
static LavenderBlush: Color;
|
|
369
|
+
static OldLace: Color;
|
|
370
|
+
static AliceBlue: Color;
|
|
371
|
+
static Seashell: Color;
|
|
372
|
+
static GhostWhite: Color;
|
|
373
|
+
static Honeydew: Color;
|
|
374
|
+
static FloralWhite: Color;
|
|
375
|
+
static Azure: Color;
|
|
376
|
+
static MintCream: Color;
|
|
377
|
+
static Snow: Color;
|
|
378
|
+
static Ivory: Color;
|
|
379
|
+
static White: Color;
|
|
380
|
+
static Black: Color;
|
|
381
|
+
static DarkSlateGray: Color;
|
|
382
|
+
static DimGray: Color;
|
|
383
|
+
static SlateGray: Color;
|
|
384
|
+
static Gray: Color;
|
|
385
|
+
static LightSlateGray: Color;
|
|
386
|
+
static DarkGray: Color;
|
|
387
|
+
static Silver: Color;
|
|
388
|
+
static LightGray: Color;
|
|
389
|
+
static Gainsboro: Color;
|
|
390
|
+
static CSS_COLORS: Record<string, Color>;
|
|
245
391
|
}
|