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/dist/gridviz.js +19 -1
- package/dist/gridviz.min.js +1 -1
- package/package.json +1 -1
- package/src/core/Drawable.js +18 -0
package/package.json
CHANGED
package/src/core/Drawable.js
CHANGED
|
@@ -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
|
}
|