gridviz 2.1.5 → 2.1.6
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 +17 -9
- package/dist/gridviz.min.js +1 -1
- package/package.json +1 -1
- package/src/style/IsoFenceStyle.js +16 -8
package/package.json
CHANGED
|
@@ -33,12 +33,12 @@ export class IsoFenceStyle extends Style {
|
|
|
33
33
|
this.angle = opts.angle != undefined ? opts.angle : 45
|
|
34
34
|
|
|
35
35
|
/** A function returning the corner line stroke style.
|
|
36
|
-
* @type {function(import('../Dataset.js').Cell,number,number):string} */
|
|
37
|
-
this.cornerLineStrokeColor = opts.cornerLineStrokeColor || ((c, r, zf) => "#333")
|
|
36
|
+
* @type {function(import('../Dataset.js').Cell,number,number,number):string} */
|
|
37
|
+
this.cornerLineStrokeColor = opts.cornerLineStrokeColor || ((c, r, zf, angle) => "#333")
|
|
38
38
|
|
|
39
39
|
/** A function returning the corner line width.
|
|
40
|
-
* @type {function(import('../Dataset.js').Cell,number,number):number} */
|
|
41
|
-
this.cornerLineWidth = opts.cornerLineWidth || ((c, r, zf) => 0.8 * zf)
|
|
40
|
+
* @type {function(import('../Dataset.js').Cell,number,number,number):number} */
|
|
41
|
+
this.cornerLineWidth = opts.cornerLineWidth || ((c, r, zf, angle) => (angle % 90 == 0 ? 0 : 0.8 * zf))
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -131,8 +131,16 @@ export class IsoFenceStyle extends Style {
|
|
|
131
131
|
//draw in geo coordinates
|
|
132
132
|
cg.setCanvasTransform()
|
|
133
133
|
|
|
134
|
-
//sort sides so that the
|
|
135
|
-
|
|
134
|
+
//sort sides so that the back ones are drawn first. This depends on the angle
|
|
135
|
+
if (Math.abs(this.angle) <= 90)
|
|
136
|
+
//north east ones are drown first
|
|
137
|
+
sides.sort((s1, s2) => (Math.hypot(s2.x, s2.y) - Math.hypot(s1.x, s1.y)))
|
|
138
|
+
else if (this.angle > 90)
|
|
139
|
+
//north west ones are drown first
|
|
140
|
+
sides.sort((s1, s2) => (Math.hypot(s2.x - cg.extGeo.xMax, s2.y) - Math.hypot(s1.x - cg.extGeo.xMax, s1.y)))
|
|
141
|
+
else if (this.angle < 90)
|
|
142
|
+
//south west ones are drown first
|
|
143
|
+
sides.sort((s1, s2) => (Math.hypot(s2.x - cg.extGeo.xMax, s2.y - cg.extGeo.yMax) - Math.hypot(s1.x - cg.extGeo.xMax, s1.y - cg.extGeo.yMax)))
|
|
136
144
|
|
|
137
145
|
//draw sides
|
|
138
146
|
for (let s of sides) {
|
|
@@ -203,8 +211,8 @@ export class IsoFenceStyle extends Style {
|
|
|
203
211
|
//height - in geo
|
|
204
212
|
const hG = h_(c[this.heightCol], r, stat, zf)
|
|
205
213
|
|
|
206
|
-
cg.ctx.strokeStyle = this.cornerLineStrokeColor ? this.cornerLineStrokeColor(c, r, zf) : "#333"
|
|
207
|
-
cg.ctx.lineWidth = this.cornerLineWidth ? this.cornerLineWidth(c, r, zf) : 0.8 * zf
|
|
214
|
+
cg.ctx.strokeStyle = this.cornerLineStrokeColor ? this.cornerLineStrokeColor(c, r, zf, this.angle) : "#333"
|
|
215
|
+
cg.ctx.lineWidth = this.cornerLineWidth ? this.cornerLineWidth(c, r, zf, this.angle) : 0.8 * zf
|
|
208
216
|
|
|
209
217
|
cg.ctx.beginPath()
|
|
210
218
|
cg.ctx.moveTo(c.x + r2, c.y + r2)
|