plotboilerplate 1.17.1 → 1.18.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/src/ts/draw.ts CHANGED
@@ -44,7 +44,10 @@
44
44
  * @modified 2022-03-27 Added the `texturedPoly` function.
45
45
  * @modified 2022-06-01 Tweaked the `polyline` function; lineWidth now scales with scale.x.
46
46
  * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
47
- * @version 1.12.2
47
+ * @modified 2022-08-23 Fixed a type issue in the `polyline` function.
48
+ * @modified 2022-08-23 Fixed a type issue in the `setConfiguration` function.
49
+ * @modified 2022-08-23 Fixed a type issue in the `path` function.
50
+ * @version 1.12.3
48
51
  **/
49
52
 
50
53
  import { CubicBezierCurve } from "./CubicBezierCurve";
@@ -141,7 +144,7 @@ export class drawutils implements DrawLib<void> {
141
144
  * @param {DrawLibConfiguration} configuration - The new configuration settings to use for the next render methods.
142
145
  */
143
146
  setConfiguration(configuration: DrawLibConfiguration): void {
144
- this.ctx.globalCompositeOperation = configuration.blendMode;
147
+ this.ctx.globalCompositeOperation = configuration.blendMode || "source-over";
145
148
  }
146
149
 
147
150
  /**
@@ -1012,7 +1015,7 @@ export class drawutils implements DrawLib<void> {
1012
1015
  }
1013
1016
  this.ctx.save();
1014
1017
  this.ctx.beginPath();
1015
- this.ctx.lineWidth = lineWidth * this.scale.x || 1.0;
1018
+ this.ctx.lineWidth = (lineWidth || 1.0) * this.scale.x;
1016
1019
  this.ctx.moveTo(this.offset.x + vertices[0].x * this.scale.x, this.offset.y + vertices[0].y * this.scale.y);
1017
1020
  for (var i = 0; i < vertices.length; i++) {
1018
1021
  this.ctx.lineTo(this.offset.x + vertices[i].x * this.scale.x, this.offset.y + vertices[i].y * this.scale.y);
@@ -1147,13 +1150,19 @@ export class drawutils implements DrawLib<void> {
1147
1150
  path(pathData: SVGPathParams, color?: string, lineWidth?: number, options?: { inplace?: boolean }) {
1148
1151
  const d: SVGPathParams = options && options.inplace ? pathData : drawutilssvg.copyPathData(pathData);
1149
1152
  drawutilssvg.transformPathData(d, this.offset, this.scale);
1150
- this.ctx.strokeStyle = color;
1153
+ if (color) {
1154
+ this.ctx.strokeStyle = color;
1155
+ }
1151
1156
  this.ctx.lineWidth = lineWidth || 1;
1152
1157
  if (this.fillShapes) {
1153
- this.ctx.fillStyle = color;
1158
+ if (color) {
1159
+ this.ctx.fillStyle = color;
1160
+ }
1154
1161
  this.ctx.fill(new Path2D(d.join(" ")));
1155
1162
  } else {
1156
- this.ctx.strokeStyle = color;
1163
+ if (color) {
1164
+ this.ctx.strokeStyle = color;
1165
+ }
1157
1166
  this.ctx.stroke(new Path2D(d.join(" ")));
1158
1167
  }
1159
1168
  }