#530 Better shaping of hexagon

The "corner" triangles are a fixed ratio to the height,
so the triangles will always be mathemtically similar.
This commit is contained in:
Brian Mearns 2019-10-02 22:36:02 -04:00
parent 57921e3f52
commit 550f91aa68
1 changed files with 8 additions and 7 deletions

View File

@ -362,15 +362,16 @@ export const draw = function(text, id) {
};
render.shapes().hexagon = function(parent, bbox, node) {
const q = 7;
const w = (q / (q - 2)) * bbox.width;
const f = 4;
const h = bbox.height;
const m = h / 4;
const w = bbox.width + 2 * m;
const points = [
{ x: w / q, y: 0 },
{ x: (w * (q - 1)) / q, y: 0 },
{ x: m, y: 0 },
{ x: w - m, y: 0 },
{ x: w, y: -h / 2 },
{ x: (w * (q - 1)) / q, y: -h },
{ x: w / q, y: -h },
{ x: w - m, y: -h },
{ x: m, y: -h },
{ x: 0, y: -h / 2 }
];
const shapeSvg = parent
@ -385,7 +386,7 @@ export const draw = function(text, id) {
)
.attr('rx', 5)
.attr('ry', 5)
.attr('transform', 'translate(' + -w / 2 + ',' + (h * 2) / 4 + ')');
.attr('transform', 'translate(' + -w / 2 + ',' + h / 2 + ')');
node.intersect = function(point) {
return dagreD3.intersect.polygon(node, points, point);
};