gridviz 2.0.49 → 2.0.50

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": "2.0.49",
3
+ "version": "2.0.50",
4
4
  "description": "Visualization tool for gridded statistics",
5
5
  "keywords": [
6
6
  "statistics",
package/src/App.js CHANGED
@@ -111,8 +111,8 @@ export class App {
111
111
  if (strong) dsc.updateViewCache(this.cg.extGeo)
112
112
 
113
113
  //set layer alpha and blend mode
114
- this.cg.ctx.globalAlpha = layer.alpha === undefined ? 1 : layer.alpha
115
- this.cg.ctx.globalCompositeOperation = layer.blendOperation
114
+ this.cg.ctx.globalAlpha = layer.alpha? layer.alpha(zf) : 1.0
115
+ this.cg.ctx.globalCompositeOperation = layer.blendOperation(zf)
116
116
 
117
117
  //draw cells, style by style
118
118
  if (strong)
@@ -124,9 +124,9 @@ export class App {
124
124
 
125
125
  //set style alpha and blend mode
126
126
  //TODO: multiply by layer alpha ?
127
- this.cg.ctx.globalAlpha = s.alpha === undefined ? 1 : s.alpha
128
- this.cg.ctx.globalCompositeOperation = s.blendOperation
129
-
127
+ this.cg.ctx.globalAlpha = s.alpha? s.alpha(zf) : 1.0
128
+ this.cg.ctx.globalCompositeOperation = s.blendOperation(zf)
129
+
130
130
  s.draw(dsc.getViewCache(), dsc.getResolution(), this.cg)
131
131
  }
132
132
 
package/src/Layer.js CHANGED
@@ -25,15 +25,16 @@ export class Layer {
25
25
  * @type {boolean} */
26
26
  this.visible = opts.visible === false ? false : true
27
27
 
28
- /** The alpha of the layer, between 0.0 (fully transparent) and 1.0 (fully opaque).
28
+ /** A function returning the alpha (transparency/opacity), between 0.0 (fully transparent) and 1.0 (fully opaque).
29
+ * The function parameter is the zoom factor.
29
30
  * (see CanvasRenderingContext2D: globalAlpha property)
30
- * @type {number|undefined} */
31
+ * @type {function(number):number|undefined} */
31
32
  this.alpha = opts.alpha
32
33
 
33
- /** The blend operation
34
+ /** A function returning the blend operation. The function parameter is the zoom factor.
34
35
  * (see CanvasRenderingContext2D: globalCompositeOperation property)
35
36
  * @type {GlobalCompositeOperation} */
36
- this.blendOperation = opts.blendOperation || 'normal'
37
+ this.blendOperation = opts.blendOperation || (zf => 'normal')
37
38
 
38
39
  /** The minimum zoom factor: Below this level, the layer is not shown.
39
40
  * @type {number} */
package/src/Style.js CHANGED
@@ -17,7 +17,7 @@
17
17
  export class Style {
18
18
  /**
19
19
  * @abstract
20
- * @param {{filter?:function(import('./Dataset').Cell):boolean,offset?:function(import('./Dataset').Cell,number,number):{dx:number,dy:number},visible?:boolean,alpha?:number,blendOperation?:GlobalCompositeOperation,minZoom?:number,maxZoom?:number}} opts
20
+ * @param {{filter?:function(import('./Dataset').Cell):boolean,offset?:function(import('./Dataset').Cell,number,number):{dx:number,dy:number},visible?:boolean,alpha?:function(number):number,blendOperation?:function(number):GlobalCompositeOperation,minZoom?:number,maxZoom?:number}} opts
21
21
  * minZoom: The minimum zoom level when to show the layer. maxZoom: The maximum zoom level when to show the layer
22
22
  */
23
23
  constructor(opts) {
@@ -37,15 +37,16 @@ export class Style {
37
37
  * @type {boolean} */
38
38
  this.visible = opts.visible === false ? false : true
39
39
 
40
- /** The alpha of the style, between 0.0 (fully transparent) and 1.0 (fully opaque).
40
+ /** A function returning the alpha (transparency/opacity), between 0.0 (fully transparent) and 1.0 (fully opaque).
41
+ * The function parameter is the zoom factor.
41
42
  * (see CanvasRenderingContext2D: globalAlpha property)
42
- * @type {number|undefined} */
43
+ * @type {function(number):number|undefined} */
43
44
  this.alpha = opts.alpha
44
45
 
45
- /** The blend operation
46
+ /** A function returning the blend operation. The function parameter is the zoom factor.
46
47
  * (see CanvasRenderingContext2D: globalCompositeOperation property)
47
- * @type {GlobalCompositeOperation} */
48
- this.blendOperation = opts.blendOperation || 'normal'
48
+ * @type {function(number):GlobalCompositeOperation} */
49
+ this.blendOperation = opts.blendOperation || (zf => 'normal')
49
50
 
50
51
  /** The minimum zoom factor: Below this level, the layer is not shown.
51
52
  * @type {number}