@cosmos.gl/graph 2.2.0 → 2.3.0-beta.0
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/README.md +7 -7
- package/dist/config.d.ts +16 -0
- package/dist/index.d.ts +68 -7
- package/dist/index.js +1989 -1880
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +64 -55
- package/dist/index.min.js.map +1 -1
- package/dist/modules/Points/index.d.ts +11 -6
- package/dist/stories/clusters/{lasso-selection → polygon-selection}/index.d.ts +1 -1
- package/dist/stories/clusters/{lasso-selection/lasso.d.ts → polygon-selection/polygon.d.ts} +5 -5
- package/dist/stories/clusters.stories.d.ts +1 -1
- package/dist/variables.d.ts +2 -0
- package/package.json +1 -1
- package/src/config.ts +21 -0
- package/src/index.ts +115 -22
- package/src/modules/Lines/draw-curve-line.frag +2 -1
- package/src/modules/Lines/draw-curve-line.vert +9 -3
- package/src/modules/Lines/index.ts +1 -0
- package/src/modules/Points/draw-highlighted.vert +2 -1
- package/src/modules/Points/draw-points.vert +2 -1
- package/src/modules/Points/{find-points-on-lasso-selection.frag → find-points-on-polygon-selection.frag} +8 -8
- package/src/modules/Points/index.ts +68 -25
- package/src/stories/2. configuration.mdx +2 -0
- package/src/stories/3. api-reference.mdx +82 -27
- package/src/stories/beginners/basic-set-up/index.ts +1 -1
- package/src/stories/clusters/{lasso-selection → polygon-selection}/index.ts +11 -11
- package/src/stories/clusters/{lasso-selection/lasso.ts → polygon-selection/polygon.ts} +16 -16
- package/src/stories/clusters/{lasso-selection → polygon-selection}/style.css +1 -1
- package/src/stories/clusters/worm.ts +22 -1
- package/src/stories/clusters.stories.ts +9 -9
- package/src/variables.ts +2 -0
|
@@ -21,7 +21,7 @@ export declare class Points extends CoreModule {
|
|
|
21
21
|
private updatePositionCommand;
|
|
22
22
|
private dragPointCommand;
|
|
23
23
|
private findPointsOnAreaSelectionCommand;
|
|
24
|
-
private
|
|
24
|
+
private findPointsOnPolygonSelectionCommand;
|
|
25
25
|
private findHoveredPointCommand;
|
|
26
26
|
private clearHoveredFboCommand;
|
|
27
27
|
private clearSampledPointsFboCommand;
|
|
@@ -32,9 +32,9 @@ export declare class Points extends CoreModule {
|
|
|
32
32
|
private greyoutStatusTexture;
|
|
33
33
|
private sizeTexture;
|
|
34
34
|
private trackedIndicesTexture;
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
private
|
|
35
|
+
private polygonPathTexture;
|
|
36
|
+
private polygonPathFbo;
|
|
37
|
+
private polygonPathLength;
|
|
38
38
|
private drawPointIndices;
|
|
39
39
|
private hoveredPointIndices;
|
|
40
40
|
private sampledPointIndices;
|
|
@@ -49,12 +49,17 @@ export declare class Points extends CoreModule {
|
|
|
49
49
|
updatePosition(): void;
|
|
50
50
|
drag(): void;
|
|
51
51
|
findPointsOnAreaSelection(): void;
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
findPointsOnPolygonSelection(): void;
|
|
53
|
+
updatePolygonPath(polygonPath: [number, number][]): void;
|
|
54
54
|
findHoveredPoint(): void;
|
|
55
55
|
trackPointsByIndices(indices?: number[] | undefined): void;
|
|
56
56
|
getTrackedPositionsMap(): Map<number, [number, number]>;
|
|
57
57
|
getSampledPointPositionsMap(): Map<number, [number, number]>;
|
|
58
|
+
getSampledPoints(): {
|
|
59
|
+
indices: number[];
|
|
60
|
+
positions: number[];
|
|
61
|
+
};
|
|
62
|
+
getTrackedPositionsArray(): number[];
|
|
58
63
|
private swapFbo;
|
|
59
64
|
private rescaleInitialNodePositions;
|
|
60
65
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class PolygonSelection {
|
|
2
2
|
private canvas;
|
|
3
3
|
private ctx;
|
|
4
4
|
private isDrawing;
|
|
5
5
|
private points;
|
|
6
6
|
private graphDiv;
|
|
7
|
-
private
|
|
7
|
+
private onPolygonComplete?;
|
|
8
8
|
private boundStartDrawing;
|
|
9
9
|
private boundDraw;
|
|
10
10
|
private boundStopDrawing;
|
|
11
11
|
private resizeObserver;
|
|
12
|
-
constructor(graphDiv: HTMLElement,
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
constructor(graphDiv: HTMLElement, onPolygonComplete?: (points: [number, number][]) => void);
|
|
13
|
+
enablePolygonMode(): void;
|
|
14
|
+
disablePolygonMode(): void;
|
|
15
15
|
destroy(): void;
|
|
16
16
|
private resizeCanvas;
|
|
17
17
|
private startDrawing;
|
|
@@ -5,5 +5,5 @@ declare const meta: Meta<CosmosStoryProps>;
|
|
|
5
5
|
export declare const Worm: Story;
|
|
6
6
|
export declare const Radial: Story;
|
|
7
7
|
export declare const WithLabels: Story;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const PolygonSelection: Story;
|
|
9
9
|
export default meta;
|
package/dist/variables.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export declare const defaultPointColor = "#b3b3b3";
|
|
2
2
|
export declare const defaultGreyoutPointOpacity: undefined;
|
|
3
3
|
export declare const defaultGreyoutPointColor: undefined;
|
|
4
|
+
export declare const defaultPointOpacity = 1;
|
|
4
5
|
export declare const defaultPointSize = 4;
|
|
5
6
|
export declare const defaultLinkColor = "#666666";
|
|
6
7
|
export declare const defaultGreyoutLinkOpacity = 0.1;
|
|
8
|
+
export declare const defaultLinkOpacity = 1;
|
|
7
9
|
export declare const defaultLinkWidth = 1;
|
|
8
10
|
export declare const defaultBackgroundColor = "#222222";
|
|
9
11
|
export declare const defaultConfigValues: {
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -4,9 +4,11 @@ import {
|
|
|
4
4
|
defaultPointColor,
|
|
5
5
|
defaultGreyoutPointOpacity,
|
|
6
6
|
defaultGreyoutPointColor,
|
|
7
|
+
defaultPointOpacity,
|
|
7
8
|
defaultPointSize,
|
|
8
9
|
defaultLinkColor,
|
|
9
10
|
defaultGreyoutLinkOpacity,
|
|
11
|
+
defaultLinkOpacity,
|
|
10
12
|
defaultLinkWidth,
|
|
11
13
|
defaultBackgroundColor,
|
|
12
14
|
defaultConfigValues,
|
|
@@ -74,6 +76,15 @@ export interface GraphConfigInterface {
|
|
|
74
76
|
* Default value: `4`
|
|
75
77
|
*/
|
|
76
78
|
pointSize?: number;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Universal opacity value applied to all points.
|
|
82
|
+
* This value multiplies with individual point alpha values (if set via setPointColors).
|
|
83
|
+
* Useful for dynamically controlling opacity of all points without updating individual RGBA arrays.
|
|
84
|
+
* Default value: `1.0`
|
|
85
|
+
*/
|
|
86
|
+
pointOpacity?: number;
|
|
87
|
+
|
|
77
88
|
/**
|
|
78
89
|
* Scale factor for the point size.
|
|
79
90
|
* Default value: `1`
|
|
@@ -128,6 +139,14 @@ export interface GraphConfigInterface {
|
|
|
128
139
|
*/
|
|
129
140
|
linkColor?: string | [number, number, number, number];
|
|
130
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Universal opacity value applied to all links.
|
|
144
|
+
* This value multiplies with individual link alpha values (if set via setLinkColors).
|
|
145
|
+
* Useful for dynamically controlling opacity of all links without updating individual RGBA arrays.
|
|
146
|
+
* Default value: `1.0`
|
|
147
|
+
*/
|
|
148
|
+
linkOpacity?: number;
|
|
149
|
+
|
|
131
150
|
/**
|
|
132
151
|
* Greyed out link opacity value when the selection is active.
|
|
133
152
|
* Default value: `0.1`
|
|
@@ -517,6 +536,7 @@ export class GraphConfig implements GraphConfigInterface {
|
|
|
517
536
|
public pointGreyoutOpacity = defaultGreyoutPointOpacity
|
|
518
537
|
public pointGreyoutColor = defaultGreyoutPointColor
|
|
519
538
|
public pointSize = defaultPointSize
|
|
539
|
+
public pointOpacity = defaultPointOpacity
|
|
520
540
|
public pointSizeScale = defaultConfigValues.pointSizeScale
|
|
521
541
|
public hoveredPointCursor = defaultConfigValues.hoveredPointCursor
|
|
522
542
|
public renderHoveredPointRing = defaultConfigValues.renderHoveredPointRing
|
|
@@ -524,6 +544,7 @@ export class GraphConfig implements GraphConfigInterface {
|
|
|
524
544
|
public focusedPointRingColor = defaultConfigValues.focusedPointRingColor
|
|
525
545
|
public focusedPointIndex = defaultConfigValues.focusedPointIndex
|
|
526
546
|
public linkColor = defaultLinkColor
|
|
547
|
+
public linkOpacity = defaultLinkOpacity
|
|
527
548
|
public linkGreyoutOpacity = defaultGreyoutLinkOpacity
|
|
528
549
|
public linkWidth = defaultLinkWidth
|
|
529
550
|
public linkWidthScale = defaultConfigValues.linkWidthScale
|
package/src/index.ts
CHANGED
|
@@ -322,6 +322,17 @@ export class Graph {
|
|
|
322
322
|
this._needsPointColorUpdate = true
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
/**
|
|
326
|
+
* Gets the current colors of the graph points.
|
|
327
|
+
*
|
|
328
|
+
* @returns {Float32Array} A Float32Array representing the colors of points in the format [r1, g1, b1, a1, r2, g2, b2, a2, ..., rn, gn, bn, an],
|
|
329
|
+
* where each color is in RGBA format. Returns an empty Float32Array if no point colors are set.
|
|
330
|
+
*/
|
|
331
|
+
public getPointColors (): Float32Array {
|
|
332
|
+
if (this._isDestroyed) return new Float32Array()
|
|
333
|
+
return this.graph.pointColors ?? new Float32Array()
|
|
334
|
+
}
|
|
335
|
+
|
|
325
336
|
/**
|
|
326
337
|
* Sets the sizes for the graph points.
|
|
327
338
|
*
|
|
@@ -335,6 +346,17 @@ export class Graph {
|
|
|
335
346
|
this._needsPointSizeUpdate = true
|
|
336
347
|
}
|
|
337
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Gets the current sizes of the graph points.
|
|
351
|
+
*
|
|
352
|
+
* @returns {Float32Array} A Float32Array representing the sizes of points in the format [size1, size2, ..., sizen],
|
|
353
|
+
* where `n` is the index of the point. Returns an empty Float32Array if no point sizes are set.
|
|
354
|
+
*/
|
|
355
|
+
public getPointSizes (): Float32Array {
|
|
356
|
+
if (this._isDestroyed) return new Float32Array()
|
|
357
|
+
return this.graph.pointSizes ?? new Float32Array()
|
|
358
|
+
}
|
|
359
|
+
|
|
338
360
|
/**
|
|
339
361
|
* Sets the links for the graph.
|
|
340
362
|
*
|
|
@@ -367,6 +389,17 @@ export class Graph {
|
|
|
367
389
|
this._needsLinkColorUpdate = true
|
|
368
390
|
}
|
|
369
391
|
|
|
392
|
+
/**
|
|
393
|
+
* Gets the current colors of the graph links.
|
|
394
|
+
*
|
|
395
|
+
* @returns {Float32Array} A Float32Array representing the colors of links in the format [r1, g1, b1, a1, r2, g2, b2, a2, ..., rn, gn, bn, an],
|
|
396
|
+
* where each color is in RGBA format. Returns an empty Float32Array if no link colors are set.
|
|
397
|
+
*/
|
|
398
|
+
public getLinkColors (): Float32Array {
|
|
399
|
+
if (this._isDestroyed) return new Float32Array()
|
|
400
|
+
return this.graph.linkColors ?? new Float32Array()
|
|
401
|
+
}
|
|
402
|
+
|
|
370
403
|
/**
|
|
371
404
|
* Sets the widths for the graph links.
|
|
372
405
|
*
|
|
@@ -380,6 +413,17 @@ export class Graph {
|
|
|
380
413
|
this._needsLinkWidthUpdate = true
|
|
381
414
|
}
|
|
382
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Gets the current widths of the graph links.
|
|
418
|
+
*
|
|
419
|
+
* @returns {Float32Array} A Float32Array representing the widths of links in the format [width1, width2, ..., widthn],
|
|
420
|
+
* where `n` is the index of the link. Returns an empty Float32Array if no link widths are set.
|
|
421
|
+
*/
|
|
422
|
+
public getLinkWidths (): Float32Array {
|
|
423
|
+
if (this._isDestroyed) return new Float32Array()
|
|
424
|
+
return this.graph.linkWidths ?? new Float32Array()
|
|
425
|
+
}
|
|
426
|
+
|
|
383
427
|
/**
|
|
384
428
|
* Sets the arrows for the graph links.
|
|
385
429
|
*
|
|
@@ -648,7 +692,7 @@ export class Graph {
|
|
|
648
692
|
* The `top` and `bottom` coordinates should be from 0 to the height of the canvas.
|
|
649
693
|
* @returns A Float32Array containing the indices of points inside a rectangular area.
|
|
650
694
|
*/
|
|
651
|
-
public
|
|
695
|
+
public getPointsInRect (selection: [[number, number], [number, number]]): Float32Array {
|
|
652
696
|
if (this._isDestroyed || !this.reglInstance || !this.points) return new Float32Array()
|
|
653
697
|
const h = this.store.screenSize[1]
|
|
654
698
|
this.store.selectedArea = [[selection[0][0], (h - selection[1][1])], [selection[1][0], (h - selection[0][1])]]
|
|
@@ -664,20 +708,32 @@ export class Graph {
|
|
|
664
708
|
}
|
|
665
709
|
|
|
666
710
|
/**
|
|
667
|
-
* Get points indices inside a
|
|
668
|
-
* @param
|
|
711
|
+
* Get points indices inside a rectangular area.
|
|
712
|
+
* @param selection - Array of two corner points `[[left, top], [right, bottom]]`.
|
|
713
|
+
* The `left` and `right` coordinates should be from 0 to the width of the canvas.
|
|
714
|
+
* The `top` and `bottom` coordinates should be from 0 to the height of the canvas.
|
|
715
|
+
* @returns A Float32Array containing the indices of points inside a rectangular area.
|
|
716
|
+
* @deprecated Use `getPointsInRect` instead. This method will be removed in a future version.
|
|
717
|
+
*/
|
|
718
|
+
public getPointsInRange (selection: [[number, number], [number, number]]): Float32Array {
|
|
719
|
+
return this.getPointsInRect(selection)
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Get points indices inside a polygon area.
|
|
724
|
+
* @param polygonPath - Array of points `[[x1, y1], [x2, y2], ..., [xn, yn]]` that defines the polygon.
|
|
669
725
|
* The coordinates should be from 0 to the width/height of the canvas.
|
|
670
|
-
* @returns A Float32Array containing the indices of points inside the
|
|
726
|
+
* @returns A Float32Array containing the indices of points inside the polygon area.
|
|
671
727
|
*/
|
|
672
|
-
public
|
|
728
|
+
public getPointsInPolygon (polygonPath: [number, number][]): Float32Array {
|
|
673
729
|
if (this._isDestroyed || !this.reglInstance || !this.points) return new Float32Array()
|
|
674
|
-
if (
|
|
730
|
+
if (polygonPath.length < 3) return new Float32Array() // Need at least 3 points for a polygon
|
|
675
731
|
|
|
676
732
|
const h = this.store.screenSize[1]
|
|
677
733
|
// Convert coordinates to WebGL coordinate system (flip Y)
|
|
678
|
-
const convertedPath =
|
|
679
|
-
this.points.
|
|
680
|
-
this.points.
|
|
734
|
+
const convertedPath = polygonPath.map(([x, y]) => [x, h - y] as [number, number])
|
|
735
|
+
this.points.updatePolygonPath(convertedPath)
|
|
736
|
+
this.points.findPointsOnPolygonSelection()
|
|
681
737
|
const pixels = readPixels(this.reglInstance, this.points.selectedFbo as regl.Framebuffer2D)
|
|
682
738
|
|
|
683
739
|
return pixels
|
|
@@ -692,7 +748,7 @@ export class Graph {
|
|
|
692
748
|
* @param selection - Array of two corner points `[[left, top], [right, bottom]]`.
|
|
693
749
|
* The `left` and `right` coordinates should be from 0 to the width of the canvas.
|
|
694
750
|
* The `top` and `bottom` coordinates should be from 0 to the height of the canvas. */
|
|
695
|
-
public
|
|
751
|
+
public selectPointsInRect (selection: [[number, number], [number, number]] | null): void {
|
|
696
752
|
if (this._isDestroyed || !this.reglInstance || !this.points) return
|
|
697
753
|
if (selection) {
|
|
698
754
|
const h = this.store.screenSize[1]
|
|
@@ -711,23 +767,33 @@ export class Graph {
|
|
|
711
767
|
this.points.updateGreyoutStatus()
|
|
712
768
|
}
|
|
713
769
|
|
|
714
|
-
/** Select points inside a
|
|
715
|
-
* @param
|
|
770
|
+
/** Select points inside a rectangular area.
|
|
771
|
+
* @param selection - Array of two corner points `[[left, top], [right, bottom]]`.
|
|
772
|
+
* The `left` and `right` coordinates should be from 0 to the width of the canvas.
|
|
773
|
+
* The `top` and `bottom` coordinates should be from 0 to the height of the canvas.
|
|
774
|
+
* @deprecated Use `selectPointsInRect` instead. This method will be removed in a future version.
|
|
775
|
+
*/
|
|
776
|
+
public selectPointsInRange (selection: [[number, number], [number, number]] | null): void {
|
|
777
|
+
return this.selectPointsInRect(selection)
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/** Select points inside a polygon area.
|
|
781
|
+
* @param polygonPath - Array of points `[[x1, y1], [x2, y2], ..., [xn, yn]]` that defines the polygon.
|
|
716
782
|
* The coordinates should be from 0 to the width/height of the canvas.
|
|
717
783
|
* Set to null to clear selection. */
|
|
718
|
-
public
|
|
784
|
+
public selectPointsInPolygon (polygonPath: [number, number][] | null): void {
|
|
719
785
|
if (this._isDestroyed || !this.reglInstance || !this.points) return
|
|
720
|
-
if (
|
|
721
|
-
if (
|
|
722
|
-
console.warn('
|
|
786
|
+
if (polygonPath) {
|
|
787
|
+
if (polygonPath.length < 3) {
|
|
788
|
+
console.warn('Polygon path requires at least 3 points to form a polygon.')
|
|
723
789
|
return
|
|
724
790
|
}
|
|
725
791
|
|
|
726
792
|
const h = this.store.screenSize[1]
|
|
727
793
|
// Convert coordinates to WebGL coordinate system (flip Y)
|
|
728
|
-
const convertedPath =
|
|
729
|
-
this.points.
|
|
730
|
-
this.points.
|
|
794
|
+
const convertedPath = polygonPath.map(([x, y]) => [x, h - y] as [number, number])
|
|
795
|
+
this.points.updatePolygonPath(convertedPath)
|
|
796
|
+
this.points.findPointsOnPolygonSelection()
|
|
731
797
|
const pixels = readPixels(this.reglInstance, this.points.selectedFbo as regl.Framebuffer2D)
|
|
732
798
|
this.store.selectedIndices = pixels
|
|
733
799
|
.map((pixel, i) => {
|
|
@@ -860,6 +926,17 @@ export class Graph {
|
|
|
860
926
|
return this.points.getTrackedPositionsMap()
|
|
861
927
|
}
|
|
862
928
|
|
|
929
|
+
/**
|
|
930
|
+
* Get current X and Y coordinates of the tracked points as an array.
|
|
931
|
+
* @returns Array of point positions in the format [x1, y1, x2, y2, ..., xn, yn] for tracked points only.
|
|
932
|
+
* The positions are ordered by the tracking indices (same order as provided to trackPointPositionsByIndices).
|
|
933
|
+
* Returns an empty array if no points are being tracked.
|
|
934
|
+
*/
|
|
935
|
+
public getTrackedPointPositionsArray (): number[] {
|
|
936
|
+
if (this._isDestroyed || !this.points) return []
|
|
937
|
+
return this.points.getTrackedPositionsArray()
|
|
938
|
+
}
|
|
939
|
+
|
|
863
940
|
/**
|
|
864
941
|
* For the points that are currently visible on the screen, get a sample of point indices with their coordinates.
|
|
865
942
|
* The resulting number of points will depend on the `pointSamplingDistance` configuration property,
|
|
@@ -871,6 +948,17 @@ export class Graph {
|
|
|
871
948
|
return this.points.getSampledPointPositionsMap()
|
|
872
949
|
}
|
|
873
950
|
|
|
951
|
+
/**
|
|
952
|
+
* For the points that are currently visible on the screen, get a sample of point indices and positions.
|
|
953
|
+
* The resulting number of points will depend on the `pointSamplingDistance` configuration property,
|
|
954
|
+
* and the sampled points will be evenly distributed.
|
|
955
|
+
* @returns An object containing arrays of point indices and positions.
|
|
956
|
+
*/
|
|
957
|
+
public getSampledPoints (): { indices: number[]; positions: number[] } {
|
|
958
|
+
if (this._isDestroyed || !this.points) return { indices: [], positions: [] }
|
|
959
|
+
return this.points.getSampledPoints()
|
|
960
|
+
}
|
|
961
|
+
|
|
874
962
|
/**
|
|
875
963
|
* Gets the X-axis of rescaling function.
|
|
876
964
|
*
|
|
@@ -898,10 +986,15 @@ export class Graph {
|
|
|
898
986
|
public start (alpha = 1): void {
|
|
899
987
|
if (this._isDestroyed) return
|
|
900
988
|
if (!this.graph.pointsNumber) return
|
|
901
|
-
|
|
989
|
+
|
|
990
|
+
// Only start the simulation if alpha > 0
|
|
991
|
+
if (alpha > 0) {
|
|
992
|
+
this.store.isSimulationRunning = true
|
|
993
|
+
this.store.simulationProgress = 0
|
|
994
|
+
this.config.onSimulationStart?.()
|
|
995
|
+
}
|
|
996
|
+
|
|
902
997
|
this.store.alpha = alpha
|
|
903
|
-
this.store.simulationProgress = 0
|
|
904
|
-
this.config.onSimulationStart?.()
|
|
905
998
|
this.stopFrames()
|
|
906
999
|
this.frame()
|
|
907
1000
|
}
|
|
@@ -5,6 +5,7 @@ varying vec2 pos;
|
|
|
5
5
|
varying float arrowLength;
|
|
6
6
|
varying float useArrow;
|
|
7
7
|
varying float smoothing;
|
|
8
|
+
varying float arrowWidthFactor;
|
|
8
9
|
|
|
9
10
|
float map(float value, float min1, float max1, float min2, float max2) {
|
|
10
11
|
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
|
|
@@ -17,7 +18,7 @@ void main() {
|
|
|
17
18
|
if (useArrow > 0.5) {
|
|
18
19
|
float end_arrow = 0.5 + arrowLength / 2.0;
|
|
19
20
|
float start_arrow = end_arrow - arrowLength;
|
|
20
|
-
float arrowWidthDelta = 0
|
|
21
|
+
float arrowWidthDelta = arrowWidthFactor / 2.0;
|
|
21
22
|
float linkOpacity = rgbaColor.a * smoothstep(0.5 - arrowWidthDelta, 0.5 - arrowWidthDelta - smoothing / 2.0, abs(pos.y));
|
|
22
23
|
float arrowOpacity = 1.0;
|
|
23
24
|
if (pos.x > start_arrow && pos.x < start_arrow + arrowLength) {
|
|
@@ -15,6 +15,7 @@ uniform float spaceSize;
|
|
|
15
15
|
uniform vec2 screenSize;
|
|
16
16
|
uniform vec2 linkVisibilityDistanceRange;
|
|
17
17
|
uniform float linkVisibilityMinTransparency;
|
|
18
|
+
uniform float linkOpacity;
|
|
18
19
|
uniform float greyoutOpacity;
|
|
19
20
|
uniform float curvedWeight;
|
|
20
21
|
uniform float curvedLinkControlPointDistance;
|
|
@@ -27,6 +28,7 @@ varying vec2 pos;
|
|
|
27
28
|
varying float arrowLength;
|
|
28
29
|
varying float useArrow;
|
|
29
30
|
varying float smoothing;
|
|
31
|
+
varying float arrowWidthFactor;
|
|
30
32
|
|
|
31
33
|
float map(float value, float min1, float max1, float min2, float max2) {
|
|
32
34
|
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
|
|
@@ -95,9 +97,11 @@ void main() {
|
|
|
95
97
|
float linkWidth = width * widthScale;
|
|
96
98
|
float k = 2.0;
|
|
97
99
|
// Arrow width is proportionally larger than the line width
|
|
98
|
-
float arrowWidth =
|
|
100
|
+
float arrowWidth = linkWidth * k;
|
|
99
101
|
arrowWidth *= arrowSizeScale;
|
|
100
102
|
|
|
103
|
+
float arrowWidthDifference = arrowWidth - linkWidth;
|
|
104
|
+
|
|
101
105
|
// Calculate arrow width in pixels
|
|
102
106
|
float arrowWidthPx = calculateArrowWidth(arrowWidth);
|
|
103
107
|
|
|
@@ -108,9 +112,11 @@ void main() {
|
|
|
108
112
|
|
|
109
113
|
useArrow = arrow;
|
|
110
114
|
if (useArrow > 0.5) {
|
|
111
|
-
linkWidth
|
|
115
|
+
linkWidth += arrowWidthDifference;
|
|
112
116
|
}
|
|
113
117
|
|
|
118
|
+
arrowWidthFactor = arrowWidthDifference / linkWidth;
|
|
119
|
+
|
|
114
120
|
// Calculate final link width in pixels with smoothing
|
|
115
121
|
float linkWidthPx = calculateLinkWidth(linkWidth);
|
|
116
122
|
float smoothingPx = 0.5 / transformationMatrix[0][0];
|
|
@@ -120,7 +126,7 @@ void main() {
|
|
|
120
126
|
// Calculate final color with opacity based on link distance
|
|
121
127
|
vec3 rgbColor = color.rgb;
|
|
122
128
|
// Adjust opacity based on link distance
|
|
123
|
-
float opacity = color.a * max(linkVisibilityMinTransparency, map(linkDistPx, linkVisibilityDistanceRange.g, linkVisibilityDistanceRange.r, 0.0, 1.0));
|
|
129
|
+
float opacity = color.a * linkOpacity * max(linkVisibilityMinTransparency, map(linkDistPx, linkVisibilityDistanceRange.g, linkVisibilityDistanceRange.r, 0.0, 1.0));
|
|
124
130
|
|
|
125
131
|
// Apply greyed out opacity if either endpoint is greyed out
|
|
126
132
|
if (greyoutStatusA.r > 0.0 || greyoutStatusB.r > 0.0) {
|
|
@@ -69,6 +69,7 @@ export class Lines extends CoreModule {
|
|
|
69
69
|
screenSize: () => store.screenSize,
|
|
70
70
|
linkVisibilityDistanceRange: () => config.linkVisibilityDistanceRange,
|
|
71
71
|
linkVisibilityMinTransparency: () => config.linkVisibilityMinTransparency,
|
|
72
|
+
linkOpacity: () => config.linkOpacity,
|
|
72
73
|
greyoutOpacity: () => config.linkGreyoutOpacity,
|
|
73
74
|
scaleLinksOnZoom: () => config.scaleLinksOnZoom,
|
|
74
75
|
maxPointSize: () => store.maxPointSize,
|
|
@@ -14,6 +14,7 @@ uniform bool scalePointsOnZoom;
|
|
|
14
14
|
uniform float pointIndex;
|
|
15
15
|
uniform float maxPointSize;
|
|
16
16
|
uniform vec4 color;
|
|
17
|
+
uniform float universalPointOpacity;
|
|
17
18
|
uniform float greyoutOpacity;
|
|
18
19
|
uniform bool darkenGreyout;
|
|
19
20
|
uniform vec4 backgroundColor;
|
|
@@ -41,7 +42,7 @@ void main () {
|
|
|
41
42
|
vec4 pointPosition = texture2D(positionsTexture, textureCoordinates / pointsTextureSize);
|
|
42
43
|
|
|
43
44
|
rgbColor = color.rgb;
|
|
44
|
-
pointOpacity = color.a;
|
|
45
|
+
pointOpacity = color.a * universalPointOpacity;
|
|
45
46
|
vec4 greyoutStatus = texture2D(pointGreyoutStatusTexture, textureCoordinates / pointsTextureSize);
|
|
46
47
|
if (greyoutStatus.r > 0.0) {
|
|
47
48
|
if (greyoutColor[0] != -1.0) {
|
|
@@ -15,6 +15,7 @@ uniform float sizeScale;
|
|
|
15
15
|
uniform float spaceSize;
|
|
16
16
|
uniform vec2 screenSize;
|
|
17
17
|
uniform float greyoutOpacity;
|
|
18
|
+
uniform float pointOpacity;
|
|
18
19
|
uniform vec4 greyoutColor;
|
|
19
20
|
uniform vec4 backgroundColor;
|
|
20
21
|
uniform bool scalePointsOnZoom;
|
|
@@ -51,7 +52,7 @@ void main() {
|
|
|
51
52
|
gl_PointSize = calculatePointSize(size * sizeScale);
|
|
52
53
|
|
|
53
54
|
rgbColor = color.rgb;
|
|
54
|
-
alpha = color.a;
|
|
55
|
+
alpha = color.a * pointOpacity;
|
|
55
56
|
|
|
56
57
|
// Adjust alpha of selected points
|
|
57
58
|
vec4 greyoutStatus = texture2D(pointGreyoutStatus, (textureCoords + 0.5) / pointsTextureSize);
|
|
@@ -3,16 +3,16 @@ precision highp float;
|
|
|
3
3
|
#endif
|
|
4
4
|
|
|
5
5
|
uniform sampler2D positionsTexture;
|
|
6
|
-
uniform sampler2D
|
|
7
|
-
uniform int
|
|
6
|
+
uniform sampler2D polygonPathTexture; // Texture containing polygon path points
|
|
7
|
+
uniform int polygonPathLength;
|
|
8
8
|
uniform float spaceSize;
|
|
9
9
|
uniform vec2 screenSize;
|
|
10
10
|
uniform mat3 transformationMatrix;
|
|
11
11
|
|
|
12
12
|
varying vec2 textureCoords;
|
|
13
13
|
|
|
14
|
-
// Get a point from the
|
|
15
|
-
vec2
|
|
14
|
+
// Get a point from the polygon path texture at a specific index
|
|
15
|
+
vec2 getPolygonPoint(sampler2D pathTexture, int index, int pathLength) {
|
|
16
16
|
if (index >= pathLength) return vec2(0.0);
|
|
17
17
|
|
|
18
18
|
// Calculate texture coordinates for the index
|
|
@@ -35,8 +35,8 @@ bool pointInPolygon(vec2 point, sampler2D pathTexture, int pathLength) {
|
|
|
35
35
|
|
|
36
36
|
int j = int(mod(float(i + 1), float(pathLength)));
|
|
37
37
|
|
|
38
|
-
vec2 pi =
|
|
39
|
-
vec2 pj =
|
|
38
|
+
vec2 pi = getPolygonPoint(pathTexture, i, pathLength);
|
|
39
|
+
vec2 pj = getPolygonPoint(pathTexture, j, pathLength);
|
|
40
40
|
|
|
41
41
|
if (((pi.y > point.y) != (pj.y > point.y)) &&
|
|
42
42
|
(point.x < (pj.x - pi.x) * (point.y - pi.y) / (pj.y - pi.y) + pi.x)) {
|
|
@@ -58,8 +58,8 @@ void main() {
|
|
|
58
58
|
|
|
59
59
|
gl_FragColor = vec4(0.0, 0.0, pointPosition.rg);
|
|
60
60
|
|
|
61
|
-
// Check if point center is inside the
|
|
62
|
-
if (pointInPolygon(screenPos,
|
|
61
|
+
// Check if point center is inside the polygon
|
|
62
|
+
if (pointInPolygon(screenPos, polygonPathTexture, polygonPathLength)) {
|
|
63
63
|
gl_FragColor.r = 1.0;
|
|
64
64
|
}
|
|
65
65
|
}
|