Переделано построение всех карт
This commit is contained in:
@@ -38,6 +38,22 @@ export default {
|
||||
return new SvgNode("circle", {r})
|
||||
},
|
||||
|
||||
ngon(r, n, ang = 0) {
|
||||
const da = 2 * Math.PI / n
|
||||
ang = ang * Math.PI / 180
|
||||
const pts = Array(n).fill(0).map((x, i) => [Math.sin(i * da + ang) * r, Math.cos(i * da + ang) * r])
|
||||
return new SvgNode("polygon", {points: pts.map(x => `${x[0]},${x[1]}`)})
|
||||
},
|
||||
|
||||
spike1(w, h, ang){
|
||||
const da = ang * Math.PI / 180
|
||||
const sa = Math.sin(da)
|
||||
const ca = Math.cos(da)
|
||||
h = h / 2
|
||||
const pts = `${-sa*h},${-ca*h} ${ca*w},${-sa*w}, ${sa*h},${ca*h}`
|
||||
return new SvgNode("polygon", {points: pts})
|
||||
},
|
||||
|
||||
sector(r, a0, a1) {
|
||||
const k = Math.PI / 180;
|
||||
let s0 = -Math.sin(a0 * k) * r;
|
||||
@@ -80,7 +96,7 @@ export default {
|
||||
ring_sectors(r0, r1, sectors){
|
||||
let sum = sectors.reduce((s,c) => s + c.v, 0)
|
||||
let angs = sectors.reduce((s, c, i) => [...s, {...c, a0: i && s[i - 1].a1, a1: c.v + (i && s[i - 1].a1)}], [])
|
||||
let items = angs.map(x => this.ring_sector(r0, r1, x.a0 * 360 / sum, x.a1 * 360 / sum).set_style(x.style))
|
||||
let items = angs.map(x => this.ring_sector(r0, r1, x.a0 * 360 / sum, x.a1 * 360 / sum).add_style(x.style))
|
||||
|
||||
return this.group(items)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user