plotboilerplate 1.25.0 → 1.27.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 +3 -0
- package/dist/index.esm.js +171 -43
- 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 +171 -43
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +6 -2
- 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 +4 -3
- package/src/cjs/PlotBoilerplate.js +2 -1
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/draw.d.ts +4 -2
- package/src/cjs/draw.js +9 -4
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.d.ts +3 -2
- package/src/cjs/drawgl.js +2 -1
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +10 -4
- package/src/cjs/drawutilssvg.js +28 -7
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +2 -0
- package/src/cjs/interfaces/DrawLib.js +1 -0
- package/src/cjs/interfaces/DrawLib.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/WebColors.d.ts +2 -1
- package/src/cjs/utils/WebColors.js +14 -25
- package/src/cjs/utils/WebColors.js.map +1 -1
- package/src/cjs/utils/algorithms/PolygonTesselationOutlines.d.ts +145 -0
- package/src/cjs/utils/algorithms/PolygonTesselationOutlines.js +269 -0
- package/src/cjs/utils/algorithms/PolygonTesselationOutlines.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.js +0 -19
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- package/src/cjs/utils/datastructures/ColorGradient.d.ts +2 -0
- package/src/cjs/utils/datastructures/ColorGradient.js +5 -0
- package/src/cjs/utils/datastructures/ColorGradient.js.map +1 -1
- 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/datastructures/Girih.d.ts +38 -1
- package/src/cjs/utils/datastructures/Girih.js +71 -1
- package/src/cjs/utils/datastructures/Girih.js.map +1 -1
- 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 +4 -3
- package/src/cjs/utils/dom/components/ColorGradientPicker.js +8 -8
- package/src/cjs/utils/dom/components/ColorGradientPicker.js.map +1 -1
- package/src/cjs/utils/dom/components/ColorGradientSelector.d.ts +1 -0
- package/src/cjs/utils/dom/components/ColorGradientSelector.js +4 -2
- package/src/cjs/utils/dom/components/ColorGradientSelector.js.map +1 -1
- package/src/cjs/utils/io/FileDrop.d.ts +2 -0
- package/src/cjs/utils/io/FileDrop.js +4 -0
- package/src/cjs/utils/io/FileDrop.js.map +1 -1
- package/src/cjs/utils/parsers/svg/types.d.ts +8 -8
- 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 +4 -3
- package/src/esm/PlotBoilerplate.js +2 -1
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/draw.d.ts +4 -2
- package/src/esm/draw.js +9 -4
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.d.ts +3 -2
- package/src/esm/drawgl.js +2 -1
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +10 -4
- package/src/esm/drawutilssvg.js +28 -7
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +2 -0
- package/src/esm/interfaces/DrawLib.js +1 -0
- package/src/esm/interfaces/DrawLib.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/WebColors.d.ts +2 -1
- package/src/esm/utils/WebColors.js +14 -25
- package/src/esm/utils/WebColors.js.map +1 -1
- package/src/esm/utils/algorithms/PolygonTesselationOutlines.d.ts +145 -0
- package/src/esm/utils/algorithms/PolygonTesselationOutlines.js +262 -0
- package/src/esm/utils/algorithms/PolygonTesselationOutlines.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.js +0 -19
- package/src/esm/utils/datastructures/Color.js.map +1 -1
- package/src/esm/utils/datastructures/ColorGradient.d.ts +2 -0
- package/src/esm/utils/datastructures/ColorGradient.js +5 -0
- package/src/esm/utils/datastructures/ColorGradient.js.map +1 -1
- 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/datastructures/Girih.d.ts +38 -1
- package/src/esm/utils/datastructures/Girih.js +71 -1
- package/src/esm/utils/datastructures/Girih.js.map +1 -1
- 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 +4 -3
- package/src/esm/utils/dom/components/ColorGradientPicker.js +18 -7
- package/src/esm/utils/dom/components/ColorGradientPicker.js.map +1 -1
- package/src/esm/utils/dom/components/ColorGradientSelector.d.ts +1 -0
- package/src/esm/utils/dom/components/ColorGradientSelector.js +9 -2
- package/src/esm/utils/dom/components/ColorGradientSelector.js.map +1 -1
- package/src/esm/utils/io/FileDrop.d.ts +2 -0
- package/src/esm/utils/io/FileDrop.js +4 -0
- package/src/esm/utils/io/FileDrop.js.map +1 -1
- package/src/esm/utils/parsers/svg/types.d.ts +8 -8
- package/src/ts/Bounds.ts +107 -22
- package/src/ts/CircleSector.ts +39 -6
- package/src/ts/PlotBoilerplate.ts +4 -3
- package/src/ts/draw.ts +8 -3
- package/src/ts/drawgl.ts +3 -2
- package/src/ts/drawutilssvg.ts +34 -7
- package/src/ts/interfaces/DrawLib.ts +3 -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/WebColors.ts +20 -33
- package/src/ts/utils/algorithms/PolygonTesselationOutlines.ts +296 -0
- package/src/ts/utils/algorithms/pixelCornersToRoundPaths.ts +379 -0
- package/src/ts/utils/datastructures/Color.ts +0 -19
- package/src/ts/utils/datastructures/ColorGradient.ts +6 -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/datastructures/Girih.ts +78 -1
- package/src/ts/utils/datastructures/interfaces.ts +4 -4
- package/src/ts/utils/detectDarkMode.ts +17 -8
- package/src/ts/utils/dom/components/ColorGradientPicker.tsx +18 -6
- package/src/ts/utils/dom/components/ColorGradientSelector.tsx +9 -2
- package/src/ts/utils/io/FileDrop.ts +5 -0
- package/src/ts/utils/parsers/svg/types.ts +8 -8
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapted from the 3D geometry datastuctured from demo-33 (depth mesh).
|
|
3
|
+
*
|
|
4
|
+
* Refactored the strucure into a class.
|
|
5
|
+
*
|
|
6
|
+
* @author Ikaros Kappler
|
|
7
|
+
* @date 2025-11-14
|
|
8
|
+
* @modified 2025-11-17 Moved `getBounds` and `normalizeGeometry` from helper functions to this class.
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export type Vertex2 = { x: number; y: number };
|
|
13
|
+
export type Vertex3 = { x: number; y: number; z: number };
|
|
14
|
+
|
|
15
|
+
export class GeometryMesh<T extends Vertex2 | Vertex3> {
|
|
16
|
+
/**
|
|
17
|
+
* A set (array) of vertices (points) used in this mesh. Can be 2d or 3d.
|
|
18
|
+
*
|
|
19
|
+
* @member {Array<T>}
|
|
20
|
+
* @memberof GeometryMesh
|
|
21
|
+
* @type {Array<T>}
|
|
22
|
+
* @instance
|
|
23
|
+
*/
|
|
24
|
+
vertices: Array<T>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A set (array) of edges used in this mesh.
|
|
28
|
+
* Each edge consist of two indices indicating the vertex position.
|
|
29
|
+
*
|
|
30
|
+
* @member {Array<T>}
|
|
31
|
+
* @memberof GeometryMesh
|
|
32
|
+
* @type {Array<T>}
|
|
33
|
+
* @instance
|
|
34
|
+
*/
|
|
35
|
+
edges: Array<[number, number]>;
|
|
36
|
+
|
|
37
|
+
constructor(vertices?: Array<T>, edges?: Array<[number, number]>) {
|
|
38
|
+
this.vertices = vertices || [];
|
|
39
|
+
this.edges = edges || [];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
normalize() {
|
|
43
|
+
// Desired bounds is a max bounding box. The object will be scaled keeping aspect ratio
|
|
44
|
+
// in that way that the largest axis size touches the desired bounds.
|
|
45
|
+
var desiredBounds = { min: { x: -1, y: -1, z: -1 }, max: { x: 1, y: 1, z: 1 } };
|
|
46
|
+
var bounds = this.getGeometryBounds();
|
|
47
|
+
var sizeX = bounds.max.x - bounds.min.x;
|
|
48
|
+
var sizeY = bounds.max.y - bounds.min.y;
|
|
49
|
+
var sizeZ = bounds.max.z - bounds.min.z;
|
|
50
|
+
// Scale uniform so the dimension with the max expansion fits into [-1,1]
|
|
51
|
+
var maxDimension = Math.max(sizeX, sizeY, sizeZ);
|
|
52
|
+
var desiredSizeX = (desiredBounds.max.x - desiredBounds.min.x) / maxDimension;
|
|
53
|
+
var desiredSizeY = (desiredBounds.max.y - desiredBounds.min.y) / maxDimension;
|
|
54
|
+
var desiredSizeZ = (desiredBounds.max.z - desiredBounds.min.z) / maxDimension;
|
|
55
|
+
for (var i in this.vertices) {
|
|
56
|
+
var vert = this.vertices[i] as Vertex3; // TODO: Check if this is safe
|
|
57
|
+
vert.x = desiredBounds.min.x + (bounds.max.x - vert.x) * desiredSizeX;
|
|
58
|
+
vert.y = desiredBounds.min.y + (bounds.max.y - vert.y) * desiredSizeY;
|
|
59
|
+
vert.z = desiredBounds.min.z + (bounds.max.z - vert.z) * desiredSizeZ;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getGeometryBounds(): { min: Vertex3; max: Vertex3; width: number; height: number; depth: number } {
|
|
64
|
+
// var min = new Vert3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
|
|
65
|
+
// var max = new Vert3(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE);
|
|
66
|
+
var min = { x: Number.MAX_VALUE, y: Number.MAX_VALUE, z: Number.MAX_VALUE };
|
|
67
|
+
var max = { x: Number.MIN_VALUE, y: Number.MIN_VALUE, z: Number.MIN_VALUE };
|
|
68
|
+
for (var i in this.vertices) {
|
|
69
|
+
var vert = this.vertices[i] as Vertex3;
|
|
70
|
+
min.x = Math.min(vert.x, min.x);
|
|
71
|
+
min.y = Math.min(vert.y, min.y);
|
|
72
|
+
min.z = Math.min(vert.z, min.z);
|
|
73
|
+
max.x = Math.max(vert.x, max.x);
|
|
74
|
+
max.y = Math.max(vert.y, max.y);
|
|
75
|
+
max.z = Math.max(vert.z, max.z);
|
|
76
|
+
}
|
|
77
|
+
return { min: min, max: max, width: max.x - min.x, height: max.y - min.y, depth: max.z - min.z };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
* @date 2020-11-24
|
|
4
4
|
* @modified 2020-11-25 Ported to TypeScript from vanilla JS.
|
|
5
5
|
* @modified 2024-03-10 Fixed some types for Typescript 5 compatibility.
|
|
6
|
-
* @
|
|
6
|
+
* @modified 2026-01-06 Added method `Girih.locateContainingTileAndEdge` to locate tile/edge pairs.
|
|
7
|
+
* @modified 2026-01-12 Added method `Girih.getTileByCenter` to locate tiles by position.
|
|
8
|
+
* @modified 2026-01-18 Added method `Girih.removeAllTiles`.
|
|
9
|
+
* @version 1.1.0
|
|
7
10
|
* @file Girih
|
|
8
11
|
**/
|
|
9
12
|
|
|
@@ -15,6 +18,7 @@ import { GirihHexagon } from "./GirihHexagon";
|
|
|
15
18
|
import { GirihPenroseRhombus } from "./GirihPenroseRhombus";
|
|
16
19
|
import { GirihPentagon } from "./GirihPentagon";
|
|
17
20
|
import { GirihRhombus } from "./GirihRhombus";
|
|
21
|
+
import { XYCoords } from "../../interfaces";
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* @classdesc The Girih datastructure for generating patterns.
|
|
@@ -135,6 +139,19 @@ export class Girih {
|
|
|
135
139
|
}
|
|
136
140
|
|
|
137
141
|
/**
|
|
142
|
+
* Remove all tiles.
|
|
143
|
+
*
|
|
144
|
+
* @name removeAllTiles
|
|
145
|
+
* @memberof Girih
|
|
146
|
+
* @instance
|
|
147
|
+
* @return {void}
|
|
148
|
+
*/
|
|
149
|
+
removeAllTiles(): void {
|
|
150
|
+
this.tiles.splice(0, this.tiles.length);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Replace all current tiles with the given ones.
|
|
138
155
|
*
|
|
139
156
|
* @param tiles
|
|
140
157
|
*/
|
|
@@ -145,6 +162,25 @@ export class Girih {
|
|
|
145
162
|
}
|
|
146
163
|
}
|
|
147
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Find the tile with the given center.
|
|
167
|
+
*
|
|
168
|
+
* @name getTileByCenter
|
|
169
|
+
* @memberof Girih
|
|
170
|
+
* @instance
|
|
171
|
+
* @param {XYCoords} center - The center point to look for.
|
|
172
|
+
* @return {GirihTile} The tile or null if not found.
|
|
173
|
+
*/
|
|
174
|
+
getTileByCenter(center: XYCoords): GirihTile {
|
|
175
|
+
for (var i = 0; i < this.tiles.length; i++) {
|
|
176
|
+
const pos = this.tiles[i].position;
|
|
177
|
+
if (pos === center || (pos.x == center.x && pos.y == center.y)) {
|
|
178
|
+
return this.tiles[i];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
148
184
|
/**
|
|
149
185
|
* Find that tile (index) which contains the given position. First match will be returned.
|
|
150
186
|
*
|
|
@@ -161,6 +197,47 @@ export class Girih {
|
|
|
161
197
|
return -1;
|
|
162
198
|
}
|
|
163
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Find find a tile-edge-pair (indices) that contain the given position. First match will be returned.
|
|
202
|
+
*
|
|
203
|
+
* @name locateContainingTileAndEdge
|
|
204
|
+
* @memberof Girih
|
|
205
|
+
* @instance
|
|
206
|
+
* @param {Vertex} position
|
|
207
|
+
* @return {{ tileIndex: number; edgeIndex: number }} The index of the containing tile and edge or null if none was found.
|
|
208
|
+
**/
|
|
209
|
+
locateContainingTileAndEdge(position): { tileIndex: number; edgeIndex: number } {
|
|
210
|
+
var containedTileIndex = this.locateConatiningTile(position);
|
|
211
|
+
|
|
212
|
+
// Reset currently highlighted tile/edge (if re-detected nothing changed in the end)
|
|
213
|
+
var hoverTileIndex = -1;
|
|
214
|
+
var hoverEdgeIndex = -1;
|
|
215
|
+
|
|
216
|
+
// Find Girih edge nearby ...
|
|
217
|
+
if (containedTileIndex == -1) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
var i = containedTileIndex;
|
|
221
|
+
do {
|
|
222
|
+
var tile = this.tiles[i];
|
|
223
|
+
// May be -1
|
|
224
|
+
hoverEdgeIndex = tile.locateEdgeAtPoint(position, this.edgeLength / 2);
|
|
225
|
+
if (hoverEdgeIndex != -1) {
|
|
226
|
+
hoverTileIndex = i;
|
|
227
|
+
}
|
|
228
|
+
i++;
|
|
229
|
+
} while (i < this.tiles.length && containedTileIndex == -1 && hoverEdgeIndex == -1);
|
|
230
|
+
if (hoverTileIndex == -1) {
|
|
231
|
+
hoverTileIndex = containedTileIndex;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Find the next possible tile to place?
|
|
235
|
+
if (hoverTileIndex == -1 || hoverEdgeIndex == -1) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
return { tileIndex: hoverTileIndex, edgeIndex: hoverEdgeIndex };
|
|
239
|
+
}
|
|
240
|
+
|
|
164
241
|
/**
|
|
165
242
|
* Turn the tile the mouse is hovering over.
|
|
166
243
|
* The turnCount is ab abstract number: -1 for one turn left, +1 for one turn right.
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @version 1.0.0
|
|
7
7
|
**/
|
|
8
8
|
|
|
9
|
-
export type Interval = [
|
|
9
|
+
export type Interval = [number, number];
|
|
10
10
|
|
|
11
11
|
export type IndexPair = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
i: number;
|
|
13
|
+
j: number;
|
|
14
|
+
};
|
|
15
15
|
|
|
16
16
|
export type Matrix<T> = Array<Array<T>>;
|
|
@@ -9,20 +9,29 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export const detectDarkMode = (GUP?: Record<string, string>): boolean => {
|
|
12
|
+
var isDarkmode: boolean = false;
|
|
12
13
|
// Respect overrides
|
|
13
14
|
if (typeof GUP !== "undefined" && GUP.hasOwnProperty("darkmode") && GUP["darkmode"]) {
|
|
14
15
|
// const overrideValue = PlotBoilerplate.utils.fetch.bool(GUP, "darkmode", null);
|
|
15
16
|
const overrideValue = !!JSON.parse(GUP["darkmode"]);
|
|
16
17
|
if (overrideValue !== null) {
|
|
17
|
-
|
|
18
|
+
isDarkmode = overrideValue;
|
|
18
19
|
}
|
|
19
|
-
}
|
|
20
|
-
if (globalThis.matchMedia && globalThis.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
20
|
+
} else if (globalThis.matchMedia && globalThis.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
21
21
|
// dark mode by system
|
|
22
|
-
|
|
22
|
+
isDarkmode = true;
|
|
23
|
+
} else {
|
|
24
|
+
// else: dark mode by daytime
|
|
25
|
+
const hours = new Date().getHours();
|
|
26
|
+
const isDayTime = hours > 6 && hours < 18;
|
|
27
|
+
isDarkmode = !isDayTime;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// console.log("Adding darkmode to <body>", isDarkmode);
|
|
31
|
+
if (isDarkmode && document.body) {
|
|
32
|
+
// Add darkmode class to <body> tag
|
|
33
|
+
document.body.classList.add("darkmode");
|
|
23
34
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const isDayTime = hours > 6 && hours < 18;
|
|
27
|
-
return !isDayTime;
|
|
35
|
+
|
|
36
|
+
return isDarkmode;
|
|
28
37
|
};
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* to get this running: NoReact.
|
|
7
7
|
*
|
|
8
8
|
*
|
|
9
|
-
* @author
|
|
10
|
-
* @date
|
|
11
|
-
* @
|
|
9
|
+
* @author Ikaros Kappler
|
|
10
|
+
* @date 2025-06-27
|
|
11
|
+
* @modified 2025-09-10 Fixing a color select bug on MacOS.
|
|
12
|
+
* @version 1.0.0
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
15
|
import * as NoReact from "noreact";
|
|
@@ -455,7 +456,7 @@ export class ColorGradientPicker {
|
|
|
455
456
|
const sliderRef = this._sliderElementRefs[newSliderIndex];
|
|
456
457
|
leftSlider.after(sliderRef.current);
|
|
457
458
|
sliderRef.current.dataset.colorValue = newColor.cssRGB();
|
|
458
|
-
sliderRef.current.dataset.colorValueHEX = newColor.
|
|
459
|
+
sliderRef.current.dataset.colorValueHEX = newColor.cssHEX();
|
|
459
460
|
// No visible change, but let's reflect this in the output gradient anyway
|
|
460
461
|
this.__updateBackgroundGradient();
|
|
461
462
|
// Highlight the newly added range slider
|
|
@@ -751,9 +752,10 @@ export class ColorGradientPicker {
|
|
|
751
752
|
>
|
|
752
753
|
<button
|
|
753
754
|
id={`color-indicator-button-${this.baseID}`}
|
|
755
|
+
className="color-indicator-button"
|
|
754
756
|
style={{
|
|
755
757
|
backgroundColor: "grey",
|
|
756
|
-
borderRadius: "
|
|
758
|
+
borderRadius: "50%",
|
|
757
759
|
border: "1px solid grey",
|
|
758
760
|
w: this.css_indicatorWidth, // "1em",
|
|
759
761
|
h: this.css_indicatorHeight, // "1em",
|
|
@@ -766,7 +768,6 @@ export class ColorGradientPicker {
|
|
|
766
768
|
id={`color-remove-button-${this.baseID}`}
|
|
767
769
|
className="color-remove-button"
|
|
768
770
|
style={{
|
|
769
|
-
backgroundColor: "grey",
|
|
770
771
|
borderRadius: "10%",
|
|
771
772
|
border: "1px solid grey",
|
|
772
773
|
w: this.css_indicatorWidth, // "1em",
|
|
@@ -871,6 +872,17 @@ export class ColorGradientPicker {
|
|
|
871
872
|
/* outline: dotted 1px orange; */
|
|
872
873
|
color: darkorange;
|
|
873
874
|
}
|
|
875
|
+
|
|
876
|
+
body.darkmode #${this.elementID} .color-remove-button {
|
|
877
|
+
background-color: #1e2937;
|
|
878
|
+
color: grey;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
body.darkmode #${this.elementID} .color-remove-button:hover,
|
|
882
|
+
body.darkmode #${this.elementID} .color-remove-button:active {
|
|
883
|
+
background-color: rgba(216,216,216,0.9);
|
|
884
|
+
}
|
|
885
|
+
|
|
874
886
|
`}</style>
|
|
875
887
|
);
|
|
876
888
|
};
|
|
@@ -46,6 +46,7 @@ export class ColorGradientSelector {
|
|
|
46
46
|
private css_buttonWidth = "100px";
|
|
47
47
|
private css_buttonHeight = "1.8em";
|
|
48
48
|
private css_buttonFontSize = "0.725em";
|
|
49
|
+
private css_buttonFontSize_larger = "1.0em";
|
|
49
50
|
|
|
50
51
|
private colorGradients: Array<ColorGradient> = [];
|
|
51
52
|
// TODO: this does not really need to be a pair, does it?
|
|
@@ -88,6 +89,7 @@ export class ColorGradientSelector {
|
|
|
88
89
|
this.css_buttonWidth = "200px";
|
|
89
90
|
this.css_buttonHeight = "2.5em";
|
|
90
91
|
this.css_buttonFontSize = "1.25em";
|
|
92
|
+
this.css_buttonFontSize_larger = "1.45em";
|
|
91
93
|
}
|
|
92
94
|
this.baseID = Math.floor(Math.random() * 65535);
|
|
93
95
|
this.elementID = `color-gradient-selector-${this.baseID}`;
|
|
@@ -391,7 +393,7 @@ export class ColorGradientSelector {
|
|
|
391
393
|
>
|
|
392
394
|
|
|
393
395
|
</div>
|
|
394
|
-
<div sx={{ w: this.css_buttonHeight, flexShrink: 2, fontSize: this.
|
|
396
|
+
<div sx={{ w: this.css_buttonHeight, flexShrink: 2, fontSize: this.css_buttonFontSize_larger }}>▾</div>
|
|
395
397
|
</button>
|
|
396
398
|
<div
|
|
397
399
|
className="positioning-container"
|
|
@@ -428,7 +430,11 @@ export class ColorGradientSelector {
|
|
|
428
430
|
#${this.elementID} button {
|
|
429
431
|
border: 0px solid lightgray;
|
|
430
432
|
padding: 0.25em;
|
|
431
|
-
background-color: rgba(255,255,255,0.9);
|
|
433
|
+
/* background-color: rgba(255,255,255,0.9); */
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
#${this.elementID} .positioning-container button {
|
|
437
|
+
border-radius: 0;
|
|
432
438
|
}
|
|
433
439
|
|
|
434
440
|
#${this.elementID} .main-button:hover {
|
|
@@ -439,6 +445,7 @@ export class ColorGradientSelector {
|
|
|
439
445
|
background-color: rgba(216,216,216,0.9);
|
|
440
446
|
}
|
|
441
447
|
|
|
448
|
+
|
|
442
449
|
`}</style>
|
|
443
450
|
);
|
|
444
451
|
};
|
|
@@ -102,10 +102,15 @@ export class FileDrop {
|
|
|
102
102
|
this.fileDroppedCallbackText = callback;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
// TODO: docs
|
|
105
106
|
onFileSVGDropped(callback: IDroppedCallbackSVG) {
|
|
106
107
|
this.fileDroppedCallbackSVG = callback;
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
onFileBinaryDropped(callback: IDroppedCallbackBinary) {
|
|
111
|
+
this.fileDroppedCallbackBinary = callback;
|
|
112
|
+
}
|
|
113
|
+
|
|
109
114
|
/**
|
|
110
115
|
* Internally handle a drop event.
|
|
111
116
|
*
|
|
@@ -17,7 +17,7 @@ export type NumericString = `${number}`;
|
|
|
17
17
|
export type BooleanString = "0" | "1" | `${boolean}`;
|
|
18
18
|
|
|
19
19
|
// Example: 'M', -10, -7.5,
|
|
20
|
-
export type SVGPathMoveToCommand = ["M" | "m", NumericString, NumericString];
|
|
20
|
+
export type SVGPathMoveToCommand = ["M" | "m", NumericString | number, NumericString | number];
|
|
21
21
|
// Example: 'L', 0, -10,
|
|
22
22
|
export type SVGPathLineToCommand = ["L" | "l", NumericString, NumericString, ...Array<NumericString>];
|
|
23
23
|
// Example: 'V', -10,
|
|
@@ -42,13 +42,13 @@ export type SVGPathQuadraticCurveToCommand =
|
|
|
42
42
|
// Example: 'C', -5, -15, 10, -15, 5, -10,
|
|
43
43
|
export type SVGPathCubicCurveToCommand = [
|
|
44
44
|
"C" | "c",
|
|
45
|
-
NumericString,
|
|
46
|
-
NumericString,
|
|
47
|
-
NumericString,
|
|
48
|
-
NumericString,
|
|
49
|
-
NumericString,
|
|
50
|
-
NumericString,
|
|
51
|
-
...Array<NumericString>
|
|
45
|
+
NumericString | number,
|
|
46
|
+
NumericString | number,
|
|
47
|
+
NumericString | number,
|
|
48
|
+
NumericString | number,
|
|
49
|
+
NumericString | number,
|
|
50
|
+
NumericString | number,
|
|
51
|
+
...Array<NumericString | number>
|
|
52
52
|
];
|
|
53
53
|
// Example: 'S', 15, 0, 10, 0,
|
|
54
54
|
export type SVGPathShorthandCubicCurveToCommand = [
|