gridviz 2.0.49 → 2.0.51
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 +23 -16
- package/dist/gridviz.min.js +1 -1
- package/package.json +1 -1
- package/src/App.js +10 -5
- package/src/Layer.js +5 -4
- package/src/Style.js +7 -6
package/package.json
CHANGED
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
|
|
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,14 +124,14 @@ 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
|
|
128
|
-
this.cg.ctx.globalCompositeOperation = s.blendOperation
|
|
127
|
+
this.cg.ctx.globalAlpha = s.alpha ? s.alpha(zf) : 1.0
|
|
128
|
+
this.cg.ctx.globalCompositeOperation = s.blendOperation(zf)
|
|
129
129
|
|
|
130
130
|
s.draw(dsc.getViewCache(), dsc.getResolution(), this.cg)
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
//add legend element
|
|
134
|
-
if (this.legend && strong)
|
|
134
|
+
if (this.legend && strong) {
|
|
135
135
|
for (const s of layer.styles) {
|
|
136
136
|
if (zf > s.maxZoom) continue
|
|
137
137
|
if (zf < s.minZoom) continue
|
|
@@ -157,6 +157,11 @@ export class App {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//restore default alpha and blend operation
|
|
163
|
+
this.cg.ctx.globalAlpha = 1.0
|
|
164
|
+
this.cg.ctx.globalCompositeOperation = "normal"
|
|
160
165
|
}
|
|
161
166
|
|
|
162
167
|
//draw boundary layer
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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}
|