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.
Files changed (222) hide show
  1. package/README.md +14 -1
  2. package/dist/index.esm.js +433 -162
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +12312 -12041
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +9 -5
  11. package/src/cjs/Bounds.d.ts +79 -25
  12. package/src/cjs/Bounds.js +102 -29
  13. package/src/cjs/Bounds.js.map +1 -1
  14. package/src/cjs/CircleSector.d.ts +3 -0
  15. package/src/cjs/CircleSector.js +28 -1
  16. package/src/cjs/CircleSector.js.map +1 -1
  17. package/src/cjs/PlotBoilerplate.d.ts +37 -6
  18. package/src/cjs/PlotBoilerplate.js +222 -116
  19. package/src/cjs/PlotBoilerplate.js.map +1 -1
  20. package/src/cjs/Polygon.d.ts +26 -7
  21. package/src/cjs/Polygon.js +56 -10
  22. package/src/cjs/Polygon.js.map +1 -1
  23. package/src/cjs/Triangle.js +2 -2
  24. package/src/cjs/Triangle.js.map +1 -1
  25. package/src/cjs/Vertex.d.ts +15 -3
  26. package/src/cjs/Vertex.js +18 -1
  27. package/src/cjs/Vertex.js.map +1 -1
  28. package/src/cjs/drawutilssvg.d.ts +2 -1
  29. package/src/cjs/drawutilssvg.js +9 -3
  30. package/src/cjs/drawutilssvg.js.map +1 -1
  31. package/src/cjs/interfaces/core.d.ts +28 -0
  32. package/src/cjs/interfaces/core.js +2 -0
  33. package/src/cjs/interfaces/core.js.map +1 -1
  34. package/src/cjs/utils/LissajousFigure.d.ts +34 -0
  35. package/src/cjs/utils/LissajousFigure.js +100 -0
  36. package/src/cjs/utils/LissajousFigure.js.map +1 -0
  37. package/src/cjs/utils/PerlinNoise.d.ts +19 -0
  38. package/src/cjs/utils/PerlinNoise.js +352 -0
  39. package/src/cjs/utils/PerlinNoise.js.map +1 -0
  40. package/src/cjs/utils/SVGPathUtils.d.ts +22 -0
  41. package/src/cjs/utils/SVGPathUtils.js +45 -0
  42. package/src/cjs/utils/SVGPathUtils.js.map +1 -0
  43. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  44. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js +270 -0
  45. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  46. package/src/cjs/utils/datastructures/Color.d.ts +147 -1
  47. package/src/cjs/utils/datastructures/Color.js +385 -41
  48. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  49. package/src/cjs/utils/datastructures/ColorGradient.d.ts +79 -0
  50. package/src/cjs/utils/datastructures/ColorGradient.js +171 -0
  51. package/src/cjs/utils/datastructures/ColorGradient.js.map +1 -0
  52. package/src/cjs/utils/datastructures/DataGrid2d.d.ts +6 -0
  53. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  54. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js +155 -0
  55. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  56. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
  57. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +3 -3
  58. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
  59. package/src/cjs/utils/datastructures/GeometryMesh.d.ts +49 -0
  60. package/src/cjs/utils/datastructures/GeometryMesh.js +58 -0
  61. package/src/cjs/utils/datastructures/GeometryMesh.js.map +1 -0
  62. package/src/cjs/utils/detectDarkMode.js +16 -7
  63. package/src/cjs/utils/detectDarkMode.js.map +1 -1
  64. package/src/cjs/utils/dom/components/ColorGradientPicker.d.ts +246 -0
  65. package/src/cjs/utils/dom/components/ColorGradientPicker.js +667 -0
  66. package/src/cjs/utils/dom/components/ColorGradientPicker.js.map +1 -0
  67. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
  68. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.js +520 -0
  69. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
  70. package/src/cjs/utils/dom/components/ColorGradientSelector.d.ts +118 -0
  71. package/src/cjs/utils/dom/components/ColorGradientSelector.js +327 -0
  72. package/src/cjs/utils/dom/components/ColorGradientSelector.js.map +1 -0
  73. package/src/cjs/utils/dom/components/Test.d.ts +7 -0
  74. package/src/cjs/utils/dom/components/Test.js +30 -0
  75. package/src/cjs/utils/dom/components/Test.js.map +1 -0
  76. package/src/cjs/utils/dom/guiSizeToggler.js +1 -1
  77. package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -1
  78. package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +9 -3
  79. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +20 -13
  80. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  81. package/src/cjs/utils/helpers/CircleHelper.d.ts +10 -1
  82. package/src/cjs/utils/helpers/CircleHelper.js +13 -2
  83. package/src/cjs/utils/helpers/CircleHelper.js.map +1 -1
  84. package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +2 -2
  85. package/src/cjs/utils/helpers/CircleSectorHelper.js +1 -0
  86. package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
  87. package/src/cjs/utils/helpers/TriangleHelper.d.ts +57 -0
  88. package/src/cjs/utils/helpers/TriangleHelper.js +83 -0
  89. package/src/cjs/utils/helpers/TriangleHelper.js.map +1 -0
  90. package/src/cjs/utils/helpers/VEllipseHelper.d.ts +6 -4
  91. package/src/cjs/utils/helpers/VEllipseHelper.js +4 -2
  92. package/src/cjs/utils/helpers/VEllipseHelper.js.map +1 -1
  93. package/src/cjs/utils/helpers/VEllipseSectorHelper.d.ts +3 -2
  94. package/src/cjs/utils/helpers/VEllipseSectorHelper.js +1 -0
  95. package/src/cjs/utils/helpers/VEllipseSectorHelper.js.map +1 -1
  96. package/src/cjs/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  97. package/src/cjs/utils/parsers/LinearColorGradientParser.js +224 -0
  98. package/src/cjs/utils/parsers/LinearColorGradientParser.js.map +1 -0
  99. package/src/cjs/utils/parsers/svg/types.d.ts +8 -8
  100. package/src/createDemoDrawables.js +1 -0
  101. package/src/esm/Bounds.d.ts +79 -25
  102. package/src/esm/Bounds.js +102 -29
  103. package/src/esm/Bounds.js.map +1 -1
  104. package/src/esm/CircleSector.d.ts +3 -0
  105. package/src/esm/CircleSector.js +28 -1
  106. package/src/esm/CircleSector.js.map +1 -1
  107. package/src/esm/PlotBoilerplate.d.ts +37 -6
  108. package/src/esm/PlotBoilerplate.js +222 -116
  109. package/src/esm/PlotBoilerplate.js.map +1 -1
  110. package/src/esm/Polygon.d.ts +26 -7
  111. package/src/esm/Polygon.js +53 -10
  112. package/src/esm/Polygon.js.map +1 -1
  113. package/src/esm/Triangle.js +2 -2
  114. package/src/esm/Triangle.js.map +1 -1
  115. package/src/esm/Vertex.d.ts +15 -3
  116. package/src/esm/Vertex.js +18 -1
  117. package/src/esm/Vertex.js.map +1 -1
  118. package/src/esm/drawutilssvg.d.ts +2 -1
  119. package/src/esm/drawutilssvg.js +9 -3
  120. package/src/esm/drawutilssvg.js.map +1 -1
  121. package/src/esm/interfaces/core.d.ts +28 -0
  122. package/src/esm/interfaces/core.js +2 -0
  123. package/src/esm/interfaces/core.js.map +1 -1
  124. package/src/esm/utils/LissajousFigure.d.ts +34 -0
  125. package/src/esm/utils/LissajousFigure.js +95 -0
  126. package/src/esm/utils/LissajousFigure.js.map +1 -0
  127. package/src/esm/utils/PerlinNoise.d.ts +19 -0
  128. package/src/esm/utils/PerlinNoise.js +346 -0
  129. package/src/esm/utils/PerlinNoise.js.map +1 -0
  130. package/src/esm/utils/SVGPathUtils.d.ts +22 -0
  131. package/src/esm/utils/SVGPathUtils.js +42 -0
  132. package/src/esm/utils/SVGPathUtils.js.map +1 -0
  133. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  134. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js +266 -0
  135. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  136. package/src/esm/utils/datastructures/Color.d.ts +147 -1
  137. package/src/esm/utils/datastructures/Color.js +386 -42
  138. package/src/esm/utils/datastructures/Color.js.map +1 -1
  139. package/src/esm/utils/datastructures/ColorGradient.d.ts +79 -0
  140. package/src/esm/utils/datastructures/ColorGradient.js +166 -0
  141. package/src/esm/utils/datastructures/ColorGradient.js.map +1 -0
  142. package/src/esm/utils/datastructures/DataGrid2d.d.ts +6 -0
  143. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  144. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js +150 -0
  145. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  146. package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
  147. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js +3 -3
  148. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
  149. package/src/esm/utils/datastructures/GeometryMesh.d.ts +49 -0
  150. package/src/esm/utils/datastructures/GeometryMesh.js +53 -0
  151. package/src/esm/utils/datastructures/GeometryMesh.js.map +1 -0
  152. package/src/esm/utils/detectDarkMode.js +16 -7
  153. package/src/esm/utils/detectDarkMode.js.map +1 -1
  154. package/src/esm/utils/dom/components/ColorGradientPicker.d.ts +246 -0
  155. package/src/esm/utils/dom/components/ColorGradientPicker.js +743 -0
  156. package/src/esm/utils/dom/components/ColorGradientPicker.js.map +1 -0
  157. package/src/esm/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
  158. package/src/esm/utils/dom/components/ColorGradientPickerJSX.js +582 -0
  159. package/src/esm/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
  160. package/src/esm/utils/dom/components/ColorGradientSelector.d.ts +118 -0
  161. package/src/esm/utils/dom/components/ColorGradientSelector.js +339 -0
  162. package/src/esm/utils/dom/components/ColorGradientSelector.js.map +1 -0
  163. package/src/esm/utils/dom/components/Test.d.ts +7 -0
  164. package/src/esm/utils/dom/components/Test.js +26 -0
  165. package/src/esm/utils/dom/components/Test.js.map +1 -0
  166. package/src/esm/utils/dom/guiSizeToggler.js +1 -1
  167. package/src/esm/utils/dom/guiSizeToggler.js.map +1 -1
  168. package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +9 -3
  169. package/src/esm/utils/helpers/BezierPathInteractionHelper.js +20 -13
  170. package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  171. package/src/esm/utils/helpers/CircleHelper.d.ts +10 -1
  172. package/src/esm/utils/helpers/CircleHelper.js +13 -2
  173. package/src/esm/utils/helpers/CircleHelper.js.map +1 -1
  174. package/src/esm/utils/helpers/CircleSectorHelper.d.ts +2 -2
  175. package/src/esm/utils/helpers/CircleSectorHelper.js +1 -0
  176. package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
  177. package/src/esm/utils/helpers/TriangleHelper.d.ts +57 -0
  178. package/src/esm/utils/helpers/TriangleHelper.js +78 -0
  179. package/src/esm/utils/helpers/TriangleHelper.js.map +1 -0
  180. package/src/esm/utils/helpers/VEllipseHelper.d.ts +6 -4
  181. package/src/esm/utils/helpers/VEllipseHelper.js +4 -2
  182. package/src/esm/utils/helpers/VEllipseHelper.js.map +1 -1
  183. package/src/esm/utils/helpers/VEllipseSectorHelper.d.ts +3 -2
  184. package/src/esm/utils/helpers/VEllipseSectorHelper.js +1 -0
  185. package/src/esm/utils/helpers/VEllipseSectorHelper.js.map +1 -1
  186. package/src/esm/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  187. package/src/esm/utils/parsers/LinearColorGradientParser.js +217 -0
  188. package/src/esm/utils/parsers/LinearColorGradientParser.js.map +1 -0
  189. package/src/esm/utils/parsers/svg/types.d.ts +8 -8
  190. package/src/external.d.ts +9 -0
  191. package/src/ts/Bounds.ts +107 -22
  192. package/src/ts/CircleSector.ts +39 -6
  193. package/src/ts/PlotBoilerplate.ts +233 -105
  194. package/src/ts/Polygon.ts +68 -14
  195. package/src/ts/Triangle.ts +2 -2
  196. package/src/ts/Vertex.ts +21 -3
  197. package/src/ts/drawutilssvg.ts +8 -3
  198. package/src/ts/interfaces/core.ts +31 -0
  199. package/src/ts/utils/LissajousFigure.ts +110 -0
  200. package/src/ts/utils/PerlinNoise.ts +368 -0
  201. package/src/ts/utils/SVGPathUtils.ts +55 -0
  202. package/src/ts/utils/algorithms/pixelCornersToRoundPaths.ts +379 -0
  203. package/src/ts/utils/datastructures/Color.ts +423 -44
  204. package/src/ts/utils/datastructures/ColorGradient.ts +196 -0
  205. package/src/ts/utils/datastructures/DataGrid2d.ts +7 -0
  206. package/src/ts/utils/datastructures/DataGrid2dArrayMatrix.ts +182 -0
  207. package/src/ts/utils/datastructures/DataGrid2dListAdapter.ts +4 -11
  208. package/src/ts/utils/datastructures/GeometryMesh.ts +79 -0
  209. package/src/ts/utils/detectDarkMode.ts +17 -8
  210. package/src/ts/utils/dom/components/ColorGradientPicker.tsx +889 -0
  211. package/src/ts/utils/dom/components/ColorGradientSelector.tsx +452 -0
  212. package/src/ts/utils/dom/components/Test.tsx +44 -0
  213. package/src/ts/utils/dom/components/_ColorGradientPicker_raw.ts_ +392 -0
  214. package/src/ts/utils/dom/guiSizeToggler.ts +1 -1
  215. package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +25 -15
  216. package/src/ts/utils/helpers/CircleHelper.ts +17 -3
  217. package/src/ts/utils/helpers/CircleSectorHelper.ts +4 -2
  218. package/src/ts/utils/helpers/TriangleHelper.ts +102 -0
  219. package/src/ts/utils/helpers/VEllipseHelper.ts +6 -4
  220. package/src/ts/utils/helpers/VEllipseSectorHelper.ts +3 -2
  221. package/src/ts/utils/parsers/LinearColorGradientParser.ts +297 -0
  222. package/src/ts/utils/parsers/svg/types.ts +8 -8
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ /**
3
+ * A script to convert any boolean matrix to rounded paths.
4
+ *
5
+ * @author Ikaros Kappler
6
+ * @date 2025-10-17 (ported to Typescript from a demo-script)
7
+ * @version 1.0.0
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.pixelCornersToRoundPaths = void 0;
11
+ var Bounds_1 = require("../../Bounds");
12
+ var DataGrid2dArrayMatrix_1 = require("../datastructures/DataGrid2dArrayMatrix");
13
+ var LEFT_BORDER = 0;
14
+ var TOP_BORDER = 1;
15
+ var RIGHT_BORDER = 2;
16
+ var BOTTOM_BORDER = 3;
17
+ /**
18
+ * Computes an array of paths from the given boolean matrix.
19
+ *
20
+ * @param {DataGrid2dArrayMatrix<boolean>} matrix
21
+ * @param {PixelCornerPathOptions} options
22
+ * @returns
23
+ */
24
+ var pixelCornersToRoundPaths = function (matrix, options) {
25
+ var paths = [];
26
+ var visitedLeftBorderMatrix = new DataGrid2dArrayMatrix_1.DataGrid2dArrayMatrix(matrix.xSegmentCount, matrix.ySegmentCount, false);
27
+ var origin = options && options.origin ? options.origin : { x: 0, y: 0 };
28
+ var squareSize = options && typeof options.squareSize === "number" ? options.squareSize : 10;
29
+ var gapSize = options && typeof options.gapSize === "number" ? options.gapSize : 2;
30
+ var curveFactor = options && typeof options.curveFactor === "number" ? options.curveFactor : 0.666;
31
+ // Find an unvisited pixel with a free left neighbour
32
+ var condition = function (value, x, y, _matrix) {
33
+ return (value === true &&
34
+ visitedLeftBorderMatrix.get(x, y) === false &&
35
+ // is left neighbour free?
36
+ (x - 1 < 0 || _matrix.get(x - 1, y) === false));
37
+ };
38
+ // Just to be sure the while loop terminates after a maximum number of iterations.
39
+ var safetyLimit = matrix.xSegmentCount * matrix.ySegmentCount + 1;
40
+ // The next unvisited pixel position.
41
+ var nonVisitedPosition;
42
+ var i = 0;
43
+ while ((nonVisitedPosition = matrix.find(condition)) && i++ < safetyLimit) {
44
+ // console.log("nonVisitedPosition", nonVisitedPosition);
45
+ // Condition: if a point was found then its left neighbour is empty.
46
+ // So by this the current pixel's left bound is definitely a path start.
47
+ var squareBox = getSquareBox(origin, squareSize, gapSize, nonVisitedPosition.xIndex, nonVisitedPosition.yIndex);
48
+ var west = squareBox.getWestPoint();
49
+ // A starting point was found: Initialize the next path.
50
+ var pathData = [
51
+ // Start point
52
+ "M",
53
+ west.x,
54
+ west.y
55
+ ];
56
+ // Now from this point starting (left pixel corner) construct the next sequence of path commands.
57
+ __constructPath(pathData, matrix, visitedLeftBorderMatrix, nonVisitedPosition, LEFT_BORDER, origin, squareSize, gapSize, curveFactor);
58
+ paths.push(pathData);
59
+ // console.log("pathData", pathData);
60
+ }
61
+ return paths;
62
+ };
63
+ exports.pixelCornersToRoundPaths = pixelCornersToRoundPaths;
64
+ /**
65
+ * Construct a bounding box representing the visual square bounds for the given pixel.
66
+ *
67
+ * @param {XYCoords} origin - The origin to build the paths from (upper left corner of the graphics).
68
+ * @param {number} squareSize - The number of pixels to use to represent a pixel square.
69
+ * @param {number} gapSize - The number of pixels to use for gaps between squares.
70
+ * @param {number} x - The x position inside the data grid (matrix offset).
71
+ * @param {number} y - They position inside the data grid (matrix offset).
72
+ * @returns
73
+ */
74
+ var getSquareBox = function (origin, squareSize, gapSize, x, y) {
75
+ return new Bounds_1.Bounds({
76
+ x: origin.x + x * (squareSize + gapSize),
77
+ y: origin.y + y * (squareSize + gapSize)
78
+ }, {
79
+ x: origin.x + x * (squareSize + gapSize) + squareSize,
80
+ y: origin.y + y * (squareSize + gapSize) + squareSize
81
+ });
82
+ };
83
+ /**
84
+ * Lerp between these two numbers using the passed lerp amount (usually a value in 0.0-1.0).
85
+ *
86
+ * @param {number} a
87
+ * @param {number} b
88
+ * @param {number} lerpFactor
89
+ * @returns {number}
90
+ */
91
+ var lerp = function (a, b, lerpFactor) {
92
+ return a + (b - a) * lerpFactor;
93
+ };
94
+ /**
95
+ * Construct a path command for a cubic Bézier curve.
96
+ *
97
+ * @param {SVGPathParams} pathData
98
+ * @param {XYCoords} start
99
+ * @param {XYCoords} controlA
100
+ * @param {XYCoords} controlB
101
+ * @param {XYCoords} end
102
+ * @param {number} curveFactor
103
+ */
104
+ var addRoundCorner = function (pathData, start, controlA, controlB, end, curveFactor) {
105
+ 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);
106
+ };
107
+ /**
108
+ * Construct a new path command for a straight line.
109
+ *
110
+ * @param {SVGPathParams} pathData
111
+ * @param {XYCoords} target
112
+ */
113
+ var addStraightLine = function (pathData, target) {
114
+ pathData.push("L", target.x, target.y);
115
+ };
116
+ /**
117
+ * A helper function for constructing the next path, beginning at the passed matrix position.
118
+ *
119
+ * Note the path will be created at the left border of the given 'pixel', constructe
120
+ * in clockwise order.
121
+ *
122
+ * @param {SVGPathParams} pathData
123
+ * @param {DataGrid2dArrayMatrix<boolean>} matrix - The data matrix to use.
124
+ * @param {DataGrid2dArrayMatrix<boolean>} visitedLeftBordersMatrix - A helper matrix to keep track of visited pixels.
125
+ * @param {RasterPosition} startingPosition
126
+ * @param {number} startingBorderDirection
127
+ * @param {XYCoords} origin
128
+ * @param {number} squareSize
129
+ * @param {number} gapSize
130
+ * @param {number} curveFactor
131
+ */
132
+ var __constructPath = function (pathData, matrix, visitedLeftBordersMatrix, startingPosition, startingBorderDirection, origin, squareSize, gapSize, curveFactor) {
133
+ // Pre: position's neighbour pixel at ehe given border direction is unset.
134
+ var isPathComplete = false;
135
+ var maxInterations = matrix.xSegmentCount * matrix.ySegmentCount * 4 + 1;
136
+ var i = 0;
137
+ var position = startingPosition;
138
+ var borderDirection = startingBorderDirection;
139
+ while (!isPathComplete && i++ < maxInterations) {
140
+ var x = position.xIndex;
141
+ var y = position.yIndex;
142
+ // console.log("x", x, "y", y, "borderDirection", borderDirection);
143
+ // Get the pixel's box bounds.
144
+ var squareBox = getSquareBox(origin, squareSize, gapSize, x, y);
145
+ // Find next step when walking 'clockwise'
146
+ if (borderDirection === LEFT_BORDER) {
147
+ // Only track visits on left borders. By this we can detect non-visited holes :)
148
+ visitedLeftBordersMatrix.set(x, y, true);
149
+ // We want to expand the left border
150
+ var west = squareBox.getWestPoint();
151
+ // Pixel in the north?
152
+ if (y - 1 < 0 || matrix.get(x, y - 1) === false) {
153
+ // Northwise pixel is empty
154
+ // -> construct round corner to right
155
+ addRoundCorner(pathData, west, squareBox.getNorthWestPoint(), squareBox.getNorthWestPoint(), squareBox.getNorthPoint(), curveFactor);
156
+ borderDirection = TOP_BORDER;
157
+ // Keep pixel position unchanged
158
+ }
159
+ else if (x - 1 >= 0 && matrix.get(x - 1, y - 1) === true) {
160
+ // Top neighbour pixel is set AND top-left pixel is set too.
161
+ // -> construct rounded edge to top-left.
162
+ var squareBoxNW = getSquareBox(origin, squareSize, gapSize, x - 1, y - 1);
163
+ addRoundCorner(pathData, west, squareBox.getNorthWestPoint(), squareBoxNW.getSouthEastPoint(), squareBoxNW.getSouthPoint(), curveFactor);
164
+ borderDirection = BOTTOM_BORDER;
165
+ position = { xIndex: x - 1, yIndex: y - 1 };
166
+ }
167
+ else {
168
+ // Straight to top
169
+ var squareBoxN = getSquareBox(origin, squareSize, gapSize, x, y - 1);
170
+ addStraightLine(pathData, squareBoxN.getWestPoint());
171
+ position = { xIndex: x, yIndex: y - 1 };
172
+ // Keep borderDirection: LEFT_BORDER
173
+ // isPathComplete = true; // TODO
174
+ }
175
+ }
176
+ else if (borderDirection === TOP_BORDER) {
177
+ // North pixel is definitely empty.
178
+ var north = squareBox.getNorthPoint();
179
+ if (x + 1 >= matrix.xSegmentCount || matrix.get(x + 1, y) === false) {
180
+ // Top border and right pixel is empty
181
+ // --> create rounded corner to right south
182
+ addRoundCorner(pathData, north, squareBox.getNorthEastPoint(), squareBox.getNorthEastPoint(), squareBox.getEastPoint(), curveFactor);
183
+ borderDirection = RIGHT_BORDER;
184
+ // Keep pixel position unchanged
185
+ }
186
+ else if (y - 1 < 0 || matrix.get(x + 1, y - 1) === false) {
187
+ // Top border and right pixel is set, and north-east pixel is clear.
188
+ // -> linear path to right
189
+ var squareBoxE = getSquareBox(origin, squareSize, gapSize, x + 1, y);
190
+ addStraightLine(pathData, squareBoxE.getNorthPoint());
191
+ position = { xIndex: x + 1, yIndex: y };
192
+ // Keep borderDirection TOP
193
+ }
194
+ else {
195
+ // Last case: right neighbour is set and north-east pixel is set
196
+ //-> construct a rounded corner to east-north.
197
+ var squareBoxNE = getSquareBox(origin, squareSize, gapSize, x + 1, y - 1);
198
+ addRoundCorner(pathData, north, squareBox.getNorthEastPoint(), squareBoxNE.getSouthWestPoint(), squareBoxNE.getWestPoint(), curveFactor);
199
+ borderDirection = LEFT_BORDER;
200
+ position = { xIndex: x + 1, yIndex: y - 1 };
201
+ // isPathComplete = true; // TODO!!!
202
+ }
203
+ }
204
+ else if (borderDirection === RIGHT_BORDER) {
205
+ // East pixel is definitely empty.
206
+ var east = squareBox.getEastPoint();
207
+ if (y + 1 >= matrix.ySegmentCount || matrix.get(x, y + 1) === false) {
208
+ // South pixel is empty.
209
+ // -> construct rounded corner to south-east
210
+ addRoundCorner(pathData, east, squareBox.getSouthEastPoint(), squareBox.getSouthEastPoint(), squareBox.getSouthPoint(), curveFactor);
211
+ borderDirection = BOTTOM_BORDER;
212
+ // Keep pixel position unchanged
213
+ }
214
+ else if (x + 1 < matrix.xSegmentCount && y + 1 < matrix.ySegmentCount && matrix.get(x + 1, y + 1) === true) {
215
+ // South pixel is set AND right lower pixel is set, too.
216
+ // -> construct round corner to south-east.
217
+ var squareBoxSE = getSquareBox(origin, squareSize, gapSize, x + 1, y + 1);
218
+ addRoundCorner(pathData, east, squareBox.getSouthEastPoint(), squareBoxSE.getNorthWestPoint(), squareBoxSE.getNorthPoint(), curveFactor);
219
+ borderDirection = TOP_BORDER;
220
+ position = { xIndex: x + 1, yIndex: y + 1 };
221
+ }
222
+ else {
223
+ // South pixel is set and south-east pixel is clear.
224
+ // -> construct linear connection to south
225
+ var squareBoxS = getSquareBox(origin, squareSize, gapSize, x, y + 1);
226
+ addStraightLine(pathData, squareBoxS.getEastPoint());
227
+ position = { xIndex: x, yIndex: y + 1 };
228
+ // Keep borderDirection RIGHT
229
+ }
230
+ }
231
+ else if (borderDirection === BOTTOM_BORDER) {
232
+ // Pre: south pixel is definitely empty
233
+ var south = squareBox.getSouthPoint();
234
+ if (x - 1 < 0 || matrix.get(x - 1, y) === false) {
235
+ // Left pixel is empty
236
+ // -> construct round corner to west-north
237
+ addRoundCorner(pathData, south, squareBox.getSouthWestPoint(), squareBox.getSouthWestPoint(), squareBox.getWestPoint(), curveFactor);
238
+ borderDirection = LEFT_BORDER;
239
+ }
240
+ else if (x - 1 >= 0 && y + 1 < matrix.ySegmentCount && matrix.get(x - 1, y + 1) === true) {
241
+ // Left pixel AND left lower pixel are set
242
+ // -> construct rounded edge to south-west
243
+ var squareBoxSW = getSquareBox(origin, squareSize, gapSize, x - 1, y + 1);
244
+ addRoundCorner(pathData, south, squareBox.getSouthWestPoint(), squareBoxSW.getNorthEastPoint(), squareBoxSW.getEastPoint(), curveFactor);
245
+ borderDirection = RIGHT_BORDER;
246
+ position = { xIndex: x - 1, yIndex: y + 1 };
247
+ }
248
+ else {
249
+ // Left pixel is set AND south pixel is empty
250
+ // -> construct linear edge to left neighbour.
251
+ var squareBoxW = getSquareBox(origin, squareSize, gapSize, x - 1, y);
252
+ addStraightLine(pathData, squareBoxW.getSouthPoint());
253
+ position = { xIndex: x - 1, yIndex: y };
254
+ // Keep borderDirection BOTTOM
255
+ }
256
+ }
257
+ else {
258
+ console.warn("[Error] Cannot construct full rounded path; 'borderDirection' has wrong value (".concat(borderDirection, ")."));
259
+ isPathComplete = true;
260
+ }
261
+ // End condition reached?
262
+ if (startingPosition.xIndex === position.xIndex &&
263
+ startingPosition.yIndex === position.yIndex &&
264
+ startingBorderDirection === borderDirection) {
265
+ pathData.push("Z");
266
+ isPathComplete = true;
267
+ }
268
+ }
269
+ };
270
+ //# 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,uCAAsC;AAGtC,iFAAgF;AAEhF,IAAM,WAAW,GAAW,CAAC,CAAC;AAC9B,IAAM,UAAU,GAAW,CAAC,CAAC;AAC7B,IAAM,YAAY,GAAW,CAAC,CAAC;AAC/B,IAAM,aAAa,GAAW,CAAC,CAAC;AAShC;;;;;;GAMG;AACI,IAAM,wBAAwB,GAAG,UACtC,MAAsC,EACtC,OAA+B;IAE/B,IAAM,KAAK,GAAyB,EAAE,CAAC;IACvC,IAAM,uBAAuB,GAAG,IAAI,6CAAqB,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAE7G,IAAM,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,IAAM,UAAU,GAAW,OAAO,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IACvG,IAAM,OAAO,GAAW,OAAO,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7F,IAAM,WAAW,GAAW,OAAO,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,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AK,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
- * @version 0.0.13
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
  }