gridviz 2.0.37 → 2.0.39
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/README.md +119 -119
- package/dist/gridviz.js +33256 -33296
- package/dist/gridviz.min.js +1 -1
- package/package.json +78 -78
- package/src/App.js +698 -698
- package/src/BackgroundLayer.js +182 -182
- package/src/BackgroundLayerWMS.js +131 -131
- package/src/Dataset.js +76 -76
- package/src/DatasetComponent.js +103 -103
- package/src/GeoCanvas.js +419 -419
- package/src/LabelLayer.js +190 -190
- package/src/Layer.js +92 -92
- package/src/Legend.js +86 -86
- package/src/LineLayer.js +150 -150
- package/src/Style.js +114 -114
- package/src/Tooltip.js +168 -166
- package/src/dataset/COGeo.js +24 -24
- package/src/dataset/CSVGrid.js +104 -104
- package/src/dataset/GeoTIFF.js +127 -127
- package/src/dataset/GridTile.js +41 -41
- package/src/dataset/ParquetGrid.js +122 -122
- package/src/dataset/TiledGrid.js +296 -296
- package/src/index.js +177 -177
- package/src/legend/ColorCategoryLegend.js +124 -124
- package/src/legend/ColorDiscreteLegend.js +105 -105
- package/src/legend/ColorLegend.js +125 -125
- package/src/legend/SegmentOrientationLegend.js +87 -87
- package/src/legend/SegmentWidthLegend.js +97 -97
- package/src/legend/SizeLegend.js +141 -141
- package/src/style/CompositionStyle.js +300 -300
- package/src/style/ContourStyle.js +54 -54
- package/src/style/DotDensityStyle.js +156 -156
- package/src/style/JoyPlotStyle.js +135 -135
- package/src/style/KernelSmoothingOldStyle.js +221 -221
- package/src/style/KernelSmoothingStyle.js +115 -115
- package/src/style/KernelSmoothingWGLStyle.js +130 -130
- package/src/style/LegoStyle.js +112 -112
- package/src/style/MosaicStyle.js +107 -107
- package/src/style/NinjaStarStyle.js +124 -124
- package/src/style/PillarStyle.js +230 -230
- package/src/style/SegmentStyle.js +142 -142
- package/src/style/ShapeColorSizeStyle.js +126 -126
- package/src/style/SideCatStyle.js +172 -172
- package/src/style/SideStyle.js +218 -218
- package/src/style/SquareColorCatWGLStyle.js +120 -120
- package/src/style/SquareColorWGLStyle.js +146 -146
- package/src/style/StrokeStyle.js +131 -131
- package/src/style/TanakaStyle.js +160 -160
- package/src/style/TextStyle.js +132 -132
- package/src/utils/Utils.js +35 -35
- package/src/utils/WebGLRectangleColoring.js +106 -106
- package/src/utils/WebGLSquareColoring.js +118 -118
- package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
- package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
- package/src/utils/WebGLSquareColoringKS.js +153 -153
- package/src/utils/stretching.js +131 -131
- package/src/utils/webGLUtils.js +71 -71
- package/src/utils/zoomUtils.js +142 -142
package/src/style/LegoStyle.js
CHANGED
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import { TanakaStyle } from './TanakaStyle.js'
|
|
5
|
-
import { StrokeStyle } from './StrokeStyle.js'
|
|
6
|
-
import { SquareColorCatWGLStyle } from './SquareColorCatWGLStyle.js'
|
|
7
|
-
import { Style } from '../Style.js'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @author Julien Gaffuri
|
|
11
|
-
*/
|
|
12
|
-
export class LegoStyle {
|
|
13
|
-
/**
|
|
14
|
-
* @param {string} col
|
|
15
|
-
* @param {object} opts
|
|
16
|
-
* @returns {Array.<Style>}
|
|
17
|
-
*/
|
|
18
|
-
static get(col, opts) {
|
|
19
|
-
opts = opts || {}
|
|
20
|
-
|
|
21
|
-
//the colors
|
|
22
|
-
//http://www.jennyscrayoncollection.com/2021/06/all-current-lego-colors.html
|
|
23
|
-
//https://leonawicz.github.io/legocolors/reference/figures/README-plot-1.png
|
|
24
|
-
opts.colors = opts.colors || [
|
|
25
|
-
'#00852b', //darker green
|
|
26
|
-
'#afd246', //light green
|
|
27
|
-
'#fac80a', //dark yellow
|
|
28
|
-
'#bb805a', //brown
|
|
29
|
-
'#d67923', //mostard
|
|
30
|
-
'#cb4e29', //redish
|
|
31
|
-
'#b40000', //red
|
|
32
|
-
'#720012', //dark red
|
|
33
|
-
//"purple",
|
|
34
|
-
//"#eee" //whithe
|
|
35
|
-
]
|
|
36
|
-
|
|
37
|
-
opts.colDark = opts.colDark || '#333'
|
|
38
|
-
opts.colBright = opts.colBright || '#aaa'
|
|
39
|
-
opts.widthFactor = opts.widthFactor || 0.12
|
|
40
|
-
|
|
41
|
-
//reuse tanaka as basis
|
|
42
|
-
const ts = TanakaStyle.get(col, opts)
|
|
43
|
-
//style to show limits between pieces
|
|
44
|
-
const sst = new StrokeStyle({
|
|
45
|
-
strokeColor: () => '#666',
|
|
46
|
-
strokeWidth: (v, r, s, z) => 0.2 * z,
|
|
47
|
-
filter: opts.filter,
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
return [
|
|
51
|
-
ts[0],
|
|
52
|
-
sst,
|
|
53
|
-
ts[1],
|
|
54
|
-
new LegoTopStyle({ colDark: opts.colDark, colBright: opts.colBright, filter: opts.filter }),
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @param {function(string):string} col
|
|
60
|
-
* @param {object} opts
|
|
61
|
-
* @returns {Array.<Style>}
|
|
62
|
-
*/
|
|
63
|
-
static getCat(col, opts) {
|
|
64
|
-
opts = opts || {}
|
|
65
|
-
|
|
66
|
-
opts.colDark = opts.colDark || '#333'
|
|
67
|
-
opts.colBright = opts.colBright || '#aaa'
|
|
68
|
-
|
|
69
|
-
//
|
|
70
|
-
const s = new SquareColorCatWGLStyle({ colorCol: col, color: opts.color })
|
|
71
|
-
//style to show limits between pieces
|
|
72
|
-
const sst = new StrokeStyle({ strokeColor: () => '#666', strokeWidth: (v, r, s, z) => 0.2 * z })
|
|
73
|
-
|
|
74
|
-
return [s, sst, new LegoTopStyle({ colDark: opts.colDark, colBright: opts.colBright })]
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* A style to draw top circle of lego bricks.
|
|
80
|
-
*/
|
|
81
|
-
class LegoTopStyle extends Style {
|
|
82
|
-
/** @param {object|undefined} opts */
|
|
83
|
-
constructor(opts) {
|
|
84
|
-
super(opts)
|
|
85
|
-
opts = opts || {}
|
|
86
|
-
this.colDark = opts.colDark || '#333'
|
|
87
|
-
this.colBright = opts.colBright || '#aaa'
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
draw(cells, r, cg) {
|
|
91
|
-
//filter
|
|
92
|
-
if (this.filter) cells = cells.filter(this.filter)
|
|
93
|
-
|
|
94
|
-
cg.ctx.lineWidth = 0.6 * cg.getZf()
|
|
95
|
-
|
|
96
|
-
//dark part
|
|
97
|
-
cg.ctx.strokeStyle = this.colDark
|
|
98
|
-
for (let c of cells) {
|
|
99
|
-
cg.ctx.beginPath()
|
|
100
|
-
cg.ctx.arc(c.x + r * 0.5, c.y + r * 0.5, r * 0.55 * 0.5, Math.PI / 4, -Math.PI * (3 / 4), true)
|
|
101
|
-
cg.ctx.stroke()
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//bright part
|
|
105
|
-
cg.ctx.strokeStyle = this.colBright
|
|
106
|
-
for (let c of cells) {
|
|
107
|
-
cg.ctx.beginPath()
|
|
108
|
-
cg.ctx.arc(c.x + r * 0.5, c.y + r * 0.5, r * 0.55 * 0.5, Math.PI / 4, -Math.PI * (3 / 4), false)
|
|
109
|
-
cg.ctx.stroke()
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { TanakaStyle } from './TanakaStyle.js'
|
|
5
|
+
import { StrokeStyle } from './StrokeStyle.js'
|
|
6
|
+
import { SquareColorCatWGLStyle } from './SquareColorCatWGLStyle.js'
|
|
7
|
+
import { Style } from '../Style.js'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @author Julien Gaffuri
|
|
11
|
+
*/
|
|
12
|
+
export class LegoStyle {
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} col
|
|
15
|
+
* @param {object} opts
|
|
16
|
+
* @returns {Array.<Style>}
|
|
17
|
+
*/
|
|
18
|
+
static get(col, opts) {
|
|
19
|
+
opts = opts || {}
|
|
20
|
+
|
|
21
|
+
//the colors
|
|
22
|
+
//http://www.jennyscrayoncollection.com/2021/06/all-current-lego-colors.html
|
|
23
|
+
//https://leonawicz.github.io/legocolors/reference/figures/README-plot-1.png
|
|
24
|
+
opts.colors = opts.colors || [
|
|
25
|
+
'#00852b', //darker green
|
|
26
|
+
'#afd246', //light green
|
|
27
|
+
'#fac80a', //dark yellow
|
|
28
|
+
'#bb805a', //brown
|
|
29
|
+
'#d67923', //mostard
|
|
30
|
+
'#cb4e29', //redish
|
|
31
|
+
'#b40000', //red
|
|
32
|
+
'#720012', //dark red
|
|
33
|
+
//"purple",
|
|
34
|
+
//"#eee" //whithe
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
opts.colDark = opts.colDark || '#333'
|
|
38
|
+
opts.colBright = opts.colBright || '#aaa'
|
|
39
|
+
opts.widthFactor = opts.widthFactor || 0.12
|
|
40
|
+
|
|
41
|
+
//reuse tanaka as basis
|
|
42
|
+
const ts = TanakaStyle.get(col, opts)
|
|
43
|
+
//style to show limits between pieces
|
|
44
|
+
const sst = new StrokeStyle({
|
|
45
|
+
strokeColor: () => '#666',
|
|
46
|
+
strokeWidth: (v, r, s, z) => 0.2 * z,
|
|
47
|
+
filter: opts.filter,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return [
|
|
51
|
+
ts[0],
|
|
52
|
+
sst,
|
|
53
|
+
ts[1],
|
|
54
|
+
new LegoTopStyle({ colDark: opts.colDark, colBright: opts.colBright, filter: opts.filter }),
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {function(string):string} col
|
|
60
|
+
* @param {object} opts
|
|
61
|
+
* @returns {Array.<Style>}
|
|
62
|
+
*/
|
|
63
|
+
static getCat(col, opts) {
|
|
64
|
+
opts = opts || {}
|
|
65
|
+
|
|
66
|
+
opts.colDark = opts.colDark || '#333'
|
|
67
|
+
opts.colBright = opts.colBright || '#aaa'
|
|
68
|
+
|
|
69
|
+
//
|
|
70
|
+
const s = new SquareColorCatWGLStyle({ colorCol: col, color: opts.color })
|
|
71
|
+
//style to show limits between pieces
|
|
72
|
+
const sst = new StrokeStyle({ strokeColor: () => '#666', strokeWidth: (v, r, s, z) => 0.2 * z })
|
|
73
|
+
|
|
74
|
+
return [s, sst, new LegoTopStyle({ colDark: opts.colDark, colBright: opts.colBright })]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A style to draw top circle of lego bricks.
|
|
80
|
+
*/
|
|
81
|
+
class LegoTopStyle extends Style {
|
|
82
|
+
/** @param {object|undefined} opts */
|
|
83
|
+
constructor(opts) {
|
|
84
|
+
super(opts)
|
|
85
|
+
opts = opts || {}
|
|
86
|
+
this.colDark = opts.colDark || '#333'
|
|
87
|
+
this.colBright = opts.colBright || '#aaa'
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
draw(cells, r, cg) {
|
|
91
|
+
//filter
|
|
92
|
+
if (this.filter) cells = cells.filter(this.filter)
|
|
93
|
+
|
|
94
|
+
cg.ctx.lineWidth = 0.6 * cg.getZf()
|
|
95
|
+
|
|
96
|
+
//dark part
|
|
97
|
+
cg.ctx.strokeStyle = this.colDark
|
|
98
|
+
for (let c of cells) {
|
|
99
|
+
cg.ctx.beginPath()
|
|
100
|
+
cg.ctx.arc(c.x + r * 0.5, c.y + r * 0.5, r * 0.55 * 0.5, Math.PI / 4, -Math.PI * (3 / 4), true)
|
|
101
|
+
cg.ctx.stroke()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//bright part
|
|
105
|
+
cg.ctx.strokeStyle = this.colBright
|
|
106
|
+
for (let c of cells) {
|
|
107
|
+
cg.ctx.beginPath()
|
|
108
|
+
cg.ctx.arc(c.x + r * 0.5, c.y + r * 0.5, r * 0.55 * 0.5, Math.PI / 4, -Math.PI * (3 / 4), false)
|
|
109
|
+
cg.ctx.stroke()
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
package/src/style/MosaicStyle.js
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import { Style } from '../Style.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @author Julien Gaffuri
|
|
8
|
-
*/
|
|
9
|
-
export class MosaicStyle extends Style {
|
|
10
|
-
/** @param {object} opts */
|
|
11
|
-
constructor(opts) {
|
|
12
|
-
super(opts)
|
|
13
|
-
opts = opts || {}
|
|
14
|
-
|
|
15
|
-
/** The name of the column/attribute of the tabular data where to retrieve the variable for color.
|
|
16
|
-
* @type {string} */
|
|
17
|
-
this.colorCol = opts.colorCol
|
|
18
|
-
|
|
19
|
-
/** A function returning the color of the cell.
|
|
20
|
-
* @type {function(number,number,import("../Style").Stat|undefined):string} */
|
|
21
|
-
this.color = opts.color || (() => '#EA6BAC')
|
|
22
|
-
|
|
23
|
-
/** The mosaic factor, within [0,0.5]. Set to 0 for no mosaic effect. Set to 0.5 for strong mosaic effect.
|
|
24
|
-
* @type {number} */
|
|
25
|
-
this.mosaicFactor = opts.mosaicFactor || 0.15
|
|
26
|
-
|
|
27
|
-
/** The mosaic shadow factor, within [0,0.5]. Set to 0 for no mosaic shadow. Set to 0.5 for strong mosaic shadow.
|
|
28
|
-
* @type {number} */
|
|
29
|
-
this.shadowFactor = opts.shadowFactor || 0.2
|
|
30
|
-
|
|
31
|
-
/** The mosaic shadow color.
|
|
32
|
-
* @type {string} */
|
|
33
|
-
this.shadowColor = opts.shadowColor || '#555'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @param {Array.<import("../Dataset").Cell>} cells
|
|
39
|
-
* @param {number} resolution
|
|
40
|
-
* @param {import("../GeoCanvas").GeoCanvas} cg
|
|
41
|
-
*/
|
|
42
|
-
draw(cells, resolution, cg) {
|
|
43
|
-
//filter
|
|
44
|
-
if (this.filter) cells = cells.filter(this.filter)
|
|
45
|
-
|
|
46
|
-
//zoom factor
|
|
47
|
-
const zf = cg.getZf()
|
|
48
|
-
|
|
49
|
-
let statColor
|
|
50
|
-
if (this.colorCol) {
|
|
51
|
-
//compute color variable statistics
|
|
52
|
-
statColor = Style.getStatistics(cells, (c) => c[this.colorCol], true)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//set stroke style, for shadow
|
|
56
|
-
cg.ctx.strokeStyle = this.shadowColor
|
|
57
|
-
cg.ctx.lineWidth = this.shadowFactor * resolution
|
|
58
|
-
cg.ctx.lineJoin = 'round'
|
|
59
|
-
cg.ctx.lineCap = 'butt'
|
|
60
|
-
|
|
61
|
-
//function to compute position mosaic effect
|
|
62
|
-
const d = resolution * this.mosaicFactor
|
|
63
|
-
const mosaic = () => {
|
|
64
|
-
return { x: Math.random() * d, y: Math.random() * d }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
//draw with HTML canvas in geo coordinates
|
|
68
|
-
cg.setCanvasTransform()
|
|
69
|
-
|
|
70
|
-
for (let cell of cells) {
|
|
71
|
-
//set fill color
|
|
72
|
-
const col = this.color ? this.color(cell[this.colorCol], resolution, statColor) : undefined
|
|
73
|
-
if (!col || col === 'none') continue
|
|
74
|
-
cg.ctx.fillStyle = col
|
|
75
|
-
|
|
76
|
-
//get offset
|
|
77
|
-
const offset = this.offset(cell, resolution, zf)
|
|
78
|
-
|
|
79
|
-
//compute position mosaic effect
|
|
80
|
-
const ll = mosaic(),
|
|
81
|
-
ul = mosaic(),
|
|
82
|
-
lr = mosaic(),
|
|
83
|
-
ur = mosaic()
|
|
84
|
-
|
|
85
|
-
//stroke
|
|
86
|
-
if (this.shadowFactor > 0) {
|
|
87
|
-
cg.ctx.beginPath()
|
|
88
|
-
cg.ctx.moveTo(cell.x + offset.dx + ll.x, cell.y + offset.dy + ll.y)
|
|
89
|
-
cg.ctx.lineTo(cell.x + offset.dx + resolution - lr.x, cell.y + offset.dy + lr.y)
|
|
90
|
-
cg.ctx.lineTo(cell.x + offset.dx + resolution - ur.x, cell.y + offset.dy + resolution - ur.y)
|
|
91
|
-
cg.ctx.stroke()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
//fill
|
|
95
|
-
|
|
96
|
-
cg.ctx.beginPath()
|
|
97
|
-
cg.ctx.moveTo(cell.x + offset.dx + ll.x, cell.y + offset.dy + ll.y)
|
|
98
|
-
cg.ctx.lineTo(cell.x + offset.dx + resolution - lr.x, cell.y + offset.dy + lr.y)
|
|
99
|
-
cg.ctx.lineTo(cell.x + offset.dx + resolution - ur.x, cell.y + offset.dy + resolution - ur.y)
|
|
100
|
-
cg.ctx.lineTo(cell.x + offset.dx + ul.x, cell.y + offset.dy + resolution - ul.y)
|
|
101
|
-
cg.ctx.fill()
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//update legends
|
|
105
|
-
this.updateLegends({ style: this, r: resolution, zf: zf, sColor: statColor })
|
|
106
|
-
}
|
|
107
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { Style } from '../Style.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @author Julien Gaffuri
|
|
8
|
+
*/
|
|
9
|
+
export class MosaicStyle extends Style {
|
|
10
|
+
/** @param {object} opts */
|
|
11
|
+
constructor(opts) {
|
|
12
|
+
super(opts)
|
|
13
|
+
opts = opts || {}
|
|
14
|
+
|
|
15
|
+
/** The name of the column/attribute of the tabular data where to retrieve the variable for color.
|
|
16
|
+
* @type {string} */
|
|
17
|
+
this.colorCol = opts.colorCol
|
|
18
|
+
|
|
19
|
+
/** A function returning the color of the cell.
|
|
20
|
+
* @type {function(number,number,import("../Style").Stat|undefined):string} */
|
|
21
|
+
this.color = opts.color || (() => '#EA6BAC')
|
|
22
|
+
|
|
23
|
+
/** The mosaic factor, within [0,0.5]. Set to 0 for no mosaic effect. Set to 0.5 for strong mosaic effect.
|
|
24
|
+
* @type {number} */
|
|
25
|
+
this.mosaicFactor = opts.mosaicFactor || 0.15
|
|
26
|
+
|
|
27
|
+
/** The mosaic shadow factor, within [0,0.5]. Set to 0 for no mosaic shadow. Set to 0.5 for strong mosaic shadow.
|
|
28
|
+
* @type {number} */
|
|
29
|
+
this.shadowFactor = opts.shadowFactor || 0.2
|
|
30
|
+
|
|
31
|
+
/** The mosaic shadow color.
|
|
32
|
+
* @type {string} */
|
|
33
|
+
this.shadowColor = opts.shadowColor || '#555'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param {Array.<import("../Dataset").Cell>} cells
|
|
39
|
+
* @param {number} resolution
|
|
40
|
+
* @param {import("../GeoCanvas").GeoCanvas} cg
|
|
41
|
+
*/
|
|
42
|
+
draw(cells, resolution, cg) {
|
|
43
|
+
//filter
|
|
44
|
+
if (this.filter) cells = cells.filter(this.filter)
|
|
45
|
+
|
|
46
|
+
//zoom factor
|
|
47
|
+
const zf = cg.getZf()
|
|
48
|
+
|
|
49
|
+
let statColor
|
|
50
|
+
if (this.colorCol) {
|
|
51
|
+
//compute color variable statistics
|
|
52
|
+
statColor = Style.getStatistics(cells, (c) => c[this.colorCol], true)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//set stroke style, for shadow
|
|
56
|
+
cg.ctx.strokeStyle = this.shadowColor
|
|
57
|
+
cg.ctx.lineWidth = this.shadowFactor * resolution
|
|
58
|
+
cg.ctx.lineJoin = 'round'
|
|
59
|
+
cg.ctx.lineCap = 'butt'
|
|
60
|
+
|
|
61
|
+
//function to compute position mosaic effect
|
|
62
|
+
const d = resolution * this.mosaicFactor
|
|
63
|
+
const mosaic = () => {
|
|
64
|
+
return { x: Math.random() * d, y: Math.random() * d }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//draw with HTML canvas in geo coordinates
|
|
68
|
+
cg.setCanvasTransform()
|
|
69
|
+
|
|
70
|
+
for (let cell of cells) {
|
|
71
|
+
//set fill color
|
|
72
|
+
const col = this.color ? this.color(cell[this.colorCol], resolution, statColor) : undefined
|
|
73
|
+
if (!col || col === 'none') continue
|
|
74
|
+
cg.ctx.fillStyle = col
|
|
75
|
+
|
|
76
|
+
//get offset
|
|
77
|
+
const offset = this.offset(cell, resolution, zf)
|
|
78
|
+
|
|
79
|
+
//compute position mosaic effect
|
|
80
|
+
const ll = mosaic(),
|
|
81
|
+
ul = mosaic(),
|
|
82
|
+
lr = mosaic(),
|
|
83
|
+
ur = mosaic()
|
|
84
|
+
|
|
85
|
+
//stroke
|
|
86
|
+
if (this.shadowFactor > 0) {
|
|
87
|
+
cg.ctx.beginPath()
|
|
88
|
+
cg.ctx.moveTo(cell.x + offset.dx + ll.x, cell.y + offset.dy + ll.y)
|
|
89
|
+
cg.ctx.lineTo(cell.x + offset.dx + resolution - lr.x, cell.y + offset.dy + lr.y)
|
|
90
|
+
cg.ctx.lineTo(cell.x + offset.dx + resolution - ur.x, cell.y + offset.dy + resolution - ur.y)
|
|
91
|
+
cg.ctx.stroke()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//fill
|
|
95
|
+
|
|
96
|
+
cg.ctx.beginPath()
|
|
97
|
+
cg.ctx.moveTo(cell.x + offset.dx + ll.x, cell.y + offset.dy + ll.y)
|
|
98
|
+
cg.ctx.lineTo(cell.x + offset.dx + resolution - lr.x, cell.y + offset.dy + lr.y)
|
|
99
|
+
cg.ctx.lineTo(cell.x + offset.dx + resolution - ur.x, cell.y + offset.dy + resolution - ur.y)
|
|
100
|
+
cg.ctx.lineTo(cell.x + offset.dx + ul.x, cell.y + offset.dy + resolution - ul.y)
|
|
101
|
+
cg.ctx.fill()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//update legends
|
|
105
|
+
this.updateLegends({ style: this, r: resolution, zf: zf, sColor: statColor })
|
|
106
|
+
}
|
|
107
|
+
}
|