plotboilerplate 1.17.0 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +16 -0
- package/dist/index.esm.js +42 -9
- 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 +45 -9
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/Bounds.d.ts +11 -0
- package/src/cjs/Bounds.js +14 -0
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +3 -1
- package/src/cjs/PlotBoilerplate.js +8 -1
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/draw.d.ts +5 -2
- package/src/cjs/draw.js +10 -4
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.d.ts +4 -2
- package/src/cjs/drawgl.js +5 -2
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +4 -2
- package/src/cjs/drawutilssvg.js +8 -2
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +3 -1
- package/src/cjs/interfaces/DrawLib.js +1 -0
- package/src/cjs/interfaces/DrawLib.js.map +1 -1
- package/src/cjs/interfaces/core.d.ts +2 -0
- package/src/cjs/interfaces/core.js +1 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/utils/datastructures/Color.d.ts +3 -1
- package/src/cjs/utils/datastructures/Color.js +17 -6
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- package/src/esm/Bounds.d.ts +11 -0
- package/src/esm/Bounds.js +14 -0
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +3 -1
- package/src/esm/PlotBoilerplate.js +8 -1
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/draw.d.ts +5 -2
- package/src/esm/draw.js +9 -4
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.d.ts +4 -2
- package/src/esm/drawgl.js +4 -2
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +4 -2
- package/src/esm/drawutilssvg.js +7 -2
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +3 -1
- package/src/esm/interfaces/DrawLib.js +1 -0
- package/src/esm/interfaces/DrawLib.js.map +1 -1
- package/src/esm/interfaces/core.d.ts +2 -0
- package/src/esm/interfaces/core.js +1 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/utils/datastructures/Color.d.ts +3 -1
- package/src/esm/utils/datastructures/Color.js +17 -6
- package/src/esm/utils/datastructures/Color.js.map +1 -1
- package/src/ts/Bounds.ts +15 -0
- package/src/ts/PlotBoilerplate.ts +8 -1
- package/src/ts/draw.ts +10 -4
- package/src/ts/drawgl.ts +4 -2
- package/src/ts/drawutilssvg.ts +7 -2
- package/src/ts/interfaces/DrawLib.ts +3 -1
- package/src/ts/interfaces/core.ts +3 -2
- package/src/ts/utils/datastructures/Color.ts +17 -6
package/changelog.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
<!-- - 2022-06-21 (Midsommer)
|
|
4
|
+
- Added `Bounds.clone()`. -->
|
|
5
|
+
|
|
6
|
+
- 2022-08-01
|
|
7
|
+
- Added `title` param to the `PBParams` interface.
|
|
8
|
+
- 2022-07-26
|
|
9
|
+
- Adding `alpha` to the `draw.image(...)` function.
|
|
10
|
+
- 2022-06-02
|
|
11
|
+
- Adding the demo 42 (Hick's Hexagons).
|
|
12
|
+
- 2022-06-01
|
|
13
|
+
- Tweaked the `draw.polyline` function; lineWidth now scales with scale.x.
|
|
14
|
+
- 2022-05-11
|
|
15
|
+
- Adding new demo: raindrops.
|
|
16
|
+
- 2022-05-11
|
|
17
|
+
- Modified the `Color.clone` function by just copying the numeric calues, not re-calculating the whole color.
|
|
18
|
+
- Fixed the `Color.interpolate` function.
|
|
3
19
|
- 2022-03-27
|
|
4
20
|
- Added the `texturedPoly` function to the `DrawLib` interface.
|
|
5
21
|
- Added the `texturedPoly` function to the `drawutils` and `drawutilssvg` class.
|
package/dist/index.esm.js
CHANGED
|
@@ -1472,6 +1472,20 @@ class Bounds {
|
|
|
1472
1472
|
toString() {
|
|
1473
1473
|
return `{ min: ${this.min.toString()}, max : ${this.max.toString()}, width: ${this.width}, height : ${this.height} }`;
|
|
1474
1474
|
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Clone this bounds object (create a deep clone).
|
|
1477
|
+
*
|
|
1478
|
+
* Note: the returned format might change in the future, so please do not
|
|
1479
|
+
* rely on the returned string format.
|
|
1480
|
+
*
|
|
1481
|
+
* @method clone
|
|
1482
|
+
* @instance
|
|
1483
|
+
* @memberof Bounds
|
|
1484
|
+
* @returns {string} Creates a deep clone of this bounds object. The returned object's `min` and `max` instances are `Vertex` instances.
|
|
1485
|
+
*/
|
|
1486
|
+
// clone() {
|
|
1487
|
+
// return new Bounds(new Vertex(this.min.x, this.min.y), new Vertex(this.max.x, this.max.y));
|
|
1488
|
+
// }
|
|
1475
1489
|
/**
|
|
1476
1490
|
* Compute the minimal bounding box for a given set of vertices.
|
|
1477
1491
|
*
|
|
@@ -4228,7 +4242,8 @@ CircleSector.circleSectorUtils = {
|
|
|
4228
4242
|
* @modified 2022-02-03 Added the `cross(...)` function.
|
|
4229
4243
|
* @modified 2022-03-26 Added the private `nodeDefs` and `bufferedNodeDefs` attributes.
|
|
4230
4244
|
* @modified 2022-03-26 Added the `texturedPoly` function to draw textures polygons.
|
|
4231
|
-
* @
|
|
4245
|
+
* @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
|
|
4246
|
+
* @version 1.6.1
|
|
4232
4247
|
**/
|
|
4233
4248
|
const RAD_TO_DEG = 180 / Math.PI;
|
|
4234
4249
|
/**
|
|
@@ -4610,11 +4625,12 @@ class drawutilssvg {
|
|
|
4610
4625
|
* @param {Image} image - The image object to draw.
|
|
4611
4626
|
* @param {Vertex} position - The position to draw the the upper left corner at.
|
|
4612
4627
|
* @param {Vertex} size - The x/y-size to draw the image with.
|
|
4628
|
+
* @param {number=0.0} alpha - (optional, default=0.0) The transparency (1.0=opaque, 0.0=transparent).
|
|
4613
4629
|
* @return {void}
|
|
4614
4630
|
* @instance
|
|
4615
4631
|
* @memberof drawutilssvg
|
|
4616
4632
|
**/
|
|
4617
|
-
image(image, position, size) {
|
|
4633
|
+
image(image, position, size, alpha = 1.0) {
|
|
4618
4634
|
const node = this.makeNode("image");
|
|
4619
4635
|
// We need to re-adjust the image if it was not yet fully loaded before.
|
|
4620
4636
|
const setImageSize = (image) => {
|
|
@@ -4624,6 +4640,9 @@ class drawutilssvg {
|
|
|
4624
4640
|
node.setAttribute("width", `${image.naturalWidth * this.scale.x}`);
|
|
4625
4641
|
node.setAttribute("height", `${image.naturalHeight * this.scale.y}`);
|
|
4626
4642
|
node.setAttribute("display", null); // Dislay when loaded
|
|
4643
|
+
// if (alpha) {
|
|
4644
|
+
node.setAttribute("opacity", `${alpha}`);
|
|
4645
|
+
// }
|
|
4627
4646
|
node.setAttribute("transform", `translate(${this._x(position.x)} ${this._y(position.y)}) scale(${ratioX} ${ratioY})`);
|
|
4628
4647
|
}
|
|
4629
4648
|
};
|
|
@@ -5587,7 +5606,9 @@ drawutilssvg.HEAD_XML = [
|
|
|
5587
5606
|
* @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.
|
|
5588
5607
|
* @modified 2022-02-03 Added the `cross(...)` function.
|
|
5589
5608
|
* @modified 2022-03-27 Added the `texturedPoly` function.
|
|
5590
|
-
* @
|
|
5609
|
+
* @modified 2022-06-01 Tweaked the `polyline` function; lineWidth now scales with scale.x.
|
|
5610
|
+
* @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
|
|
5611
|
+
* @version 1.12.2
|
|
5591
5612
|
**/
|
|
5592
5613
|
// Todo: rename this class to Drawutils?
|
|
5593
5614
|
/**
|
|
@@ -5724,16 +5745,18 @@ class drawutils {
|
|
|
5724
5745
|
* @param {Image} image - The image object to draw.
|
|
5725
5746
|
* @param {Vertex} position - The position to draw the the upper left corner at.
|
|
5726
5747
|
* @param {Vertex} size - The x/y-size to draw the image with.
|
|
5748
|
+
* @param {number=0.0} alpha - (optional, default=0.0) The transparency (1.0=opaque, 0.0=transparent).
|
|
5727
5749
|
* @return {void}
|
|
5728
5750
|
* @instance
|
|
5729
5751
|
* @memberof drawutils
|
|
5730
5752
|
**/
|
|
5731
|
-
image(image, position, size) {
|
|
5753
|
+
image(image, position, size, alpha = 1.0) {
|
|
5732
5754
|
if (!image.complete || !image.naturalWidth) {
|
|
5733
5755
|
// Avoid drawing un-unloaded or broken images
|
|
5734
5756
|
return;
|
|
5735
5757
|
}
|
|
5736
5758
|
this.ctx.save();
|
|
5759
|
+
this.ctx.globalAlpha = alpha;
|
|
5737
5760
|
// Note that there is a Safari bug with the 3 or 5 params variant.
|
|
5738
5761
|
// Only the 9-param varaint works.
|
|
5739
5762
|
this.ctx.drawImage(image, 0, 0, image.naturalWidth - 1, // There is this horrible Safari bug (fixed in newer versions)
|
|
@@ -6343,11 +6366,12 @@ class drawutils {
|
|
|
6343
6366
|
* @memberof drawutils
|
|
6344
6367
|
*/
|
|
6345
6368
|
polyline(vertices, isOpen, color, lineWidth) {
|
|
6346
|
-
if (vertices.length <= 1)
|
|
6369
|
+
if (vertices.length <= 1) {
|
|
6347
6370
|
return;
|
|
6371
|
+
}
|
|
6348
6372
|
this.ctx.save();
|
|
6349
6373
|
this.ctx.beginPath();
|
|
6350
|
-
this.ctx.lineWidth = lineWidth || 1.0;
|
|
6374
|
+
this.ctx.lineWidth = lineWidth * this.scale.x || 1.0;
|
|
6351
6375
|
this.ctx.moveTo(this.offset.x + vertices[0].x * this.scale.x, this.offset.y + vertices[0].y * this.scale.y);
|
|
6352
6376
|
for (var i = 0; i < vertices.length; i++) {
|
|
6353
6377
|
this.ctx.lineTo(this.offset.x + vertices[i].x * this.scale.x, this.offset.y + vertices[i].y * this.scale.y);
|
|
@@ -6516,7 +6540,8 @@ drawutils.helpers = {
|
|
|
6516
6540
|
* @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.
|
|
6517
6541
|
* @modified 2022-02-03 Added the `cross(...)` function.
|
|
6518
6542
|
* @modified 2022-03-27 Added the `texturedPoly` function.
|
|
6519
|
-
* @
|
|
6543
|
+
* @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
|
|
6544
|
+
* @version 0.0.8
|
|
6520
6545
|
**/
|
|
6521
6546
|
/**
|
|
6522
6547
|
* @classdesc A wrapper class for basic drawing operations. This is the WebGL
|
|
@@ -6706,11 +6731,12 @@ class drawutilsgl {
|
|
|
6706
6731
|
* @param {Image} image - The image object to draw.
|
|
6707
6732
|
* @param {Vertex} position - The position to draw the the upper left corner at.
|
|
6708
6733
|
* @param {Vertex} size - The x/y-size to draw the image with.
|
|
6734
|
+
* @param {number=0.0} alpha - (optional, default=0.0) The transparency (0.0=opaque, 1.0=transparent).
|
|
6709
6735
|
* @return {void}
|
|
6710
6736
|
* @instance
|
|
6711
6737
|
* @memberof drawutils
|
|
6712
6738
|
**/
|
|
6713
|
-
image(image, position, size) {
|
|
6739
|
+
image(image, position, size, alpha = 0.0) {
|
|
6714
6740
|
// NOT YET IMPLEMENTED
|
|
6715
6741
|
}
|
|
6716
6742
|
/**
|
|
@@ -9866,7 +9892,8 @@ VEllipseSector.ellipseSectorUtils = {
|
|
|
9866
9892
|
* @modified 2021-03-29 Clearing `currentClassName` and `currentId` after drawing each drawable.
|
|
9867
9893
|
* @modified 2021-04-25 Extending `remove` to accept arrays of drawables.
|
|
9868
9894
|
* @modified 2021-11-16 Adding the `PBText` drawable.
|
|
9869
|
-
* @
|
|
9895
|
+
* @modified 2022-08-01 Added `title` to the params.
|
|
9896
|
+
* @version 1.15.1
|
|
9870
9897
|
*
|
|
9871
9898
|
* @file PlotBoilerplate
|
|
9872
9899
|
* @fileoverview The main class.
|
|
@@ -9959,6 +9986,7 @@ class PlotBoilerplate {
|
|
|
9959
9986
|
* @param {boolean=} [config.enableGL=false] - Indicates if the application should use the experimental WebGL features (not recommended).
|
|
9960
9987
|
* @param {boolean=} [config.enableSVGExport=true] - Indicates if the SVG export should be enabled (default is true).
|
|
9961
9988
|
* Note that changes from the postDraw hook might not be visible in the export.
|
|
9989
|
+
* @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
|
|
9962
9990
|
*/
|
|
9963
9991
|
constructor(config) {
|
|
9964
9992
|
/**
|
|
@@ -10174,6 +10202,11 @@ class PlotBoilerplate {
|
|
|
10174
10202
|
else {
|
|
10175
10203
|
throw "Element is neither a canvas nor an svg element.";
|
|
10176
10204
|
}
|
|
10205
|
+
// At this point the event cacher element is deinfed and located at highest elevation.
|
|
10206
|
+
// Set `title` attribut?
|
|
10207
|
+
if (config.title) {
|
|
10208
|
+
this.eventCatcher.setAttribute("title", config.title);
|
|
10209
|
+
}
|
|
10177
10210
|
this.draw.scale.set(this.config.scaleX, this.config.scaleY);
|
|
10178
10211
|
this.fill.scale.set(this.config.scaleX, this.config.scaleY);
|
|
10179
10212
|
this.vertices = [];
|