gridviz 3.0.20 → 3.0.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gridviz",
3
- "version": "3.0.20",
3
+ "version": "3.0.21",
4
4
  "description": "Visualization tool for gridded statistics",
5
5
  "keywords": [
6
6
  "statistics",
@@ -34,6 +34,8 @@ export class Drawable {
34
34
 
35
35
  /** @type {(function(number):string)|undefined} */
36
36
  this.filterColor = opts.filterColor // (z) => "#eee7"
37
+ /** @type {(function(number):GlobalCompositeOperation|"none")|undefined} */
38
+ this.filterBlendOperation = opts.filterBlendOperation // (z) => "multiply"
37
39
  }
38
40
 
39
41
  /**
@@ -54,7 +56,23 @@ export class Drawable {
54
56
  if (!fc || fc == 'none') return
55
57
 
56
58
  //draw filter
59
+
60
+ //set color
57
61
  geoCanvas.offscreenCtx.fillStyle = fc
62
+
63
+ //save blend mode and set new, if any
64
+ let bo = undefined, bo2 = undefined
65
+ if (this.filterBlendOperation) {
66
+ bo = geoCanvas.offscreenCtx.globalCompositeOperation
67
+ bo2 = this.filterBlendOperation(geoCanvas.view.z)
68
+ }
69
+ if (bo2 && bo2 != "none") geoCanvas.offscreenCtx.globalCompositeOperation = bo2;
70
+
71
+ //draw
58
72
  geoCanvas.offscreenCtx.fillRect(0, 0, geoCanvas.w, geoCanvas.h)
73
+
74
+ //restore blend mode
75
+ if (bo) geoCanvas.offscreenCtx.globalCompositeOperation = bo;
76
+
59
77
  }
60
78
  }