@neo4j-nvl/base 0.3.1-3ce43a8b
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/LICENSE.txt +49 -0
- package/README.md +43 -0
- package/dist/base.mjs +2 -0
- package/dist/base.mjs.LICENSE.txt +10 -0
- package/dist/types/index.d.ts +379 -0
- package/dist/types/layouts/animatedlayout/AnimatedLayout.d.ts +25 -0
- package/dist/types/layouts/animatedlayout/animationUtils.d.ts +9 -0
- package/dist/types/layouts/d3forcelayout/circularLayout.d.ts +5 -0
- package/dist/types/layouts/d3forcelayout/constants.d.ts +18 -0
- package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +29 -0
- package/dist/types/layouts/d3forcelayout/types.d.ts +9 -0
- package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +24 -0
- package/dist/types/layouts/forcedirectedlayout/cosebilkentlayout/CoseBilkentLayout.d.ts +32 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +167 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/glwrapper.d.ts +4 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-update-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/sim-vertex.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/workaround-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +43 -0
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/solar-placer.d.ts +4 -0
- package/dist/types/layouts/freeLayout/FreeLayout.d.ts +26 -0
- package/dist/types/layouts/gridLayout/GridLayout.d.ts +16 -0
- package/dist/types/layouts/hierarchicallayout/HierarchicalLayout.d.ts +26 -0
- package/dist/types/layouts/hierarchicallayout/constants.d.ts +11 -0
- package/dist/types/modules/CallbackHelper.d.ts +38 -0
- package/dist/types/modules/ExternalCallbackHandler.d.ts +25 -0
- package/dist/types/modules/NvlController.d.ts +119 -0
- package/dist/types/modules/Shader.d.ts +18 -0
- package/dist/types/modules/ZoomTransitionHandler.d.ts +27 -0
- package/dist/types/modules/dataset.d.ts +37 -0
- package/dist/types/modules/logging.d.ts +5 -0
- package/dist/types/modules/performance.d.ts +93 -0
- package/dist/types/modules/state.d.ts +232 -0
- package/dist/types/renderers/canvasrenderer/Animation.d.ts +64 -0
- package/dist/types/renderers/canvasrenderer/AnimationHandler.d.ts +72 -0
- package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +92 -0
- package/dist/types/renderers/canvasrenderer/ImageCache.d.ts +11 -0
- package/dist/types/renderers/canvasrenderer/arrows/ArrowBundle.d.ts +79 -0
- package/dist/types/renderers/canvasrenderer/arrows/ArrowBundler.d.ts +33 -0
- package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +50 -0
- package/dist/types/renderers/canvasrenderer/arrows/constants.d.ts +54 -0
- package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +58 -0
- package/dist/types/renderers/canvasrenderer/types.d.ts +47 -0
- package/dist/types/renderers/canvasrenderer/util.d.ts +69 -0
- package/dist/types/renderers/canvasrenderer/vectorUtils.d.ts +21 -0
- package/dist/types/renderers/canvasrenderer/wordwrap.d.ts +42 -0
- package/dist/types/renderers/webglrenderer/Controller.d.ts +66 -0
- package/dist/types/renderers/webglrenderer/Renderer.d.ts +52 -0
- package/dist/types/renderers/webglrenderer/node-animation-fragment.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/node-animation-vertex.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/rel-fragment-line.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/rel-vertex-line.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +2 -0
- package/dist/types/types/graph-element.d.ts +88 -0
- package/dist/types/utils/canvasManagement.d.ts +15 -0
- package/dist/types/utils/colorMapperFunctions.d.ts +6 -0
- package/dist/types/utils/constants.d.ts +30 -0
- package/dist/types/utils/errors.d.ts +11 -0
- package/dist/types/utils/geometry.d.ts +122 -0
- package/dist/types/utils/graphObjectUtils.d.ts +9 -0
- package/dist/types/utils/hittest.d.ts +56 -0
- package/dist/types/utils/mouseUtils.d.ts +9 -0
- package/dist/types/utils/zoomFunctions.d.ts +20 -0
- package/package.json +63 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Node, Relationship } from '../../../types/graph-element';
|
|
2
|
+
import type { Point } from '../../../utils/geometry';
|
|
3
|
+
import type ArrowBundle from './ArrowBundle';
|
|
4
|
+
/**
|
|
5
|
+
* This function calculates the difference in radius between two nodes.
|
|
6
|
+
* @param {number} toArrowGap - The gap between the node and the arrow on the to side.
|
|
7
|
+
* @param {number} fromArrowGap - The gap between the node and the arrow on the from side.
|
|
8
|
+
* @returns {number} The difference in radius between the two nodes.
|
|
9
|
+
* @comment can be affected for example by the label crust and selected ring
|
|
10
|
+
* as well as a gap between the node and the arrow on it's side.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getRadiusDifference: (toArrowGap: number, fromArrowGap: number) => number;
|
|
13
|
+
/**
|
|
14
|
+
* This function calculates the coordinates of the via point
|
|
15
|
+
* between two nodes. The via point is used to bend the edge
|
|
16
|
+
* between the two nodes.
|
|
17
|
+
* @param {Node} fromNode - The node the edge starts from.
|
|
18
|
+
* @param {Node} toNode - The node the edge ends at.
|
|
19
|
+
* @param {number} fromArrowGap - The gap between the node and the arrow on the from side.
|
|
20
|
+
* @param {number} toArrowGap - The gap between the node and the arrow on the to side.
|
|
21
|
+
* @returns {Point} The coordinates of the via point.
|
|
22
|
+
*/
|
|
23
|
+
export declare const getViaCoordinates: (fromNode: Node, toNode: Node, fromArrowGap: number, toArrowGap: number, rel: Relationship, bundle: ArrowBundle) => Point;
|
|
24
|
+
export declare const getPointsForStraight: (rel: Relationship, bundle: ArrowBundle, fromNode: Node, toNode: Node, showLabel: boolean, curved?: boolean) => Point[];
|
|
25
|
+
/**
|
|
26
|
+
* Draws a label for a relationship
|
|
27
|
+
* @param {CanvasRenderingContext2D} ctx - the canvas context
|
|
28
|
+
* @param {number} x - the x coordinate of the label
|
|
29
|
+
* @param {number} y - the y coordinate of the label
|
|
30
|
+
* @param {number} angle - the angle of the label
|
|
31
|
+
* @param {number} maxWidth - the maximum width of the label
|
|
32
|
+
* @param {Relationship} rel - the relationship
|
|
33
|
+
* @param {boolean} flip - whether to flip the label
|
|
34
|
+
*/
|
|
35
|
+
export declare const drawLabel: (ctx: CanvasRenderingContext2D, point: Point, angle: number, maxWidth: number, rel: Relationship, bundle: ArrowBundle, flip?: boolean) => void;
|
|
36
|
+
export declare const renderWaypointArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, from: Node, to: Node, bundle: ArrowBundle, showLabel: boolean, drawCurves: boolean) => void;
|
|
37
|
+
export declare const renderSelfArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, node: Node, bundle: ArrowBundle, showLabel: boolean) => void;
|
|
38
|
+
export declare const renderArrow: (ctx: CanvasRenderingContext2D, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, showLabel: boolean, drawCurves?: boolean) => void;
|
|
39
|
+
export declare const distanceToEdge: (pos: Point, rel: Relationship, fromNode: Node, toNode: Node, bundle: ArrowBundle, showLabel: boolean, drawCurves?: boolean) => number;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the bounding box of the arrow.
|
|
42
|
+
* @param {Relationship} rel - The relationship to get the bounding box for.
|
|
43
|
+
* @param {ArrowBundle} bundle - The arrow bundle the relationship is part of.
|
|
44
|
+
* @param {Node} fromNode - The node the relationship is coming from.
|
|
45
|
+
* @param {Node} toNode - The node the relationship is going to.
|
|
46
|
+
* @param {boolean} showLabel - Whether or not a label is shown.
|
|
47
|
+
* @param {boolean} drawCurves - Whether or the relationship is drawn as a curve.
|
|
48
|
+
* @returns {DOMRect} The bounding box of the arrow.
|
|
49
|
+
*/
|
|
50
|
+
export declare const getBoundingBox: (rel: Relationship, bundle: ArrowBundle, fromNode: Node, toNode: Node, showLabel?: boolean, drawCurves?: boolean) => DOMRect | null;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** The gap between a node and a relationship. */
|
|
2
|
+
export declare const NodeGap = 4;
|
|
3
|
+
/** The increase of the gap between a node and relationship when the node is selected */
|
|
4
|
+
export declare const SelectGap = 4;
|
|
5
|
+
/** The width of arrow heads. */
|
|
6
|
+
export declare const HeadWidth = 7;
|
|
7
|
+
/** The height of arrow heads. */
|
|
8
|
+
export declare const HeadHeight = 9;
|
|
9
|
+
/** The chin height of arrows. */
|
|
10
|
+
export declare const HeadChinHeight = 2;
|
|
11
|
+
/** The default color of relationships. */
|
|
12
|
+
export declare const RelColor = "#848484";
|
|
13
|
+
/** The length of the curve of a curved relationship. */
|
|
14
|
+
export declare const TaperRelLength = 30;
|
|
15
|
+
/** The distance of the starting points of relationships in a bundle. */
|
|
16
|
+
export declare const BundleAngleSep: number;
|
|
17
|
+
/** The distance needed to draw an arrow head in a bundled relationship. */
|
|
18
|
+
export declare const BundleArrowDist = 8;
|
|
19
|
+
/** The distance needed to draw an arrow head in a detailed bundled relationship. */
|
|
20
|
+
export declare const BundleArrowDistDetailed = 17;
|
|
21
|
+
/** The angle of the starting - and ending points of a self-referring relationship. */
|
|
22
|
+
export declare const SelfRefAngle: number;
|
|
23
|
+
/** The width of a self-referring relationship. */
|
|
24
|
+
export declare const SelfRefWidth = 25;
|
|
25
|
+
/** The height of a self-referring relationship. */
|
|
26
|
+
export declare const SelfRefHeight = 35;
|
|
27
|
+
/** The maximum width of a self-referring relationship's label. */
|
|
28
|
+
export declare const SelfRefLabelMaxWidth = 40;
|
|
29
|
+
/** Width increase when a relationship is selected. */
|
|
30
|
+
export declare const SelectedWidthFactor = 1.5;
|
|
31
|
+
/** The width of the outline of a selected relationship. */
|
|
32
|
+
export declare const SelectedOutlineWidth = 2;
|
|
33
|
+
/** The color of the first outline of a selected relationship. */
|
|
34
|
+
export declare const SelectedOutlineColor1 = "white";
|
|
35
|
+
/** The color of the second outline of a selected relationship. */
|
|
36
|
+
export declare const SelectedOutlineColor2 = "#45bff8";
|
|
37
|
+
/** The shadow properties of a selected relationship. */
|
|
38
|
+
export declare const SelectedShadow: {
|
|
39
|
+
color: string;
|
|
40
|
+
size: number;
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
};
|
|
44
|
+
/** The style properties of a disabled relationship. */
|
|
45
|
+
export declare const Disabled: {
|
|
46
|
+
color: string;
|
|
47
|
+
fontColor: string;
|
|
48
|
+
};
|
|
49
|
+
/** The font styles for relationship captions. */
|
|
50
|
+
export declare const Font: {
|
|
51
|
+
size: number;
|
|
52
|
+
color: string;
|
|
53
|
+
face: string;
|
|
54
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { NodeBorderStyles } from '../../../modules/state';
|
|
2
|
+
import type { Node } from '../../../types/graph-element';
|
|
3
|
+
import type AnimationHandler from '../AnimationHandler';
|
|
4
|
+
type RingStyle = {
|
|
5
|
+
width: number;
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Returns an array of styles for the rings of a node.
|
|
10
|
+
* It takes the node as an argument, and an optional array of size animations.
|
|
11
|
+
* If the node is selected, it returns the selectedStyle.rings array.
|
|
12
|
+
* If the node is not selected, it returns an array containing only one object with
|
|
13
|
+
* a width of 0 and an empty color.
|
|
14
|
+
* @param node {Node} - The node to get the ring styles for.
|
|
15
|
+
* @param animationHandler {AnimationHandler} - The animation handler.
|
|
16
|
+
* @param nodeBorderStyles {NodeBorderStyles} - The node border styles.
|
|
17
|
+
* @returns {{ width: number, color: string }[]} - An array of ring styles.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getRingStyles: (node: Node, animationHandler: AnimationHandler, nodeBorderStyles: any) => RingStyle[];
|
|
20
|
+
/**
|
|
21
|
+
* Returns the bounding box of a node with the given x, y, and size properties.
|
|
22
|
+
* If no size is given, the default size is used.
|
|
23
|
+
* @param {Node} Node - The node to get the bounding box for.
|
|
24
|
+
* @returns {object} The bounding box of the node.
|
|
25
|
+
*/
|
|
26
|
+
export declare const getBoundingBox: ({ x, y, size }: Node) => DOMRect;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the caption font size that should be used
|
|
29
|
+
* for the given info level and node diameter.
|
|
30
|
+
* @param infoLevel {number} - The info level.
|
|
31
|
+
* @param nodeRadius {number} - The radius of the node.
|
|
32
|
+
* @param captionSize {number} - The size of the caption.
|
|
33
|
+
* @returns {number} - The font size.
|
|
34
|
+
*/
|
|
35
|
+
export declare const infoLevelToFontSize: (infoLevel: number, nodeRadius?: number, captionSize?: number, hasIcon?: boolean) => number;
|
|
36
|
+
/**
|
|
37
|
+
* Returns maximum length of lines
|
|
38
|
+
* @param lines {array} - The lines info
|
|
39
|
+
* @returns {number} - The font size.
|
|
40
|
+
*/
|
|
41
|
+
export declare const findMaxLength: (lines: any[], ctx: CanvasRenderingContext2D, pixelRatio: number) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Returns minimum length of lines
|
|
44
|
+
* @param lines {array} - The lines info
|
|
45
|
+
* @returns {number} - The font size.
|
|
46
|
+
*/
|
|
47
|
+
export declare const findMinLength: (lines: any[], ctx: CanvasRenderingContext2D, pixelRatio: number) => any;
|
|
48
|
+
/**
|
|
49
|
+
* Draws a node with the given context, node, and image cache.
|
|
50
|
+
* @param ctx {any} - The context to draw the node on.
|
|
51
|
+
* @param node {Node} - The node to draw.
|
|
52
|
+
* @param imageCache {any} - The image cache to use.
|
|
53
|
+
* @param animationHandler {AnimationHandler} - The animation handler.
|
|
54
|
+
* @param nodeBorderStyles {NodeBorderStyles} - The node border styles.
|
|
55
|
+
* @param zoomLevel {number} - The current zoom level.
|
|
56
|
+
*/
|
|
57
|
+
export declare const drawNode: (ctx: CanvasRenderingContext2D, node: Node, imageCache: any, animationHandler: AnimationHandler, nodeBorderStyles: NodeBorderStyles, zoomLevel?: number) => void;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Node, Relationship } from '../../types/graph-element';
|
|
2
|
+
import type { Point } from '../../utils/geometry';
|
|
3
|
+
export type TextSegment = {
|
|
4
|
+
hasEllipsisChar?: boolean;
|
|
5
|
+
hasHyphenChar?: boolean;
|
|
6
|
+
text: string;
|
|
7
|
+
overflowed?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The caption text and its text style.
|
|
11
|
+
* @property styles - The font styles as comma separated values
|
|
12
|
+
* @example 'bold,italic'
|
|
13
|
+
* @property value - The text for the caption.
|
|
14
|
+
* @property key - The caption identifier key.
|
|
15
|
+
*/
|
|
16
|
+
export type StyledCaption = {
|
|
17
|
+
styles?: string[];
|
|
18
|
+
value?: string;
|
|
19
|
+
key?: string;
|
|
20
|
+
};
|
|
21
|
+
export type StyledCaptionWithChars = StyledCaption & {
|
|
22
|
+
chars?: string[][];
|
|
23
|
+
};
|
|
24
|
+
export type CacheItem = {
|
|
25
|
+
image?: CacheInfo;
|
|
26
|
+
inverted?: CacheInfo;
|
|
27
|
+
};
|
|
28
|
+
export type CacheInfo = {
|
|
29
|
+
canvas: HTMLCanvasElement;
|
|
30
|
+
image: HTMLImageElement;
|
|
31
|
+
drawn: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type Cache = Record<string, CacheItem>;
|
|
34
|
+
export interface RelationshipToRender extends Relationship {
|
|
35
|
+
fromNode: Node;
|
|
36
|
+
toNode: Node;
|
|
37
|
+
showLabel: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface WaypointPath {
|
|
40
|
+
points: Point[];
|
|
41
|
+
from: Point;
|
|
42
|
+
to: Point;
|
|
43
|
+
}
|
|
44
|
+
export interface ArrowBundleGap {
|
|
45
|
+
size: number;
|
|
46
|
+
start: number;
|
|
47
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Point } from '../../utils/geometry';
|
|
2
|
+
import type { TextSegment } from './types';
|
|
3
|
+
export declare const fontThresholds: number[][];
|
|
4
|
+
/**
|
|
5
|
+
* This function takes color in hex format or rgb() or rgba() format and overrides the opacity. Returns rgba() string.
|
|
6
|
+
* @param {string} color
|
|
7
|
+
* @param {number} opacity
|
|
8
|
+
* @returns {string} rgba() string with the given opacity
|
|
9
|
+
*/
|
|
10
|
+
export declare const overrideOpacity: (color: string, opacity: number) => string;
|
|
11
|
+
/**
|
|
12
|
+
* The parameters for drawing an arrowhead.
|
|
13
|
+
*/
|
|
14
|
+
type ArrowHeadParameters = {
|
|
15
|
+
headPosition: Point;
|
|
16
|
+
headAngle: number;
|
|
17
|
+
headHeight: number;
|
|
18
|
+
headChinHeight: number;
|
|
19
|
+
headWidth: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Creates an arrowhead shape using a polygon.
|
|
23
|
+
* @param {CanvasRenderingContext2D} ctx - The canvas context to draw on.
|
|
24
|
+
* @param {number} headLineWidth - The width of the arrowhead's outline.
|
|
25
|
+
* @param {string} color - The color of the arrowhead.
|
|
26
|
+
* @param {ArrowHeadParameters} arrowHeadParameters - The parameters for the arrowhead.
|
|
27
|
+
* @param {boolean} fill - Whether or not to fill the triangle.
|
|
28
|
+
* @param {boolean} stroke - Whether or not to stroke the triangle.
|
|
29
|
+
*/
|
|
30
|
+
export declare const drawArrowHead: (ctx: CanvasRenderingContext2D, headLineWidth: number, color: string, arrowHeadParameters: ArrowHeadParameters, fill?: boolean, stroke?: boolean) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Draws borders around a node with a given array of border styles
|
|
33
|
+
* @param {CanvasRenderingContext2D} ctx - The canvas context
|
|
34
|
+
* @param {number} x - The x coordinate of the node
|
|
35
|
+
* @param {number} y - The y coordinate of the node
|
|
36
|
+
* @param {number} innerRadius - The inner radius of the node without any border
|
|
37
|
+
* @param {Array} borderStyles - An array of border styles
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
export declare const drawCircleBand: (ctx: CanvasRenderingContext2D, x: number, y: number, innerRadius: number, borderStyles: {
|
|
41
|
+
width: number;
|
|
42
|
+
color: string;
|
|
43
|
+
}[]) => void;
|
|
44
|
+
export declare const drawCircle: (ctx: CanvasRenderingContext2D, x: number, y: number, r: number) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Fill a circle band with a gradient from a certain color to transparent
|
|
47
|
+
* @param {CanvasRenderingContext2D} ctx - The canvas context
|
|
48
|
+
* @param {number} x - The x coordinate of the node
|
|
49
|
+
* @param {number} y - The y coordinate of the node
|
|
50
|
+
* @param {string} color - The color of the gradient
|
|
51
|
+
* @param {number} radius - The inner radius of the node without any border
|
|
52
|
+
* @param {number} blur - The blur radius of the gradient
|
|
53
|
+
* @param {number} maxOpacity - The maximum opacity of the gradient
|
|
54
|
+
*/
|
|
55
|
+
export declare const drawGradientCircleBand: (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, radius: number, blur: number, maxOpacity?: number) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Draw a circle shape with a solid color
|
|
58
|
+
*/
|
|
59
|
+
export declare const drawSolidCircle: (ctx: CanvasRenderingContext2D, x: number, y: number, color: string, size: number) => void;
|
|
60
|
+
export declare function getIndividualInfoLevels(r: number, zoomLevel: number): {
|
|
61
|
+
nodeInfoLevel: number;
|
|
62
|
+
fontInfoLevel: number;
|
|
63
|
+
iconInfoLevel: number;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Prints the caption for a node
|
|
67
|
+
*/
|
|
68
|
+
export declare const drawNodeCaption: (ctx: CanvasRenderingContext2D, lines: TextSegment[], stylesPerChar: string[][], initialYPos: number, fontSize: number, fontFace: string, lineDistance: number, x: number, y: number) => void;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Point } from '../../utils/geometry';
|
|
2
|
+
export declare const add: (v1: Point, v2: Point) => {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const sub: (v1: Point, v2: Point) => {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const scale: (v: Point, s: number) => {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const dot: (v1: Point, v2: Point) => number;
|
|
15
|
+
export declare const getModule: (v1: Point) => number;
|
|
16
|
+
export declare const distance: (v1: Point, v2: Point) => number;
|
|
17
|
+
export declare const angle: (v1: Point, v2: Point) => number;
|
|
18
|
+
export declare const coordFromPolar: (polarAngle: number, polarModule: number) => {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { StyledCaption, TextSegment } from './types';
|
|
2
|
+
export declare const hyphenChar = "\u2010";
|
|
3
|
+
export declare const ellipsisChar = "\u2026";
|
|
4
|
+
/**
|
|
5
|
+
* This is the main function that tries to fit a text on one or more lines
|
|
6
|
+
*
|
|
7
|
+
* @param {string} text = The full string to place
|
|
8
|
+
* @param {function} measureWidth - a function that returns the width of a string as pixels on the canvas
|
|
9
|
+
* @param {function} getAvailbleWidth - A function providing the pixel width for a line index
|
|
10
|
+
* @param {number} numberOfLines - How many lines is availble for this placement
|
|
11
|
+
* @param {boolean} allowedToGiveUp - If cannot fit on last avilble line - should we give up or place as much as we can
|
|
12
|
+
*
|
|
13
|
+
* @return array of text lines
|
|
14
|
+
*/
|
|
15
|
+
export declare const tryWithNumberOfLines: (text: string, measureWidth: (text: string) => number, getAvailableWidth: (a: number, b: number) => number, numberOfLines: number, allowedToGiveUp?: boolean) => TextSegment[];
|
|
16
|
+
/**
|
|
17
|
+
* This functions tries to fit the text in a given number of lines and only linebreak on whitespace
|
|
18
|
+
*
|
|
19
|
+
* @param {string} text = The full string to place
|
|
20
|
+
* @param {function} measureWidth - a function that returns the width of a string as pixels on the canvas
|
|
21
|
+
* @param {function} getAvailbleWidth - A function providing the pixel width for a line index
|
|
22
|
+
* @param {number} numberOfLines - How many lines is availble for this placement
|
|
23
|
+
*
|
|
24
|
+
* @return array of text lines
|
|
25
|
+
*/
|
|
26
|
+
export declare const tryBreakingOnSpaces: (text: string, measureWidth: (text: string) => number, getAvailableWidth: (a: number, b: number) => number, numberOfLines: number) => TextSegment[];
|
|
27
|
+
/**
|
|
28
|
+
* @param {object} ctx = Canvas.2dContext
|
|
29
|
+
* @param {object} text - The text to display
|
|
30
|
+
*
|
|
31
|
+
* @return array of text lines
|
|
32
|
+
*/
|
|
33
|
+
export declare const getLines: (ctx: CanvasRenderingContext2D, text: string, fontFace: string, fontSize: string | number, maxWidth: number, hasIcon: boolean, fontInfoLevel: number, align: string) => TextSegment[];
|
|
34
|
+
/**
|
|
35
|
+
* Returns the styles by char for a group of property values
|
|
36
|
+
* @param {array} captions = array of captions
|
|
37
|
+
* @return array of list of styles by char
|
|
38
|
+
*/
|
|
39
|
+
export declare const getStylesByChar: (captions?: StyledCaption[]) => {
|
|
40
|
+
stylesPerChar: string[][];
|
|
41
|
+
fullCaption: string;
|
|
42
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Node, Relationship } from '../../index';
|
|
2
|
+
import type { DataSet } from '../../modules/dataset';
|
|
3
|
+
import type { NvlState } from '../../modules/state';
|
|
4
|
+
import type Renderer from './Renderer';
|
|
5
|
+
export interface ControllerInterface {
|
|
6
|
+
mainSceneRenderer: Renderer;
|
|
7
|
+
minimapRenderer: Renderer;
|
|
8
|
+
needsRun: boolean;
|
|
9
|
+
minimapMouseDown: boolean;
|
|
10
|
+
stateDisposers: NvlState['autorun'][];
|
|
11
|
+
state: NvlState;
|
|
12
|
+
needsToRun: () => boolean;
|
|
13
|
+
renderMainScene: (positionArray: Node[]) => void;
|
|
14
|
+
renderMinimap: (positionArray: Node[]) => void;
|
|
15
|
+
checkForUpdates: (nodes: DataSet<Node>, rels: DataSet<Relationship>) => void;
|
|
16
|
+
onResize: () => void;
|
|
17
|
+
updateMainViewport: (zoom: number, panX: number, panY: number) => void;
|
|
18
|
+
updateMinimapViewport: (zoom: number, panX: number, panY: number) => void;
|
|
19
|
+
handleMinimapDrag: (e: MouseEvent) => void;
|
|
20
|
+
handleMinimapWheel: (evt: MouseEvent) => void;
|
|
21
|
+
setupMinimapInteractions: () => void;
|
|
22
|
+
destroy: () => void;
|
|
23
|
+
}
|
|
24
|
+
export default class Controller implements ControllerInterface {
|
|
25
|
+
mainSceneRenderer: Renderer;
|
|
26
|
+
minimapRenderer: Renderer;
|
|
27
|
+
needsRun: boolean;
|
|
28
|
+
minimapMouseDown: boolean;
|
|
29
|
+
stateDisposers: NvlState['autorun'][];
|
|
30
|
+
state: NvlState;
|
|
31
|
+
constructor(options: {
|
|
32
|
+
mainSceneRenderer?: Renderer;
|
|
33
|
+
minimapRenderer?: Renderer;
|
|
34
|
+
state: NvlState;
|
|
35
|
+
});
|
|
36
|
+
needsToRun(): boolean;
|
|
37
|
+
renderMainScene(positionArray: any): void;
|
|
38
|
+
renderMinimap(positionArray: Node[]): void;
|
|
39
|
+
checkForUpdates(nodes: DataSet<Node>, rels: DataSet<Relationship>): void;
|
|
40
|
+
onResize(): void;
|
|
41
|
+
updateMainViewport(zoom: number, panX: number, panY: number): void;
|
|
42
|
+
updateMinimapViewport(zoom: number, panX: number, panY: number): void;
|
|
43
|
+
handleMinimapDrag(e: MouseEvent): void;
|
|
44
|
+
handleMinimapWheel(evt: WheelEvent): void;
|
|
45
|
+
setupMinimapInteractions(): void;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
}
|
|
48
|
+
export declare class DummyController implements ControllerInterface {
|
|
49
|
+
mainSceneRenderer: Renderer;
|
|
50
|
+
minimapRenderer: Renderer;
|
|
51
|
+
needsRun: boolean;
|
|
52
|
+
minimapMouseDown: boolean;
|
|
53
|
+
stateDisposers: NvlState['autorun'][];
|
|
54
|
+
state: NvlState;
|
|
55
|
+
renderMainScene(positionArray: Node[]): void;
|
|
56
|
+
renderMinimap(positionArray: Node[]): void;
|
|
57
|
+
checkForUpdates(nodes: DataSet<Node>, rels: DataSet<Relationship>): void;
|
|
58
|
+
onResize(): void;
|
|
59
|
+
updateMainViewport(zoom: number, panX: number, panY: number): void;
|
|
60
|
+
updateMinimapViewport(zoom: number, panX: number, panY: number): void;
|
|
61
|
+
handleMinimapDrag(e: MouseEvent): void;
|
|
62
|
+
handleMinimapWheel(e: MouseEvent): void;
|
|
63
|
+
setupMinimapInteractions(): void;
|
|
64
|
+
destroy(): void;
|
|
65
|
+
needsToRun(): boolean;
|
|
66
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// <reference types="gl-matrix/index.js" />
|
|
2
|
+
import { mat4 } from 'gl-matrix';
|
|
3
|
+
import type { DataSet } from '../../modules/dataset.js';
|
|
4
|
+
import type { NvlState } from '../../modules/state.js';
|
|
5
|
+
import type { Node, Relationship } from '../../types/graph-element.js';
|
|
6
|
+
export default class Renderer {
|
|
7
|
+
private readonly nodeShader;
|
|
8
|
+
private readonly nodeAnimShader;
|
|
9
|
+
private readonly relShader;
|
|
10
|
+
private relDataBuffer;
|
|
11
|
+
private readonly viewportBoxShader;
|
|
12
|
+
private readonly defaultRelColor;
|
|
13
|
+
private readonly defaultNodeColor;
|
|
14
|
+
private readonly disableRelColor;
|
|
15
|
+
private readonly disableNodeColor;
|
|
16
|
+
private readonly gl;
|
|
17
|
+
activeNodes: Record<string, boolean>;
|
|
18
|
+
readonly canvas: HTMLCanvasElement;
|
|
19
|
+
projection: mat4;
|
|
20
|
+
private idToIndex;
|
|
21
|
+
private posBuffer;
|
|
22
|
+
private numRels;
|
|
23
|
+
private numNodes;
|
|
24
|
+
private nodeDataByte;
|
|
25
|
+
private relIdToIndex;
|
|
26
|
+
private relData;
|
|
27
|
+
private containerWidth;
|
|
28
|
+
private containerHeight;
|
|
29
|
+
private nodeDataInt;
|
|
30
|
+
private viewportBoxBuffer;
|
|
31
|
+
private relBuffer;
|
|
32
|
+
private nodeBuffer;
|
|
33
|
+
private posTexture;
|
|
34
|
+
constructor(gl: WebGLRenderingContext, nodes: DataSet<Node>, rels: DataSet<Relationship>, state: NvlState);
|
|
35
|
+
private setShaderUniforms;
|
|
36
|
+
setData(data: {
|
|
37
|
+
nodes: Node[];
|
|
38
|
+
rels: Relationship[];
|
|
39
|
+
}): void;
|
|
40
|
+
render(positionArray: Node[], nodes: any, rels: any): void;
|
|
41
|
+
renderViewbox(): void;
|
|
42
|
+
updateNodes(updates: Node[]): void;
|
|
43
|
+
updateRelationships(relItems: Relationship[]): void;
|
|
44
|
+
private createPositionTexture;
|
|
45
|
+
updateViewportBox(zoom: number, panX: number, panY: number, viewportWidth: number, viewportHeight: number): void;
|
|
46
|
+
updateViewport(zoom: number, panX: number, panY: number): void;
|
|
47
|
+
private setupViewportRendering;
|
|
48
|
+
private setupNodeRendering;
|
|
49
|
+
private setupRelationshipRendering;
|
|
50
|
+
private renderAnimations;
|
|
51
|
+
destroy(): void;
|
|
52
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "uniform mediump float u_zoom;\nuniform lowp float u_animPos;\nuniform mediump float u_glAdjust;\n\nvarying lowp vec4 color;\nvarying lowp float varNodeSize;\nmediump float circleSize = 0.50;\n\nvoid main(void) {\n\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float alpha = 1.0 - smoothstep(circleSize - (1.0 / (varNodeSize * 2.0 * u_zoom * u_glAdjust)), circleSize, dist);\n lowp float pulseAlpha = 0.9 - 0.9 * u_animPos;\n gl_FragColor = vec4(color.xyz, 1.0) * alpha * pulseAlpha;\n }\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "uniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform lowp float u_animPos;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nattribute float a_size;\nattribute lowp vec2 a_index;\nattribute lowp vec4 a_color;\nattribute lowp float a_active;\n\nvarying lowp float varNodeSize;\nvarying lowp vec4 color;\n\nvoid main(void) {\n vec4 data = texture2D(u_positions, a_index);\n\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n float nodeSize = a_size * u_zoom * u_glAdjust;\n nodeSize = nodeSize * (0.4 / 0.5); // Remove extra space added for shadow and selection ring\n\n gl_PointSize = a_active > 0.5\n ? nodeSize + 0.88 * nodeSize * u_animPos\n : 0.0;\n\n color = a_color;\n varNodeSize = a_size;\n}";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "uniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nvarying lowp vec4 color;\nvarying lowp float drawDefaultBorder;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\n\nmediump float circleSize = 0.40;\nmediump float ringSize = 0.43;\nmediump float ringSize2 = 0.47;\nmediump float shadowSize = 0.51;\nlowp vec3 shadowColor = vec3(0.73);\nlowp vec3 lineColor = vec3(1.0);\n\nlowp float getShadowAlpha(lowp float size, lowp float dist) {\n return (1.0 - smoothstep(size, shadowSize, dist)) * 0.25;\n}\n\nlowp float getCircleAlpha(lowp float ringSize, lowp float nodeSize, lowp float dist) {\n return color.w - smoothstep(ringSize - nodeSize, ringSize, dist);\n}\n\nvoid main() {\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float nodeSize = 1.0 / varNodeSize;\n lowp float nodeAlpha = getCircleAlpha(circleSize, nodeSize, dist);\n lowp float ringAlpha = getCircleAlpha(ringSize, nodeSize, dist);\n lowp vec3 finalColor = color.xyz;\n lowp float finalAlpha = nodeAlpha;\n\n if (selected > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(ringSize2, dist);\n lowp float ringAlpha2 = getCircleAlpha(ringSize2, nodeSize, dist);\n\n finalColor = mix(lineColor, finalColor, nodeAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(ringAlpha, ringAlpha2)));\n } else if (hovered > 0.0) {\n if (drawDefaultBorder > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(ringSize, dist);\n \n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, ringAlpha));\n } else {\n lowp float shadowAlpha = getShadowAlpha(circleSize, dist);\n\n finalColor = mix(shadowColor, finalColor, nodeAlpha);\n finalAlpha = max(shadowAlpha, nodeAlpha);\n }\n } else {\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalAlpha = ringAlpha;\n }\n }\n gl_FragColor = vec4(finalColor, 1.0) * finalAlpha;\n }\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "uniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\nuniform lowp vec3 u_nodeBorderColor;\nuniform lowp vec3 u_selectedBorderColor;\nuniform lowp float u_drawDefaultBorder;\n\nattribute float a_size;\nattribute lowp vec2 a_index;\nattribute lowp vec4 a_color;\nattribute lowp float a_selected;\nattribute lowp float a_hovered;\n\nvarying lowp float window;\nvarying lowp vec4 color;\nvarying lowp float selected;\nvarying lowp float hovered;\nvarying lowp float varNodeSize;\nvarying lowp vec3 nodeBorderColor;\nvarying lowp vec3 selectedBorderColor;\nvarying lowp float drawDefaultBorder;\n\nlowp float MinNodeSize = 5.0;\n\nvoid main(void) {\n vec4 data = texture2D(u_positions, a_index);\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n lowp float nodeSize = a_size * u_zoom * u_glAdjust;\n if (nodeSize < MinNodeSize) {\n gl_PointSize = MinNodeSize;\n varNodeSize = MinNodeSize;\n } else {\n gl_PointSize = nodeSize;\n varNodeSize = nodeSize;\n }\n\n color = a_color;\n selected = a_selected;\n hovered = a_hovered;\n nodeBorderColor = u_nodeBorderColor;\n selectedBorderColor = u_selectedBorderColor;\n drawDefaultBorder = u_drawDefaultBorder;\n}";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "uniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_glAdjust;\n\nattribute vec2 a_from;\nattribute vec2 a_to;\nattribute lowp vec4 a_color;\nattribute lowp float a_triside;\nattribute float a_width;\n\nvarying lowp vec4 color;\n\nvoid main(void) {\n vec4 from = texture2D(u_positions, a_from);\n vec4 to = texture2D(u_positions, a_to);\n vec2 direction = normalize(to.xy - from.xy);\n direction = vec2(-direction.y, direction.x);\n\n float width = a_width * u_glAdjust * 0.5;\n\n if (a_triside == 0.0) {\n from.y += (width / 2.0) * direction.y;\n from.x += (width / 2.0) * direction.x;\n } else {\n from.y -= (width / 2.0) * direction.y;\n from.x -= (width / 2.0) * direction.x;\n }\n\n color = a_color;\n gl_Position = u_projection * vec4(from.xy, 0.0, 1.0);\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { StyledCaption } from '../renderers/canvasrenderer/types';
|
|
2
|
+
/**
|
|
3
|
+
* The base type for graph elements.
|
|
4
|
+
* @private
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
interface GraphElement {
|
|
8
|
+
/**
|
|
9
|
+
* The id of the current node or relationship.
|
|
10
|
+
* @note ids need to be unique across all nodes and relationships.
|
|
11
|
+
* @note ids need to be strings and cannot be empty.
|
|
12
|
+
*/
|
|
13
|
+
readonly id: string;
|
|
14
|
+
color?: string;
|
|
15
|
+
/** Whether or not the current node or relationship is selected.*/
|
|
16
|
+
selected?: boolean;
|
|
17
|
+
/** The text to display inside on node or relationship.
|
|
18
|
+
* @deprecated Use {@link captions} instead.
|
|
19
|
+
*/
|
|
20
|
+
caption?: string;
|
|
21
|
+
/** Whether or not the current node or relationship is disabled.*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Whether or not the current node or relationship is hovered.*/
|
|
24
|
+
hovered?: boolean;
|
|
25
|
+
/** The caption text size.*/
|
|
26
|
+
captionSize?: number;
|
|
27
|
+
/** The caption align.*/
|
|
28
|
+
captionAlign?: 'top' | 'bottom' | 'center';
|
|
29
|
+
/** The caption text and font style.*/
|
|
30
|
+
captions?: StyledCaption[];
|
|
31
|
+
}
|
|
32
|
+
export declare const isValidNode: (node: unknown) => node is Node;
|
|
33
|
+
/**
|
|
34
|
+
* A node inside the graph visualization.
|
|
35
|
+
*/
|
|
36
|
+
interface Node extends GraphElement {
|
|
37
|
+
/** The size of the node.*/
|
|
38
|
+
size?: number;
|
|
39
|
+
/** Whether or not the current node is pinned.*/
|
|
40
|
+
pinned?: boolean;
|
|
41
|
+
/** The x-coordinate for the position of the node.*/
|
|
42
|
+
x?: number;
|
|
43
|
+
/** The y-coordinate for the position of the node.*/
|
|
44
|
+
y?: number;
|
|
45
|
+
/** Whether or not the current node is activated.*/
|
|
46
|
+
activated?: boolean;
|
|
47
|
+
/** The icon to display inside the node.*/
|
|
48
|
+
icon?: string;
|
|
49
|
+
/**
|
|
50
|
+
* The DOM element to display on top of a node.
|
|
51
|
+
* @experimental
|
|
52
|
+
*/
|
|
53
|
+
html?: HTMLElement;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
type PartialNode = Partial<Node> & {
|
|
59
|
+
id: string;
|
|
60
|
+
};
|
|
61
|
+
export declare const isValidRelationship: (relationship: unknown) => relationship is Relationship;
|
|
62
|
+
/**
|
|
63
|
+
* A relationship inside the graph visualization.
|
|
64
|
+
*/
|
|
65
|
+
interface Relationship extends GraphElement {
|
|
66
|
+
/** Node id where the relationship starts from.*/
|
|
67
|
+
from: string;
|
|
68
|
+
/** Node id where the relationship points to.*/
|
|
69
|
+
to: string;
|
|
70
|
+
/** The relationship type.*/
|
|
71
|
+
type?: string;
|
|
72
|
+
/** The width of the relationship.*/
|
|
73
|
+
width?: number;
|
|
74
|
+
/**
|
|
75
|
+
* The DOM element to display on top of a relationship caption.
|
|
76
|
+
* @experimental
|
|
77
|
+
* @note The {@link captionSize} and {@link captionAlign} properties
|
|
78
|
+
* will affect the position and height of the html container element.
|
|
79
|
+
*/
|
|
80
|
+
captionHtml?: HTMLElement;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
type PartialRelationship = Partial<Relationship> & {
|
|
86
|
+
id: string;
|
|
87
|
+
};
|
|
88
|
+
export type { Node, Relationship, PartialNode, PartialRelationship };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixes the canvas size to match the parent element's size.
|
|
3
|
+
* @param canvas The canvas to fix the size of.
|
|
4
|
+
*
|
|
5
|
+
* @note Make sure canvas pixel buffer is 1 to 1 vs screen pixels
|
|
6
|
+
*/
|
|
7
|
+
export declare const fitCanvasSizeToParent: (canvas: HTMLCanvasElement) => void;
|
|
8
|
+
export declare const addWebGLContextLostListener: (canvas: HTMLCanvasElement, contextLostCallback?: (e: WebGLContextEvent) => void) => void;
|
|
9
|
+
export declare const createCanvasForScreenshot: (fullWidth: number, fullHeight: number) => HTMLCanvasElement;
|
|
10
|
+
export declare const createCanvasForRenderer: (parent?: HTMLElement, onContextLostCallback?: (e: WebGLContextEvent) => void) => HTMLCanvasElement;
|
|
11
|
+
export declare const removeCanvas: (canvas: HTMLCanvasElement) => void;
|
|
12
|
+
export declare const getCanvas2DContext: (canvas: HTMLCanvasElement) => CanvasRenderingContext2D;
|
|
13
|
+
export declare const getWebGLContext: (canvas: HTMLCanvasElement) => RenderingContext;
|
|
14
|
+
export declare const removeWebGLContext: (webGLCtx: WebGLRenderingContext) => void;
|
|
15
|
+
export declare const checkWebGLAvailability: (canvas?: HTMLCanvasElement) => boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether a black or white font color is more readable for a given background color
|
|
3
|
+
* @param {string} color The background color
|
|
4
|
+
* @returns {string} The font color that should be used @defaultValue '#fff'
|
|
5
|
+
*/
|
|
6
|
+
export declare const textColorForBackground: (color: string) => string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const PhysTextureSize = 256;
|
|
2
|
+
export declare const SpringTextureSize = 4096;
|
|
3
|
+
export declare const MaxIndexBuffer = 65536;
|
|
4
|
+
export declare const MinRelLength = 100;
|
|
5
|
+
export declare const Gravity = 100;
|
|
6
|
+
export declare const SimulationStopVelocity = 100;
|
|
7
|
+
export declare const MappingEnd = 999999;
|
|
8
|
+
export declare const ActiveAnimDuration = 1000;
|
|
9
|
+
export declare const DefaultNodeSize = 25;
|
|
10
|
+
export declare const DefaultNodeColor = "#478BFF";
|
|
11
|
+
export declare const DefaultRelWidth = 1;
|
|
12
|
+
export declare const DisabledRelColor = "#ededed";
|
|
13
|
+
export declare const absFillStyle: {
|
|
14
|
+
position: string;
|
|
15
|
+
top: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
left: number;
|
|
18
|
+
right: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Factor to make nodes same size in WebGL renderer and Canvas.
|
|
22
|
+
* @returns {number} The adjustment factor.
|
|
23
|
+
*/
|
|
24
|
+
export declare const GlAdjust: number;
|
|
25
|
+
/**
|
|
26
|
+
* Get the pixel ratio of the device
|
|
27
|
+
* @returns {number} The pixel ratio of the device
|
|
28
|
+
*/
|
|
29
|
+
export declare const getDevicePixelRatio: () => number;
|
|
30
|
+
export declare const HtmlCaptionMinWidthThreshold = 5;
|