mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Added the hex shape to the renderer, and support for it in the flow parser.
Need to work on properly sizing it.
This commit is contained in:
parent
18f35ac213
commit
51e902cd36
@ -121,6 +121,9 @@ export const addVertices = function(vert, g, svgId) {
|
||||
case 'diamond':
|
||||
_shape = 'question';
|
||||
break;
|
||||
case 'hexagon':
|
||||
_shape = 'hexagon';
|
||||
break;
|
||||
case 'odd':
|
||||
_shape = 'rect_left_inv_arrow';
|
||||
break;
|
||||
@ -358,6 +361,37 @@ export const draw = function(text, id) {
|
||||
return shapeSvg;
|
||||
};
|
||||
|
||||
render.shapes().hexagon = function(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
const h = bbox.height;
|
||||
const s = (w + h) * 0.9;
|
||||
const points = [
|
||||
{ x: s / 4, y: 0 },
|
||||
{ x: (3 * s) / 4, y: 0 },
|
||||
{ x: s, y: -s / 2 },
|
||||
{ x: (3 * s) / 4, y: -s },
|
||||
{ x: s / 4, y: -s },
|
||||
{ x: 0, y: -s / 2 }
|
||||
];
|
||||
const shapeSvg = parent
|
||||
.insert('polygon', ':first-child')
|
||||
.attr(
|
||||
'points',
|
||||
points
|
||||
.map(function(d) {
|
||||
return d.x + ',' + d.y;
|
||||
})
|
||||
.join(' ')
|
||||
)
|
||||
.attr('rx', 5)
|
||||
.attr('ry', 5)
|
||||
.attr('transform', 'translate(' + -s / 2 + ',' + (s * 2) / 4 + ')');
|
||||
node.intersect = function(point) {
|
||||
return dagreD3.intersect.polygon(node, points, point);
|
||||
};
|
||||
return shapeSvg;
|
||||
};
|
||||
|
||||
// Add custom shape for box with inverted arrow on left side
|
||||
render.shapes().rect_left_inv_arrow = function(parent, bbox, node) {
|
||||
const w = bbox.width;
|
||||
|
@ -313,6 +313,10 @@ vertex: idString SQS text SQE
|
||||
{$$ = $1;yy.addVertex($1,$3,'diamond');}
|
||||
| idString DIAMOND_START text DIAMOND_STOP spaceList
|
||||
{$$ = $1;yy.addVertex($1,$3,'diamond');}
|
||||
| idString DIAMOND_START DIAMOND_START text DIAMOND_STOP DIAMOND_STOP
|
||||
{$$ = $1;yy.addVertex($1,$4,'hexagon');}
|
||||
| idString DIAMOND_START DIAMOND_START text DIAMOND_STOP DIAMOND_STOP spaceList
|
||||
{$$ = $1;yy.addVertex($1,$4,'hexagon');}
|
||||
| idString TAGEND text SQE
|
||||
{$$ = $1;yy.addVertex($1,$3,'odd');}
|
||||
| idString TAGEND text SQE spaceList
|
||||
|
Loading…
x
Reference in New Issue
Block a user