This repository has been archived by the owner on Jul 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new Hexagon shape in the Network (#3420)
* added hexagon shape to the node. * Updated function for hexagon shape.js * Modifid the shape login for hexagon * Remove this.translate from the Shape.js for hexagon * updated hexagon draw logic * Fixed code review comments and update the branch * Updated changes in test.js
- Loading branch information
Showing
6 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
|
||
import ShapeBase from '../util/ShapeBase' | ||
|
||
/** | ||
* A Hexagon Node/Cluster shape. | ||
* | ||
* @extends ShapeBase | ||
*/ | ||
class Hexagon extends ShapeBase { | ||
/** | ||
* @param {Object} options | ||
* @param {Object} body | ||
* @param {Label} labelModule | ||
*/ | ||
constructor(options, body, labelModule) { | ||
super(options, body, labelModule) | ||
} | ||
|
||
/** | ||
* | ||
* @param {CanvasRenderingContext2D} ctx | ||
* @param {number} x width | ||
* @param {number} y height | ||
* @param {boolean} selected | ||
* @param {boolean} hover | ||
* @param {{toArrow: boolean, toArrowScale: (allOptions.edges.arrows.to.scaleFactor|{number}|allOptions.edges.arrows.middle.scaleFactor|allOptions.edges.arrows.from.scaleFactor|Array|number), toArrowType: *, middleArrow: boolean, middleArrowScale: (number|allOptions.edges.arrows.middle.scaleFactor|{number}|Array), middleArrowType: (allOptions.edges.arrows.middle.type|{string}|string|*), fromArrow: boolean, fromArrowScale: (allOptions.edges.arrows.to.scaleFactor|{number}|allOptions.edges.arrows.middle.scaleFactor|allOptions.edges.arrows.from.scaleFactor|Array|number), fromArrowType: *, arrowStrikethrough: (*|boolean|allOptions.edges.arrowStrikethrough|{boolean}), color: undefined, inheritsColor: (string|string|string|allOptions.edges.color.inherit|{string, boolean}|Array|*), opacity: *, hidden: *, length: *, shadow: *, shadowColor: *, shadowSize: *, shadowX: *, shadowY: *, dashes: (*|boolean|Array|allOptions.edges.dashes|{boolean, array}), width: *}} values | ||
*/ | ||
draw(ctx, x, y, selected, hover, values) { | ||
this._drawShape(ctx, 'hexagon', 4, x, y, selected, hover, values); | ||
} | ||
|
||
/** | ||
* | ||
* @param {CanvasRenderingContext2D} ctx | ||
* @param {number} angle | ||
* @returns {number} | ||
*/ | ||
distanceToBorder(ctx, angle) { | ||
return this._distanceToBorder(ctx,angle); | ||
} | ||
} | ||
|
||
export default Hexagon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters