gridviz 3.0.1 → 3.0.2
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 +36 -33
- package/dist/gridviz.js +434 -183
- package/dist/gridviz.min.js +1 -1
- package/package.json +4 -3
- package/src/button/Button.js +1 -0
- package/src/button/FullscreenButton.js +1 -0
- package/src/button/ZoomButtons.js +1 -0
- package/src/core/Dataset.js +1 -0
- package/src/core/Drawable.js +1 -0
- package/src/core/GeoCanvas.js +1 -0
- package/src/core/Layer.js +1 -0
- package/src/core/Legend.js +1 -0
- package/src/core/Map.js +1 -0
- package/src/core/MultiResolutionDataset.js +1 -0
- package/src/core/Style.js +10 -1
- package/src/core/Tooltip.js +1 -0
- package/src/dataset/COGeo.js +1 -0
- package/src/dataset/CSVGrid.js +1 -0
- package/src/dataset/GeoTIFF.js +1 -0
- package/src/dataset/JSGrid.js +1 -0
- package/src/dataset/TiledGrid.js +1 -0
- package/src/index.js +2 -2
- package/src/layer/BackgroundLayer.js +1 -0
- package/src/layer/BackgroundLayerWMS.js +1 -0
- package/src/layer/GeoJSONLayer.js +1 -0
- package/src/layer/GridLayer.js +1 -0
- package/src/layer/LabelLayer.js +1 -0
- package/src/legend/ColorCategoryLegend.js +1 -0
- package/src/legend/ColorDiscreteLegend.js +2 -0
- package/src/legend/ColorLegend.js +1 -0
- package/src/legend/OrientationLegend.js +1 -0
- package/src/legend/SizeLegend.js +4 -2
- package/src/style/CompositionStyle.js +1 -0
- package/src/style/ContourStyle.js +1 -0
- package/src/style/DotDensityStyle.js +1 -0
- package/src/style/IsoFenceStyle.js +24 -72
- package/src/style/JoyPlotStyle.js +1 -1
- package/src/style/LegoStyle.js +22 -24
- package/src/style/MosaicStyle.js +1 -0
- package/src/style/NinjaStarStyle.js +1 -1
- package/src/style/PillarStyle.js +1 -0
- package/src/style/SegmentStyle.js +1 -0
- package/src/style/ShapeColorSizeStyle.js +1 -0
- package/src/style/SideCategoryStyle.js +1 -0
- package/src/style/SideStyle.js +51 -28
- package/src/style/SquareColorCategoryWebGLStyle.js +4 -3
- package/src/style/SquareColorWebGLStyle.js +1 -0
- package/src/style/StrokeStyle.js +1 -1
- package/src/style/TanakaStyle.js +11 -5
- package/src/style/TextStyle.js +1 -1
- package/src/style/TimeSeriesStyle.js +1 -0
- package/src/utils/scale.js +22 -11
- package/src/utils/stretching.js +4 -0
- package/src/utils/utils.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gridviz",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Visualization tool for gridded statistics",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"statistics",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"start": "export NODE_OPTIONS=--openssl-legacy-provider && webpack --config webpack.config.dev.cjs",
|
|
41
41
|
"start-dev": "webpack --config webpack.config.dev.cjs",
|
|
42
42
|
"server": "webpack serve -c webpack.config.dev.cjs",
|
|
43
|
-
"doc": "./node_modules/.bin/jsdoc
|
|
43
|
+
"doc": "./node_modules/.bin/jsdoc -c docs/jsdoc/jsdoc.conf.json",
|
|
44
44
|
"bp": "webpack --config webpack.config.prod.cjs",
|
|
45
45
|
"test": "jest"
|
|
46
46
|
},
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"d3-random": "^3.0.1",
|
|
56
56
|
"d3-scale": "^4.0.2",
|
|
57
57
|
"d3-selection": "^3.0.0",
|
|
58
|
-
"d3-zoom": "^3.0.0"
|
|
58
|
+
"d3-zoom": "^3.0.0",
|
|
59
|
+
"jsdoc": "^4.0.2"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@babel/core": "^7.9.0",
|
package/src/button/Button.js
CHANGED
package/src/core/Dataset.js
CHANGED
package/src/core/Drawable.js
CHANGED
package/src/core/GeoCanvas.js
CHANGED
package/src/core/Layer.js
CHANGED
package/src/core/Legend.js
CHANGED
package/src/core/Map.js
CHANGED
package/src/core/Style.js
CHANGED
|
@@ -13,6 +13,7 @@ import { Drawable } from "./Drawable.js"
|
|
|
13
13
|
/**
|
|
14
14
|
* A style, to show a grid dataset.
|
|
15
15
|
*
|
|
16
|
+
* @module core
|
|
16
17
|
* @author Joseph Davies, Julien Gaffuri
|
|
17
18
|
*/
|
|
18
19
|
export class Style extends Drawable {
|
|
@@ -73,7 +74,7 @@ export class Style extends Drawable {
|
|
|
73
74
|
return this
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
/**
|
|
77
|
+
/** Update legends of the style, if any
|
|
77
78
|
* @param {object} opts
|
|
78
79
|
* @returns {this} */
|
|
79
80
|
updateLegends(opts) {
|
|
@@ -81,4 +82,12 @@ export class Style extends Drawable {
|
|
|
81
82
|
return this
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @param {Array.<import("./Legend").Legend>} legends
|
|
87
|
+
* @returns {this} */
|
|
88
|
+
addLegends(legends) {
|
|
89
|
+
for (let legend of legends)
|
|
90
|
+
this.legends.push(legend)
|
|
91
|
+
return this
|
|
92
|
+
}
|
|
84
93
|
}
|
package/src/core/Tooltip.js
CHANGED
package/src/dataset/COGeo.js
CHANGED
package/src/dataset/CSVGrid.js
CHANGED
package/src/dataset/GeoTIFF.js
CHANGED
package/src/dataset/JSGrid.js
CHANGED
package/src/dataset/TiledGrid.js
CHANGED
package/src/index.js
CHANGED
|
@@ -25,8 +25,8 @@ export { SideStyle } from './style/SideStyle.js'
|
|
|
25
25
|
//export { ContourStyle } from './style/ContourStyle.js'
|
|
26
26
|
export { SideCategoryStyle } from './style/SideCategoryStyle.js'
|
|
27
27
|
export { DotDensityStyle } from './style/DotDensityStyle.js'
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
export { TanakaStyle } from './style/TanakaStyle.js'
|
|
29
|
+
export { LegoStyle } from './style/LegoStyle.js'
|
|
30
30
|
export { SquareColorWebGLStyle } from './style/SquareColorWebGLStyle.js'
|
|
31
31
|
export { SquareColorCategoryWebGLStyle } from './style/SquareColorCategoryWebGLStyle.js'
|
|
32
32
|
export { MosaicStyle } from './style/MosaicStyle.js'
|
|
@@ -9,6 +9,7 @@ import { Layer } from '../core/Layer.js'
|
|
|
9
9
|
* See https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
|
|
10
10
|
* https://www.maptiler.com/google-maps-coordinates-tile-bounds-projection/#6/27.88/44.48
|
|
11
11
|
*
|
|
12
|
+
* @module layer
|
|
12
13
|
* @author Julien Gaffuri
|
|
13
14
|
*/
|
|
14
15
|
export class BackgroundLayer extends Layer {
|
package/src/layer/GridLayer.js
CHANGED
package/src/layer/LabelLayer.js
CHANGED
|
@@ -13,6 +13,7 @@ import { csv } from 'd3-fetch'
|
|
|
13
13
|
* If the label data is not in the expected format or in the same CRS as the grid, it can be corrected with the "preprocess" function.
|
|
14
14
|
* The selection of the label, their style (font, weight, etc.) and color can be specified depending on their importance and the zoom level.
|
|
15
15
|
*
|
|
16
|
+
* @module layer
|
|
16
17
|
* @author Joseph Davies, Julien Gaffuri
|
|
17
18
|
*/
|
|
18
19
|
export class LabelLayer extends Layer {
|
|
@@ -7,6 +7,7 @@ import { Legend } from '../core/Legend.js'
|
|
|
7
7
|
* A legend element for discrete color style.
|
|
8
8
|
* Inspiration: https://observablehq.com/@d3/color-legend
|
|
9
9
|
*
|
|
10
|
+
* @module legend
|
|
10
11
|
* @author Julien Gaffuri
|
|
11
12
|
*/
|
|
12
13
|
export class ColorDiscreteLegend extends Legend {
|
|
@@ -43,6 +44,7 @@ export class ColorDiscreteLegend extends Legend {
|
|
|
43
44
|
//get colors and breaks
|
|
44
45
|
const colors = this.colors(opts.viewScale)
|
|
45
46
|
const breaks = this.breaks(opts.viewScale)
|
|
47
|
+
if (!breaks) return
|
|
46
48
|
|
|
47
49
|
//classes
|
|
48
50
|
const nb = colors.length
|
|
@@ -7,6 +7,7 @@ import { Legend } from '../core/Legend.js'
|
|
|
7
7
|
* A legend element for continuous color style.
|
|
8
8
|
* Inspiration: https://observablehq.com/@d3/color-legend
|
|
9
9
|
*
|
|
10
|
+
* @module legend
|
|
10
11
|
* @author Joseph Davies, Julien Gaffuri
|
|
11
12
|
*/
|
|
12
13
|
export class ColorLegend extends Legend {
|
package/src/legend/SizeLegend.js
CHANGED
|
@@ -8,6 +8,7 @@ import { max } from 'd3-array'
|
|
|
8
8
|
/**
|
|
9
9
|
* A legend element for proportional symbols.
|
|
10
10
|
*
|
|
11
|
+
* @module legend
|
|
11
12
|
* @author Joseph Davies, Julien Gaffuri
|
|
12
13
|
*/
|
|
13
14
|
export class SizeLegend extends Legend {
|
|
@@ -198,10 +199,11 @@ export function sizeDiscreteViewScaleLegend(classNumber, opts = {}) {
|
|
|
198
199
|
const f = opts.labelFormat || (x => x)
|
|
199
200
|
const labelText = opts.labelText || defaultLabelText(f)
|
|
200
201
|
const legends = []
|
|
202
|
+
const viewScaleFun = opts.viewScaleFun || (t => t) //TODO do it differently? At sizelegend level !
|
|
201
203
|
for (let i = classNumber - 1; i >= 0; i--) {
|
|
202
204
|
opts.title = i == classNumber - 1 ? opts.title : undefined
|
|
203
|
-
opts.size = (viewScale) => viewScale.values[i]
|
|
204
|
-
opts.label = (viewScale) => labelText(viewScale.breaks[i - 1], viewScale.breaks[i])
|
|
205
|
+
opts.size = (viewScale) => viewScaleFun(viewScale).values[i]
|
|
206
|
+
opts.label = (viewScale) => labelText(viewScaleFun(viewScale).breaks[i - 1], viewScaleFun(viewScale).breaks[i])
|
|
205
207
|
legends.push(new SizeLegend(opts))
|
|
206
208
|
}
|
|
207
209
|
return legends
|
|
@@ -11,6 +11,7 @@ import { Style } from '../core/Style.js'
|
|
|
11
11
|
* For a list of supported symbols, @see CompositionType
|
|
12
12
|
* The symbol can be scaled depending on the cell importance.
|
|
13
13
|
*
|
|
14
|
+
* @module style
|
|
14
15
|
* @author Julien Gaffuri
|
|
15
16
|
*/
|
|
16
17
|
export class CompositionStyle extends Style {
|
|
@@ -7,6 +7,7 @@ import { SideStyle } from './SideStyle.js'
|
|
|
7
7
|
/** @typedef {{x:number,y:number,or:"v"|"h",c1:import('../core/Dataset.js').Cell|undefined,c2:import('../core/Dataset.js').Cell|undefined}} Side */
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* @module style
|
|
10
11
|
* @author Julien Gaffuri
|
|
11
12
|
*/
|
|
12
13
|
export class IsoFenceStyle extends Style {
|
|
@@ -77,57 +78,7 @@ export class IsoFenceStyle extends Style {
|
|
|
77
78
|
|
|
78
79
|
//make sides
|
|
79
80
|
/** @type {Array.<Side>} */
|
|
80
|
-
const sides = SideStyle.buildSides(cells, resolution, this.angle % 180 != 90 && this.sVert, this.angle % 180 != 0 && this.sHor
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/*const sides = []
|
|
85
|
-
|
|
86
|
-
//make horizontal sides - except when angle%180=0
|
|
87
|
-
//sort cells by x and y
|
|
88
|
-
if (this.angle % 180 != 90 && this.sVert) {
|
|
89
|
-
cells.sort((c1, c2) => (c2.x == c1.x ? c1.y - c2.y : c1.x - c2.x))
|
|
90
|
-
let c1 = cells[0]
|
|
91
|
-
for (let i = 1; i < cells.length; i++) {
|
|
92
|
-
let c2 = cells[i]
|
|
93
|
-
|
|
94
|
-
if ((c1.y + resolution == c2.y) && (c1.x == c2.x))
|
|
95
|
-
//cells in same column and touch along horizontal side
|
|
96
|
-
//make shared side
|
|
97
|
-
sides.push({ x: c1.x + r2, y: c2.y, or: 'h', c1: c1, c2: c2 })
|
|
98
|
-
else {
|
|
99
|
-
//cells do not touch along horizontal side
|
|
100
|
-
//make two sides: top one for c1, bottom for c2
|
|
101
|
-
sides.push({ x: c1.x + r2, y: c1.y + resolution, or: 'h', c1: c1, c2: undefined })
|
|
102
|
-
sides.push({ x: c2.x + r2, y: c2.y, or: 'h', c1: undefined, c2: c2 })
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
c1 = c2
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
//make vertical sides - except when angle%180=90
|
|
110
|
-
//sort cells by y and x
|
|
111
|
-
if (this.angle % 180 != 0 && this.sHor) {
|
|
112
|
-
cells.sort((c1, c2) => (c2.y == c1.y ? c1.x - c2.x : c1.y - c2.y))
|
|
113
|
-
let c1 = cells[0]
|
|
114
|
-
for (let i = 1; i < cells.length; i++) {
|
|
115
|
-
let c2 = cells[i]
|
|
116
|
-
|
|
117
|
-
if ((c1.x + resolution == c2.x) && (c1.y == c2.y))
|
|
118
|
-
//cells in same row and touch along vertical side
|
|
119
|
-
//make shared side
|
|
120
|
-
sides.push({ x: c2.x, y: c1.y + r2, or: 'v', c1: c1, c2: c2 })
|
|
121
|
-
else {
|
|
122
|
-
//cells do not touch along vertical side
|
|
123
|
-
//make two sides: right one for c1, left for c2
|
|
124
|
-
sides.push({ x: c1.x + resolution, y: c1.y + r2, or: 'v', c1: c1, c2: undefined })
|
|
125
|
-
sides.push({ x: c2.x, y: c2.y + r2, or: 'v', c1: undefined, c2: c2 })
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
c1 = c2
|
|
129
|
-
}
|
|
130
|
-
}*/
|
|
81
|
+
const sides = SideStyle.buildSides(cells, resolution, this.angle % 180 != 90 && this.sVert, this.angle % 180 != 0 && this.sHor)
|
|
131
82
|
|
|
132
83
|
//
|
|
133
84
|
if (sides.length == 0) return
|
|
@@ -163,15 +114,16 @@ export class IsoFenceStyle extends Style {
|
|
|
163
114
|
|
|
164
115
|
//draw sides
|
|
165
116
|
geoCanvas.ctx.lineCap = "round";
|
|
166
|
-
for (let
|
|
117
|
+
for (let side of sides) {
|
|
118
|
+
const c1 = side.c1, c2 = side.c2, x = side.x, y = side.y
|
|
167
119
|
|
|
168
120
|
//heights - in geo
|
|
169
|
-
const hG1 =
|
|
170
|
-
hG2 =
|
|
121
|
+
const hG1 = c1 ? this.height(c1, resolution, z, viewScale) : 0,
|
|
122
|
+
hG2 = c2 ? this.height(c2, resolution, z, viewScale) : 0
|
|
171
123
|
|
|
172
124
|
//compute totals for both cells
|
|
173
|
-
const total1 = computeTotal(
|
|
174
|
-
total2 = computeTotal(
|
|
125
|
+
const total1 = computeTotal(c1, cats),
|
|
126
|
+
total2 = computeTotal(c2, cats)
|
|
175
127
|
if (total1 == 0 && total2 == 0) continue
|
|
176
128
|
|
|
177
129
|
let cumul1 = 0, cumul2 = 0
|
|
@@ -179,8 +131,8 @@ export class IsoFenceStyle extends Style {
|
|
|
179
131
|
//draw stripe of side s and category column
|
|
180
132
|
|
|
181
133
|
//get values for both cells
|
|
182
|
-
let v1 =
|
|
183
|
-
let v2 =
|
|
134
|
+
let v1 = c1 ? +c1[column] : 0
|
|
135
|
+
let v2 = c2 ? +c2[column] : 0
|
|
184
136
|
if (v1 == 0 && v2 == 0) continue
|
|
185
137
|
|
|
186
138
|
//compute heights
|
|
@@ -191,26 +143,26 @@ export class IsoFenceStyle extends Style {
|
|
|
191
143
|
|
|
192
144
|
//make path
|
|
193
145
|
geoCanvas.ctx.beginPath()
|
|
194
|
-
if (
|
|
146
|
+
if (side.or == "h") {
|
|
195
147
|
//horizontal side - vertical section
|
|
196
148
|
//bottom left
|
|
197
|
-
geoCanvas.ctx.moveTo(
|
|
149
|
+
geoCanvas.ctx.moveTo(x + h1 * cos + dx, y - r2 + h1 * sin + dy)
|
|
198
150
|
//top left
|
|
199
|
-
geoCanvas.ctx.lineTo(
|
|
151
|
+
geoCanvas.ctx.lineTo(x + h2 * cos + dx, y + r2 + h2 * sin + dy)
|
|
200
152
|
//top right
|
|
201
|
-
geoCanvas.ctx.lineTo(
|
|
153
|
+
geoCanvas.ctx.lineTo(x + h2n * cos + dx, y + r2 + h2n * sin + dy)
|
|
202
154
|
//bottom right
|
|
203
|
-
geoCanvas.ctx.lineTo(
|
|
155
|
+
geoCanvas.ctx.lineTo(x + h1n * cos + dx, y - r2 + h1n * sin + dy)
|
|
204
156
|
} else {
|
|
205
157
|
//vertical side - horizontal section
|
|
206
158
|
//bottom left
|
|
207
|
-
geoCanvas.ctx.moveTo(
|
|
159
|
+
geoCanvas.ctx.moveTo(x - r2 + h1 * cos + dx, y + h1 * sin + dy)
|
|
208
160
|
//bottom right
|
|
209
|
-
geoCanvas.ctx.lineTo(
|
|
161
|
+
geoCanvas.ctx.lineTo(x + r2 + h2 * cos + dx, y + h2 * sin + dy)
|
|
210
162
|
//top right
|
|
211
|
-
geoCanvas.ctx.lineTo(
|
|
163
|
+
geoCanvas.ctx.lineTo(x + r2 + h2n * cos + dx, y + h2n * sin + dy)
|
|
212
164
|
//top left
|
|
213
|
-
geoCanvas.ctx.lineTo(
|
|
165
|
+
geoCanvas.ctx.lineTo(x - r2 + h1n * cos + dx, y + h1n * sin + dy)
|
|
214
166
|
}
|
|
215
167
|
//cg.ctx.closePath()
|
|
216
168
|
|
|
@@ -223,11 +175,11 @@ export class IsoFenceStyle extends Style {
|
|
|
223
175
|
|
|
224
176
|
//TODO draw only one line
|
|
225
177
|
//draw corner line
|
|
226
|
-
//if (
|
|
227
|
-
drawCornerLine(
|
|
228
|
-
drawCornerLine(
|
|
229
|
-
//if (this.angle > 0 &&
|
|
230
|
-
//else drawCornerLine(
|
|
178
|
+
//if (side.or == "h") {
|
|
179
|
+
drawCornerLine(c1)
|
|
180
|
+
drawCornerLine(c2)
|
|
181
|
+
//if (this.angle > 0 && side.or == "h") drawCornerLine(c2)
|
|
182
|
+
//else drawCornerLine(c2)
|
|
231
183
|
//}
|
|
232
184
|
}
|
|
233
185
|
}
|
package/src/style/LegoStyle.js
CHANGED
|
@@ -7,21 +7,18 @@ import { SquareColorCategoryWebGLStyle } from './SquareColorCategoryWebGLStyle.j
|
|
|
7
7
|
import { Style } from '../core/Style.js'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* @module style
|
|
10
11
|
* @author Julien Gaffuri
|
|
11
12
|
*/
|
|
12
13
|
export class LegoStyle {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @param {object} opts
|
|
16
|
-
* @returns {Array.<Style>}
|
|
17
|
-
*/
|
|
18
|
-
static get(col, opts) {
|
|
14
|
+
|
|
15
|
+
static get(value, breaks, colors, opts = {}) {
|
|
19
16
|
opts = opts || {}
|
|
20
17
|
|
|
21
18
|
//the colors
|
|
22
19
|
//http://www.jennyscrayoncollection.com/2021/06/all-current-lego-colors.html
|
|
23
20
|
//https://leonawicz.github.io/legocolors/reference/figures/README-plot-1.png
|
|
24
|
-
opts.colors = opts.colors || [
|
|
21
|
+
/*opts.colors = opts.colors || [
|
|
25
22
|
'#00852b', //darker green
|
|
26
23
|
'#afd246', //light green
|
|
27
24
|
'#fac80a', //dark yellow
|
|
@@ -32,18 +29,18 @@ export class LegoStyle {
|
|
|
32
29
|
'#720012', //dark red
|
|
33
30
|
//"purple",
|
|
34
31
|
//"#eee" //whithe
|
|
35
|
-
]
|
|
32
|
+
]*/
|
|
36
33
|
|
|
37
34
|
opts.colDark = opts.colDark || '#333'
|
|
38
35
|
opts.colBright = opts.colBright || '#aaa'
|
|
39
36
|
opts.widthFactor = opts.widthFactor || 0.12
|
|
40
37
|
|
|
41
38
|
//reuse tanaka as basis
|
|
42
|
-
const ts = TanakaStyle.get(
|
|
39
|
+
const ts = TanakaStyle.get(value, breaks, colors, opts)
|
|
43
40
|
//style to show limits between pieces
|
|
44
41
|
const sst = new StrokeStyle({
|
|
45
42
|
strokeColor: () => '#666',
|
|
46
|
-
strokeWidth: (
|
|
43
|
+
strokeWidth: (c, r, z) => 0.2 * z,
|
|
47
44
|
filter: opts.filter,
|
|
48
45
|
})
|
|
49
46
|
|
|
@@ -56,20 +53,21 @@ export class LegoStyle {
|
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
/**
|
|
59
|
-
* @param {function(
|
|
56
|
+
* @param {function(import('../core/Dataset.js').Cell):string} code
|
|
57
|
+
* @param {object} color
|
|
60
58
|
* @param {object} opts
|
|
61
59
|
* @returns {Array.<Style>}
|
|
62
60
|
*/
|
|
63
|
-
static
|
|
61
|
+
static getCategory(code, color, opts) {
|
|
64
62
|
opts = opts || {}
|
|
65
63
|
|
|
66
64
|
opts.colDark = opts.colDark || '#333'
|
|
67
65
|
opts.colBright = opts.colBright || '#aaa'
|
|
68
66
|
|
|
69
67
|
//
|
|
70
|
-
const s = new SquareColorCategoryWebGLStyle({
|
|
68
|
+
const s = new SquareColorCategoryWebGLStyle({ code: code, color: color })
|
|
71
69
|
//style to show limits between pieces
|
|
72
|
-
const sst = new StrokeStyle({ strokeColor: () => '#666', strokeWidth: (
|
|
70
|
+
const sst = new StrokeStyle({ strokeColor: () => '#666', strokeWidth: (c, r, z) => 0.2 * z })
|
|
73
71
|
|
|
74
72
|
return [s, sst, new LegoTopStyle({ colDark: opts.colDark, colBright: opts.colBright })]
|
|
75
73
|
}
|
|
@@ -87,26 +85,26 @@ class LegoTopStyle extends Style {
|
|
|
87
85
|
this.colBright = opts.colBright || '#aaa'
|
|
88
86
|
}
|
|
89
87
|
|
|
90
|
-
draw(cells,
|
|
88
|
+
draw(cells, geoCanvas, r) {
|
|
91
89
|
//filter
|
|
92
90
|
if (this.filter) cells = cells.filter(this.filter)
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
geoCanvas.ctx.lineWidth = 0.6 * geoCanvas.view.z
|
|
95
93
|
|
|
96
94
|
//dark part
|
|
97
|
-
|
|
95
|
+
geoCanvas.ctx.strokeStyle = this.colDark
|
|
98
96
|
for (let c of cells) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
geoCanvas.ctx.beginPath()
|
|
98
|
+
geoCanvas.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)
|
|
99
|
+
geoCanvas.ctx.stroke()
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
//bright part
|
|
105
|
-
|
|
103
|
+
geoCanvas.ctx.strokeStyle = this.colBright
|
|
106
104
|
for (let c of cells) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
geoCanvas.ctx.beginPath()
|
|
106
|
+
geoCanvas.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)
|
|
107
|
+
geoCanvas.ctx.stroke()
|
|
110
108
|
}
|
|
111
109
|
}
|
|
112
110
|
}
|
package/src/style/MosaicStyle.js
CHANGED