gridviz 2.0.48 → 2.0.49
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 +40 -4
- package/dist/gridviz.min.js +1 -1
- package/package.json +1 -1
- package/src/App.js +12 -0
- package/src/Layer.js +12 -2
- package/src/Style.js +15 -1
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -110,11 +110,23 @@ export class App {
|
|
|
110
110
|
//update dataset view cache
|
|
111
111
|
if (strong) dsc.updateViewCache(this.cg.extGeo)
|
|
112
112
|
|
|
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
|
|
116
|
+
|
|
113
117
|
//draw cells, style by style
|
|
114
118
|
if (strong)
|
|
115
119
|
for (const s of layer.styles) {
|
|
120
|
+
//check if style is visible
|
|
121
|
+
if (!s.visible) continue
|
|
116
122
|
if (zf > s.maxZoom) continue
|
|
117
123
|
if (zf < s.minZoom) continue
|
|
124
|
+
|
|
125
|
+
//set style alpha and blend mode
|
|
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
|
+
|
|
118
130
|
s.draw(dsc.getViewCache(), dsc.getResolution(), this.cg)
|
|
119
131
|
}
|
|
120
132
|
|
package/src/Layer.js
CHANGED
|
@@ -10,7 +10,7 @@ export class Layer {
|
|
|
10
10
|
/**
|
|
11
11
|
* @param {import("./Dataset").Dataset} dataset The multi resolution dataset to show.
|
|
12
12
|
* @param {Array.<import("./Style").Style>} styles The styles, ordered in drawing order.
|
|
13
|
-
* @param {{visible?:boolean,minZoom?:number,maxZoom?:number,pixNb?:number,cellInfoHTML?:function(import("./Dataset").Cell):string}} opts
|
|
13
|
+
* @param {{visible?:boolean,alpha?:number,blendOperation?:GlobalCompositeOperation,minZoom?:number,maxZoom?:number,pixNb?:number,cellInfoHTML?:function(import("./Dataset").Cell):string}} opts
|
|
14
14
|
* minZoom: The minimum zoom level when to show the layer. maxZoom: The maximum zoom level when to show the layer
|
|
15
15
|
*/
|
|
16
16
|
constructor(dataset, styles, opts = {}) {
|
|
@@ -23,7 +23,17 @@ export class Layer {
|
|
|
23
23
|
|
|
24
24
|
/** An attribute to specify if a layer should be drawn or not
|
|
25
25
|
* @type {boolean} */
|
|
26
|
-
this.visible = opts.visible
|
|
26
|
+
this.visible = opts.visible === false ? false : true
|
|
27
|
+
|
|
28
|
+
/** The alpha of the layer, between 0.0 (fully transparent) and 1.0 (fully opaque).
|
|
29
|
+
* (see CanvasRenderingContext2D: globalAlpha property)
|
|
30
|
+
* @type {number|undefined} */
|
|
31
|
+
this.alpha = opts.alpha
|
|
32
|
+
|
|
33
|
+
/** The blend operation
|
|
34
|
+
* (see CanvasRenderingContext2D: globalCompositeOperation property)
|
|
35
|
+
* @type {GlobalCompositeOperation} */
|
|
36
|
+
this.blendOperation = opts.blendOperation || 'normal'
|
|
27
37
|
|
|
28
38
|
/** The minimum zoom factor: Below this level, the layer is not shown.
|
|
29
39
|
* @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},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?:number,blendOperation?: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) {
|
|
@@ -33,6 +33,20 @@ export class Style {
|
|
|
33
33
|
* @type {function(import('./Dataset').Cell,number,number):{dx:number,dy:number}} */
|
|
34
34
|
this.offset = opts.offset || ((c, r, zf) => ({ dx: 0, dy: 0 }))
|
|
35
35
|
|
|
36
|
+
/** An attribute to specify if a style should be drawn or not
|
|
37
|
+
* @type {boolean} */
|
|
38
|
+
this.visible = opts.visible === false ? false : true
|
|
39
|
+
|
|
40
|
+
/** The alpha of the style, between 0.0 (fully transparent) and 1.0 (fully opaque).
|
|
41
|
+
* (see CanvasRenderingContext2D: globalAlpha property)
|
|
42
|
+
* @type {number|undefined} */
|
|
43
|
+
this.alpha = opts.alpha
|
|
44
|
+
|
|
45
|
+
/** The blend operation
|
|
46
|
+
* (see CanvasRenderingContext2D: globalCompositeOperation property)
|
|
47
|
+
* @type {GlobalCompositeOperation} */
|
|
48
|
+
this.blendOperation = opts.blendOperation || 'normal'
|
|
49
|
+
|
|
36
50
|
/** The minimum zoom factor: Below this level, the layer is not shown.
|
|
37
51
|
* @type {number}
|
|
38
52
|
* */
|