plotboilerplate 1.26.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 +2 -0
- package/dist/index.esm.js +33 -11
- 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 +33 -11
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +6 -2
- 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 +9 -4
- package/src/cjs/drawutilssvg.js +20 -5
- 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/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/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/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/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/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 +9 -4
- package/src/esm/drawutilssvg.js +20 -5
- 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/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/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/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/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/ts/PlotBoilerplate.ts +4 -3
- package/src/ts/draw.ts +8 -3
- package/src/ts/drawgl.ts +3 -2
- package/src/ts/drawutilssvg.ts +27 -5
- package/src/ts/interfaces/DrawLib.ts +3 -0
- package/src/ts/utils/WebColors.ts +20 -33
- package/src/ts/utils/algorithms/PolygonTesselationOutlines.ts +296 -0
- package/src/ts/utils/datastructures/Color.ts +0 -19
- package/src/ts/utils/datastructures/ColorGradient.ts +6 -0
- package/src/ts/utils/datastructures/Girih.ts +78 -1
- package/src/ts/utils/datastructures/interfaces.ts +4 -4
- package/src/ts/utils/io/FileDrop.ts +5 -0
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @author Ikaros Kappler
|
|
9
9
|
* @version 1.0.0
|
|
10
10
|
* @date 2025-08-05
|
|
11
|
+
* @modified 2025-11-26 Fixing a bug in `ColorGradient.getColorAt(ratio)`: value at 1.0 caused runtime error.
|
|
11
12
|
*/
|
|
12
13
|
import { Color } from "./Color";
|
|
13
14
|
const RAD_TO_DEG = 180.0 / Math.PI;
|
|
@@ -68,6 +69,9 @@ export class ColorGradient {
|
|
|
68
69
|
const intervalLocation = this.locateClosestRatio(ratio);
|
|
69
70
|
const leftItem = this.values[intervalLocation[0]];
|
|
70
71
|
const rightItem = this.values[intervalLocation[0] + 1];
|
|
72
|
+
if (!rightItem) {
|
|
73
|
+
return leftItem.color.clone();
|
|
74
|
+
}
|
|
71
75
|
const relativeInnerIntervalPosition = (ratio - leftItem.ratio) / (rightItem.ratio - leftItem.ratio);
|
|
72
76
|
return leftItem.color.clone().interpolate(rightItem.color, relativeInnerIntervalPosition);
|
|
73
77
|
}
|
|
@@ -163,4 +167,5 @@ export class ColorGradient {
|
|
|
163
167
|
], angleInRadians);
|
|
164
168
|
}
|
|
165
169
|
}
|
|
170
|
+
ColorGradient.DEFAULT_COLORSET = DEFAULT_COLORSET;
|
|
166
171
|
//# sourceMappingURL=ColorGradient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorGradient.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/ColorGradient.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ColorGradient.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/ColorGradient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,UAAU,GAAW,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC;AAI3C,MAAM,gBAAgB,GAA6B;IACjD,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;IAChC,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;IACjC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE;IACnC,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE;IACtC,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE;IACvC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE;CACpC,CAAC;AAOF,MAAM,OAAO,aAAa;IAMxB;;;;;;OAMG;IACH,YAAY,MAAgC,EAAE,KAA6B;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,yBAAyB;QACzB,IAAI,CAAC,KAAK,GAAG,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;IACpE,CAAC;IAED;;;;;;OAMG;IACI,qBAAqB;QAC1B,WAAW;QACX,wIAAwI;QAExI,kGAAkG;QAClG,MAAM,MAAM,GAA8B;YACxC,oBAAoB,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAA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CAAC;QACvH,CAAC,CAAC,CAAC;QACH,gCAAgC;QAChC,OAAO,IAAI,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACI,KAAK;QACV,OAAO,IAAI,aAAa,CACtB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAuB,EAAE,EAAE;YAC1C,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAClD,CAAC,CAAC,EACF,IAAI,CAAC,KAAK,CACX,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,aAAa;QACzB,OAAO,IAAI,aAAa,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAuB,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1H,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,UAAU,CAAC,UAAiB,EAAE,QAAe,EAAE,cAAuB;QAClF,OAAO,IAAI,aAAa,CACtB;YACE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE;YACjC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE;SAChC,EACD,cAAc,CACf,CAAC;IACJ,CAAC;;AAnKM,8BAAgB,GAAG,gBAAgB,CAAC"}
|
|
@@ -3,11 +3,15 @@
|
|
|
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
|
import { Vertex } from "../../Vertex";
|
|
10
13
|
import { GirihTile } from "./GirihTile";
|
|
14
|
+
import { XYCoords } from "../../interfaces";
|
|
11
15
|
/**
|
|
12
16
|
* @classdesc The Girih datastructure for generating patterns.
|
|
13
17
|
*
|
|
@@ -88,10 +92,30 @@ export declare class Girih {
|
|
|
88
92
|
*/
|
|
89
93
|
removeTileAt(index: number): void;
|
|
90
94
|
/**
|
|
95
|
+
* Remove all tiles.
|
|
96
|
+
*
|
|
97
|
+
* @name removeAllTiles
|
|
98
|
+
* @memberof Girih
|
|
99
|
+
* @instance
|
|
100
|
+
* @return {void}
|
|
101
|
+
*/
|
|
102
|
+
removeAllTiles(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Replace all current tiles with the given ones.
|
|
91
105
|
*
|
|
92
106
|
* @param tiles
|
|
93
107
|
*/
|
|
94
108
|
replaceTiles(tiles: GirihTile[]): void;
|
|
109
|
+
/**
|
|
110
|
+
* Find the tile with the given center.
|
|
111
|
+
*
|
|
112
|
+
* @name getTileByCenter
|
|
113
|
+
* @memberof Girih
|
|
114
|
+
* @instance
|
|
115
|
+
* @param {XYCoords} center - The center point to look for.
|
|
116
|
+
* @return {GirihTile} The tile or null if not found.
|
|
117
|
+
*/
|
|
118
|
+
getTileByCenter(center: XYCoords): GirihTile;
|
|
95
119
|
/**
|
|
96
120
|
* Find that tile (index) which contains the given position. First match will be returned.
|
|
97
121
|
*
|
|
@@ -102,6 +126,19 @@ export declare class Girih {
|
|
|
102
126
|
* @return {number} The index of the containing tile or -1 if none was found.
|
|
103
127
|
**/
|
|
104
128
|
locateConatiningTile(position: Vertex): number;
|
|
129
|
+
/**
|
|
130
|
+
* Find find a tile-edge-pair (indices) that contain the given position. First match will be returned.
|
|
131
|
+
*
|
|
132
|
+
* @name locateContainingTileAndEdge
|
|
133
|
+
* @memberof Girih
|
|
134
|
+
* @instance
|
|
135
|
+
* @param {Vertex} position
|
|
136
|
+
* @return {{ tileIndex: number; edgeIndex: number }} The index of the containing tile and edge or null if none was found.
|
|
137
|
+
**/
|
|
138
|
+
locateContainingTileAndEdge(position: any): {
|
|
139
|
+
tileIndex: number;
|
|
140
|
+
edgeIndex: number;
|
|
141
|
+
};
|
|
105
142
|
/**
|
|
106
143
|
* Turn the tile the mouse is hovering over.
|
|
107
144
|
* The turnCount is ab abstract number: -1 for one turn left, +1 for one turn right.
|
|
@@ -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
|
import { Vertex } from "../../Vertex";
|
|
@@ -94,6 +97,18 @@ export class Girih {
|
|
|
94
97
|
this.tiles.splice(index, 1);
|
|
95
98
|
}
|
|
96
99
|
/**
|
|
100
|
+
* Remove all tiles.
|
|
101
|
+
*
|
|
102
|
+
* @name removeAllTiles
|
|
103
|
+
* @memberof Girih
|
|
104
|
+
* @instance
|
|
105
|
+
* @return {void}
|
|
106
|
+
*/
|
|
107
|
+
removeAllTiles() {
|
|
108
|
+
this.tiles.splice(0, this.tiles.length);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Replace all current tiles with the given ones.
|
|
97
112
|
*
|
|
98
113
|
* @param tiles
|
|
99
114
|
*/
|
|
@@ -103,6 +118,24 @@ export class Girih {
|
|
|
103
118
|
this.addTile(tiles[i]);
|
|
104
119
|
}
|
|
105
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Find the tile with the given center.
|
|
123
|
+
*
|
|
124
|
+
* @name getTileByCenter
|
|
125
|
+
* @memberof Girih
|
|
126
|
+
* @instance
|
|
127
|
+
* @param {XYCoords} center - The center point to look for.
|
|
128
|
+
* @return {GirihTile} The tile or null if not found.
|
|
129
|
+
*/
|
|
130
|
+
getTileByCenter(center) {
|
|
131
|
+
for (var i = 0; i < this.tiles.length; i++) {
|
|
132
|
+
const pos = this.tiles[i].position;
|
|
133
|
+
if (pos === center || (pos.x == center.x && pos.y == center.y)) {
|
|
134
|
+
return this.tiles[i];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
106
139
|
/**
|
|
107
140
|
* Find that tile (index) which contains the given position. First match will be returned.
|
|
108
141
|
*
|
|
@@ -119,6 +152,43 @@ export class Girih {
|
|
|
119
152
|
}
|
|
120
153
|
return -1;
|
|
121
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Find find a tile-edge-pair (indices) that contain the given position. First match will be returned.
|
|
157
|
+
*
|
|
158
|
+
* @name locateContainingTileAndEdge
|
|
159
|
+
* @memberof Girih
|
|
160
|
+
* @instance
|
|
161
|
+
* @param {Vertex} position
|
|
162
|
+
* @return {{ tileIndex: number; edgeIndex: number }} The index of the containing tile and edge or null if none was found.
|
|
163
|
+
**/
|
|
164
|
+
locateContainingTileAndEdge(position) {
|
|
165
|
+
var containedTileIndex = this.locateConatiningTile(position);
|
|
166
|
+
// Reset currently highlighted tile/edge (if re-detected nothing changed in the end)
|
|
167
|
+
var hoverTileIndex = -1;
|
|
168
|
+
var hoverEdgeIndex = -1;
|
|
169
|
+
// Find Girih edge nearby ...
|
|
170
|
+
if (containedTileIndex == -1) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
var i = containedTileIndex;
|
|
174
|
+
do {
|
|
175
|
+
var tile = this.tiles[i];
|
|
176
|
+
// May be -1
|
|
177
|
+
hoverEdgeIndex = tile.locateEdgeAtPoint(position, this.edgeLength / 2);
|
|
178
|
+
if (hoverEdgeIndex != -1) {
|
|
179
|
+
hoverTileIndex = i;
|
|
180
|
+
}
|
|
181
|
+
i++;
|
|
182
|
+
} while (i < this.tiles.length && containedTileIndex == -1 && hoverEdgeIndex == -1);
|
|
183
|
+
if (hoverTileIndex == -1) {
|
|
184
|
+
hoverTileIndex = containedTileIndex;
|
|
185
|
+
}
|
|
186
|
+
// Find the next possible tile to place?
|
|
187
|
+
if (hoverTileIndex == -1 || hoverEdgeIndex == -1) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
return { tileIndex: hoverTileIndex, edgeIndex: hoverEdgeIndex };
|
|
191
|
+
}
|
|
122
192
|
/**
|
|
123
193
|
* Turn the tile the mouse is hovering over.
|
|
124
194
|
* The turnCount is ab abstract number: -1 for one turn left, +1 for one turn right.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Girih.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/Girih.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Girih.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/Girih.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;IAUI;AAEJ,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;;;;;;;;;GAWG;AACH,MA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;IACH,yBAAyB,CAAC,SAAiB,EAAE,SAAiB;QAC5D,IAAI,QAAQ,GAAqB,EAAE,CAAC;QACpC,IAAI,SAAS,IAAI,CAAC,CAAC,IAAI,SAAS,IAAI,CAAC,CAAC;YACpC,wBAAwB;YACxB,OAAO,EAAE,CAAC;QAEZ,IAAI,QAAQ,GAAqB,IAAI,CAAC;QACtC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAClC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YAC1C,0DAA0D;YAC1D,MAAM,UAAU,GAAqB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,0BAA0B,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAC3G,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBAC3B,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;QACD,6BAA6B;QAC7B,2EAA2E;QAC3E,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC,kBAAkB"}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
type IDroppedCallbackJSON = (jsonData: object) => void;
|
|
20
20
|
type IDroppedCallbackText = (textData: string) => void;
|
|
21
21
|
type IDroppedCallbackSVG = (svgDocument: Document) => void;
|
|
22
|
+
type IDroppedCallbackBinary = (binaryData: Blob, file: File) => void;
|
|
22
23
|
export declare class FileDrop {
|
|
23
24
|
/**
|
|
24
25
|
* The 'dropzone' element.
|
|
@@ -81,6 +82,7 @@ export declare class FileDrop {
|
|
|
81
82
|
*/
|
|
82
83
|
onFileTextDropped(callback: IDroppedCallbackText): void;
|
|
83
84
|
onFileSVGDropped(callback: IDroppedCallbackSVG): void;
|
|
85
|
+
onFileBinaryDropped(callback: IDroppedCallbackBinary): void;
|
|
84
86
|
/**
|
|
85
87
|
* Internally handle a drop event.
|
|
86
88
|
*
|
|
@@ -152,9 +152,13 @@ export class FileDrop {
|
|
|
152
152
|
onFileTextDropped(callback) {
|
|
153
153
|
this.fileDroppedCallbackText = callback;
|
|
154
154
|
}
|
|
155
|
+
// TODO: docs
|
|
155
156
|
onFileSVGDropped(callback) {
|
|
156
157
|
this.fileDroppedCallbackSVG = callback;
|
|
157
158
|
}
|
|
159
|
+
onFileBinaryDropped(callback) {
|
|
160
|
+
this.fileDroppedCallbackBinary = callback;
|
|
161
|
+
}
|
|
158
162
|
/**
|
|
159
163
|
* Removes all listeners (drop, dragover and dragleave).
|
|
160
164
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDrop.js","sourceRoot":"","sources":["../../../ts/utils/io/FileDrop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,MAAM,OAAO,QAAQ;IAyCnB;;;OAGG;IACH,YAAY,OAAoB;
|
|
1
|
+
{"version":3,"file":"FileDrop.js","sourceRoot":"","sources":["../../../ts/utils/io/FileDrop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,MAAM,OAAO,QAAQ;IAyCnB;;;OAGG;IACH,YAAY,OAAoB;QA4ChC;;;;;WAKG;QACK,oBAAe,GAAG,CAAC,KAAgB,EAAE,EAAE;YAC7C,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;YAEnC,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9F,wBAAwB;gBACxB,OAAO;YACT,CAAC;YACD,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAA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AC1C,CAAC;IAED,aAAa;IACb,gBAAgB,CAAC,QAA6B;QAC5C,IAAI,CAAC,sBAAsB,GAAG,QAAQ,CAAC;IACzC,CAAC;IAED,mBAAmB,CAAC,QAAgC;QAClD,IAAI,CAAC,yBAAyB,GAAG,QAAQ,CAAC;IAC5C,CAAC;IAwGD;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACvE,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC3E,CAAC;CACF"}
|
|
@@ -91,8 +91,9 @@
|
|
|
91
91
|
* @modified 2025-05-07 Added `PlogBoilerplate.addContentChangeListener` and `.removeContentChangeListener`.
|
|
92
92
|
* @modified 2025-05-07 Moving full vectors now by default when vector point a is moved.
|
|
93
93
|
* @modified 2025-05-20 Applying `lineWith` parameter in the draw routine for vectors (had been missing).
|
|
94
|
+
* @modified 2026-03-13 Changed visibility of `setZoom` and `setOffset` to public. There was no good reason to have the private.
|
|
94
95
|
*
|
|
95
|
-
* @version 1.21.
|
|
96
|
+
* @version 1.21.2
|
|
96
97
|
*
|
|
97
98
|
* @file PlotBoilerplate
|
|
98
99
|
* @fileoverview The main class.
|
|
@@ -2103,7 +2104,7 @@ export class PlotBoilerplate {
|
|
|
2103
2104
|
*
|
|
2104
2105
|
* @param {Vertex} newOffset - The new draw offset to use.
|
|
2105
2106
|
**/
|
|
2106
|
-
|
|
2107
|
+
public setOffset(newOffset: XYCoords) {
|
|
2107
2108
|
this.draw.offset.set(newOffset);
|
|
2108
2109
|
this.fill.offset.set(newOffset);
|
|
2109
2110
|
this.config.offsetX = newOffset.x;
|
|
@@ -2119,7 +2120,7 @@ export class PlotBoilerplate {
|
|
|
2119
2120
|
* @param {number} zoomFactorY - The new vertical zoom value.
|
|
2120
2121
|
* @param {Vertex} interactionPos - The position of mouse/touch interaction.
|
|
2121
2122
|
**/
|
|
2122
|
-
|
|
2123
|
+
public setZoom(zoomFactorX: number, zoomFactorY: number, interactionPos: Vertex) {
|
|
2123
2124
|
let oldPos: XYCoords = this.transformMousePosition(interactionPos.x, interactionPos.y);
|
|
2124
2125
|
this.draw.scale.x = this.fill.scale.x = this.config.scaleX = Math.max(zoomFactorX, 0.01);
|
|
2125
2126
|
this.draw.scale.y = this.fill.scale.y = this.config.scaleY = Math.max(zoomFactorY, 0.01);
|
package/src/ts/draw.ts
CHANGED
|
@@ -57,7 +57,9 @@
|
|
|
57
57
|
* @modified 2023-09-30 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
|
|
58
58
|
* @modified 2023-10-07 Adding the optional `arrowHeadBasePositionBuffer` param to the arrowHead(...) method.
|
|
59
59
|
* @modified 2024-09-13 Remoed the scaling of `lineWidth` in the `polygon` and `polyline` methods. This makes no sense here and doesn't match up with the behavior of other line functions.
|
|
60
|
-
* @
|
|
60
|
+
* @modified 2026-01-04 Adding `lineJoin` attribute to the `StrokeOptions`.
|
|
61
|
+
* @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
|
|
62
|
+
* @version 1.14.0
|
|
61
63
|
**/
|
|
62
64
|
|
|
63
65
|
import { CubicBezierCurve } from "./CubicBezierCurve";
|
|
@@ -140,6 +142,7 @@ export class drawutils implements DrawLib<void> {
|
|
|
140
142
|
})
|
|
141
143
|
);
|
|
142
144
|
this.ctx.lineDashOffset = (strokeOptions?.dashOffset ?? 0) * this.scale.x;
|
|
145
|
+
this.ctx.lineJoin = strokeOptions?.lineJoin ?? null;
|
|
143
146
|
}
|
|
144
147
|
|
|
145
148
|
// +---------------------------------------------------------------------------------
|
|
@@ -698,7 +701,7 @@ export class drawutils implements DrawLib<void> {
|
|
|
698
701
|
* @instance
|
|
699
702
|
* @memberof drawutils
|
|
700
703
|
*/
|
|
701
|
-
cubicBezierPath(path: Array<XYCoords>, color: string, lineWidth?: number, strokeOptions?: StrokeOptions) {
|
|
704
|
+
cubicBezierPath(path: Array<XYCoords>, color: string, lineWidth?: number, strokeOptions?: StrokeOptions, isOpen?: boolean) {
|
|
702
705
|
if (!path || path.length == 0) {
|
|
703
706
|
return;
|
|
704
707
|
}
|
|
@@ -723,7 +726,9 @@ export class drawutils implements DrawLib<void> {
|
|
|
723
726
|
this.offset.y + endPoint.y * this.scale.y
|
|
724
727
|
);
|
|
725
728
|
}
|
|
726
|
-
|
|
729
|
+
if (!isOpen) {
|
|
730
|
+
this.ctx.closePath();
|
|
731
|
+
}
|
|
727
732
|
this.ctx.lineWidth = lineWidth || 1;
|
|
728
733
|
this._fillOrDraw(color);
|
|
729
734
|
this.ctx.restore();
|
package/src/ts/drawgl.ts
CHANGED
|
@@ -16,12 +16,13 @@
|
|
|
16
16
|
* @modified 2023-09-29 Added the `arrowHead(...)` function to the 'DrawLib.arrow()` interface.
|
|
17
17
|
* @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
|
|
18
18
|
* @modified 2023-09-29 Added the `lineDashes` attribute.
|
|
19
|
+
* @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
|
|
19
20
|
* @version 0.0.10
|
|
20
21
|
**/
|
|
21
22
|
|
|
22
23
|
import { Polygon } from "./Polygon";
|
|
23
24
|
import { Vertex } from "./Vertex";
|
|
24
|
-
import { DrawLib, XYCoords, SVGPathParams, UID, DrawLibConfiguration, FontStyle, FontWeight } from "./interfaces";
|
|
25
|
+
import { DrawLib, XYCoords, SVGPathParams, UID, DrawLibConfiguration, FontStyle, FontWeight, StrokeOptions } from "./interfaces";
|
|
25
26
|
import { Bounds } from "./Bounds";
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -426,7 +427,7 @@ export class drawutilsgl implements DrawLib<void> {
|
|
|
426
427
|
* @instance
|
|
427
428
|
* @memberof drawutils
|
|
428
429
|
*/
|
|
429
|
-
cubicBezierPath(path: Array<XYCoords>, color: string, lineWidth?: number) {
|
|
430
|
+
cubicBezierPath(path: Array<XYCoords>, color: string, lineWidth?: number, strokeOptions?: StrokeOptions, isOpen?: boolean) {
|
|
430
431
|
// NOT YET IMPLEMENTED
|
|
431
432
|
}
|
|
432
433
|
|
package/src/ts/drawutilssvg.ts
CHANGED
|
@@ -48,7 +48,10 @@
|
|
|
48
48
|
* @modified 2024-03-10 Fixing some types for Typescript 5 compatibility.
|
|
49
49
|
* @modified 2024-07-24 Caching custom style defs in a private buffer variable.
|
|
50
50
|
* @modified 2025-11-14 Fixing a bug in the CSS `mix-blend-mode` property handling (caused a runtime error).
|
|
51
|
-
* @
|
|
51
|
+
* @modified 2026-01-04 Adding `lineJoin` attribute to the methods' `StrokeOptions` param.
|
|
52
|
+
* @modified 2026-01-04 Fixing missing `strokeOptions` param in the `drawutilssvg.polygon` method.
|
|
53
|
+
* @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
|
|
54
|
+
* @version 1.7.0
|
|
52
55
|
**/
|
|
53
56
|
|
|
54
57
|
import { CircleSector } from "./CircleSector";
|
|
@@ -655,6 +658,7 @@ export class drawutilssvg implements DrawLib<void | SVGElement> {
|
|
|
655
658
|
* @param {StrokeOptions=} strokeOptions -
|
|
656
659
|
*/
|
|
657
660
|
private applyStrokeOpts(node: SVGElement, strokeOptions?: StrokeOptions) {
|
|
661
|
+
// Set line dash options?
|
|
658
662
|
if (
|
|
659
663
|
strokeOptions &&
|
|
660
664
|
strokeOptions.dashArray &&
|
|
@@ -673,6 +677,10 @@ export class drawutilssvg implements DrawLib<void | SVGElement> {
|
|
|
673
677
|
node.setAttribute("stroke-dashoffset", `${strokeOptions.dashOffset * this.scale.x}`);
|
|
674
678
|
}
|
|
675
679
|
}
|
|
680
|
+
// Set line join option?
|
|
681
|
+
if (strokeOptions && strokeOptions.lineJoin && drawutilssvg.nodeSupportsLineJoin(node.tagName)) {
|
|
682
|
+
node.setAttribute("stroke-linejoin", strokeOptions.lineJoin);
|
|
683
|
+
}
|
|
676
684
|
}
|
|
677
685
|
|
|
678
686
|
private _x(x: number): number {
|
|
@@ -1003,12 +1011,18 @@ export class drawutilssvg implements DrawLib<void | SVGElement> {
|
|
|
1003
1011
|
* @param {string} color - The CSS colot to draw the path with.
|
|
1004
1012
|
* @param {number=1} lineWidth - (optional) The line width to use.
|
|
1005
1013
|
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
1006
|
-
*
|
|
1014
|
+
* @param {boolean} isOpen - (optional) Set to tur if the path should not be closed.
|
|
1007
1015
|
* @return {void}
|
|
1008
1016
|
* @instance
|
|
1009
1017
|
* @memberof drawutilssvg
|
|
1010
1018
|
*/
|
|
1011
|
-
cubicBezierPath(
|
|
1019
|
+
cubicBezierPath(
|
|
1020
|
+
path: Array<XYCoords>,
|
|
1021
|
+
color: string,
|
|
1022
|
+
lineWidth?: number,
|
|
1023
|
+
strokeOptions?: StrokeOptions,
|
|
1024
|
+
isOpen?: boolean
|
|
1025
|
+
): SVGElement {
|
|
1012
1026
|
const node: SVGElement = this.makeNode("path");
|
|
1013
1027
|
this.applyStrokeOpts(node, strokeOptions);
|
|
1014
1028
|
if (!path || path.length == 0) {
|
|
@@ -1036,6 +1050,9 @@ export class drawutilssvg implements DrawLib<void | SVGElement> {
|
|
|
1036
1050
|
this._y(endPoint.y)
|
|
1037
1051
|
);
|
|
1038
1052
|
}
|
|
1053
|
+
if (!isOpen) {
|
|
1054
|
+
d.push("Z");
|
|
1055
|
+
}
|
|
1039
1056
|
node.setAttribute("d", d.join(" "));
|
|
1040
1057
|
return this._bindFillDraw(node, "cubicBezierPath", color, lineWidth || 1);
|
|
1041
1058
|
}
|
|
@@ -1537,12 +1554,13 @@ export class drawutilssvg implements DrawLib<void | SVGElement> {
|
|
|
1537
1554
|
* @param {Polygon} polygon - The polygon to draw.
|
|
1538
1555
|
* @param {string} color - The CSS color to draw the polygon with.
|
|
1539
1556
|
* @param {number=} lineWidth - (optional) The line width to use; default is 1.
|
|
1557
|
+
* @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
|
|
1540
1558
|
* @return {void}
|
|
1541
1559
|
* @instance
|
|
1542
1560
|
* @memberof drawutilssvg
|
|
1543
1561
|
*/
|
|
1544
|
-
polygon(polygon: Polygon, color: string, lineWidth?: number): SVGElement {
|
|
1545
|
-
return this.polyline(polygon.vertices, polygon.isOpen, color, lineWidth);
|
|
1562
|
+
polygon(polygon: Polygon, color: string, lineWidth?: number, strokeOptions?: StrokeOptions): SVGElement {
|
|
1563
|
+
return this.polyline(polygon.vertices, polygon.isOpen, color, lineWidth, strokeOptions);
|
|
1546
1564
|
}
|
|
1547
1565
|
|
|
1548
1566
|
/**
|
|
@@ -1961,6 +1979,10 @@ export class drawutilssvg implements DrawLib<void | SVGElement> {
|
|
|
1961
1979
|
return ["line", "path", "circle", "ellipse", "rectangle", "rect"].includes(nodeName);
|
|
1962
1980
|
}
|
|
1963
1981
|
|
|
1982
|
+
private static nodeSupportsLineJoin(nodeName: string) {
|
|
1983
|
+
return ["line", "path", "circle", "ellipse", "rectangle", "rect"].includes(nodeName);
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1964
1986
|
/**
|
|
1965
1987
|
* Creates a basic <line> node with start and end coordinates. The created node will not
|
|
1966
1988
|
* be bound to any root node.
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
|
|
26
26
|
* @modified 2023-09-29 Added the `lineDashes` attribute.
|
|
27
27
|
* @modified 2023-09-30 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
|
|
28
|
+
* @modified 2026-01-04 Adding optional `lineJoin` attribute to the `StrokeOptions` interface.
|
|
28
29
|
**/
|
|
29
30
|
|
|
30
31
|
import { Bounds } from "../Bounds";
|
|
@@ -68,6 +69,8 @@ export interface FontOptions {
|
|
|
68
69
|
export interface StrokeOptions {
|
|
69
70
|
dashOffset?: number;
|
|
70
71
|
dashArray?: Array<number>;
|
|
72
|
+
// SVG has more options for this: arcs | bevel | miter | miter-clip | round
|
|
73
|
+
lineJoin?: "round" | "bevel" | "miter";
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
/**
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @author Ikaros Kappler
|
|
3
|
-
* @version 1.0.1
|
|
4
3
|
* @date 2018-11-10
|
|
5
4
|
* @modified 2020-10-23 Ported to Typescript.
|
|
6
5
|
* @modified 2020-10-30 Exporting each color under its name globally.
|
|
6
|
+
* @modified 2025-12-08 Replaying self defined colors by official web colors.
|
|
7
|
+
* @version 1.0.2
|
|
7
8
|
**/
|
|
8
9
|
|
|
9
10
|
import { Color } from "./datastructures/Color";
|
|
10
11
|
|
|
11
|
-
export const Red
|
|
12
|
-
export const Pink
|
|
13
|
-
export const Purple
|
|
14
|
-
export const DeepPurple
|
|
15
|
-
export const Indigo
|
|
16
|
-
export const Blue
|
|
17
|
-
export const LightBlue
|
|
18
|
-
export const Cyan
|
|
19
|
-
export const Teal
|
|
20
|
-
export const Green
|
|
21
|
-
export const LightGreen
|
|
22
|
-
|
|
12
|
+
export const Red: Color = Color.Red; // Color.makeRGB(255,67,55);
|
|
13
|
+
export const Pink: Color = Color.Pink; // Color.makeRGB(232,31,100);
|
|
14
|
+
export const Purple: Color = Color.Purple; // Color.makeRGB(156,39,175);
|
|
15
|
+
export const DeepPurple: Color = Color.DeepPink; // Color.makeRGB(103,59,184);
|
|
16
|
+
export const Indigo: Color = Color.Indigo; // Color.makeRGB(64,81,181);
|
|
17
|
+
export const Blue: Color = Color.Blue; // Color.makeRGB(35,151,245);
|
|
18
|
+
export const LightBlue: Color = Color.LightBlue; // Color.makeRGB(6,170,245);
|
|
19
|
+
export const Cyan: Color = Color.Cyan; // Color.makeRGB(3,189,214);
|
|
20
|
+
export const Teal: Color = Color.Teal; // Color.makeRGB(1,150,137);
|
|
21
|
+
export const Green: Color = Color.Green; // Color.makeRGB(77,175,82);
|
|
22
|
+
export const LightGreen: Color = Color.LightGreen; // Color.makeRGB(141,195,67);
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* A set of beautiful web colors (I know, beauty is in the eye of the beholder).
|
|
@@ -30,28 +30,15 @@ export const LightGreen : Color = Color.makeRGB(141,195,67);
|
|
|
30
30
|
* @requires Color
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
|
-
export const WebColors
|
|
34
|
-
Red,
|
|
35
|
-
Pink,
|
|
36
|
-
Purple,
|
|
37
|
-
DeepPurple,
|
|
38
|
-
Indigo,
|
|
39
|
-
Blue,
|
|
40
|
-
LightBlue,
|
|
41
|
-
Cyan,
|
|
42
|
-
Teal,
|
|
43
|
-
Green,
|
|
44
|
-
LightGreen
|
|
45
|
-
];
|
|
46
|
-
|
|
33
|
+
export const WebColors: Array<Color> = [Red, Pink, Purple, DeepPurple, Indigo, Blue, LightBlue, Cyan, Teal, Green, LightGreen];
|
|
47
34
|
|
|
48
35
|
/**
|
|
49
36
|
* A helper function to shuffle the colors into a new order.
|
|
50
37
|
*/
|
|
51
|
-
export const shuffleWebColors = (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
export const shuffleWebColors = (order: Array<number>) => {
|
|
39
|
+
const result: Array<Color> = Array(order.length);
|
|
40
|
+
for (var i = 0; i < order.length; i++) {
|
|
41
|
+
result[i] = WebColors[order[i] % WebColors.length];
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
57
44
|
};
|