@sigma/edge-curve
Advanced tools
Comparing version 3.0.0-beta.6 to 3.0.0-beta.7
@@ -17,2 +17,3 @@ import Graph from "graphology"; | ||
edgeIndexAttribute: string; | ||
edgeMinIndexAttribute: string; | ||
edgeMaxIndexAttribute: string; | ||
@@ -19,0 +20,0 @@ }; |
@@ -313,3 +313,3 @@ 'use strict'; | ||
// language=GLSL | ||
var SHADER = /*glsl*/"\nattribute vec4 a_id;\nattribute vec4 a_color;\nattribute float a_direction;\nattribute float a_thickness;\nattribute vec2 a_source;\nattribute vec2 a_target;\nattribute float a_current;\nattribute float a_curvature;\n".concat(arrowHead ? "attribute float a_targetSize;\n" : "", "\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_pixelRatio;\nuniform vec2 u_dimensions;\n\nvarying vec4 v_color;\nvarying float v_thickness;\nvarying vec2 v_cpA;\nvarying vec2 v_cpB;\nvarying vec2 v_cpC;\n").concat(arrowHead ? "\nvarying float v_targetSize;\nvarying vec2 v_targetPoint;\nuniform float u_widenessToThicknessRatio;\n" : "", "\n\nconst float bias = 255.0 / 254.0;\nconst float epsilon = 0.7;\nconst float minThickness = 0.3;\n\nvec2 clipspaceToViewport(vec2 pos, vec2 dimensions) {\n return vec2(\n (pos.x + 1.0) * dimensions.x / 2.0,\n (pos.y + 1.0) * dimensions.y / 2.0\n );\n}\n\nvec2 viewportToClipspace(vec2 pos, vec2 dimensions) {\n return vec2(\n pos.x / dimensions.x * 2.0 - 1.0,\n pos.y / dimensions.y * 2.0 - 1.0\n );\n}\n\nvoid main() {\n // Selecting the correct position\n // Branchless \"position = a_source if a_current == 1.0 else a_target\"\n vec2 position = a_source * max(0.0, a_current) + a_target * max(0.0, 1.0 - a_current);\n position = (u_matrix * vec3(position, 1)).xy;\n\n vec2 source = (u_matrix * vec3(a_source, 1)).xy;\n vec2 target = (u_matrix * vec3(a_target, 1)).xy;\n\n vec2 viewportPosition = clipspaceToViewport(position, u_dimensions);\n vec2 viewportSource = clipspaceToViewport(source, u_dimensions);\n vec2 viewportTarget = clipspaceToViewport(target, u_dimensions);\n\n vec2 delta = viewportTarget.xy - viewportSource.xy;\n float len = length(delta);\n vec2 normal = vec2(-delta.y, delta.x) * a_direction;\n vec2 unitNormal = normal / len;\n float boundingBoxThickness = len * a_curvature;\n float curveThickness = max(minThickness, a_thickness / 2.0 / u_sizeRatio * u_pixelRatio);\n\n v_thickness = curveThickness;\n\n v_cpA = viewportSource;\n v_cpB = 0.5 * (viewportSource + viewportTarget) + unitNormal * a_direction * boundingBoxThickness;\n v_cpC = viewportTarget;\n\n vec2 viewportOffsetPosition = (\n viewportPosition +\n unitNormal * (boundingBoxThickness / 2.0 + ").concat(arrowHead ? "curveThickness * u_widenessToThicknessRatio" : "curveThickness", " + epsilon) *\n max(0.0, a_direction) // NOTE: cutting the bounding box in half to avoid overdraw\n );\n\n position = viewportToClipspace(viewportOffsetPosition, u_dimensions);\n gl_Position = vec4(position, 0, 1);\n \n").concat(arrowHead ? "\n v_targetSize = a_targetSize * u_pixelRatio / u_sizeRatio;\n v_targetPoint = viewportTarget;\n" : "", "\n\n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_color = a_color;\n #endif\n\n v_color.a *= bias;\n}\n"); | ||
var SHADER = /*glsl*/"\nattribute vec4 a_id;\nattribute vec4 a_color;\nattribute float a_direction;\nattribute float a_thickness;\nattribute vec2 a_source;\nattribute vec2 a_target;\nattribute float a_current;\nattribute float a_curvature;\n".concat(arrowHead ? "attribute float a_targetSize;\n" : "", "\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_pixelRatio;\nuniform vec2 u_dimensions;\n\nvarying vec4 v_color;\nvarying float v_thickness;\nvarying vec2 v_cpA;\nvarying vec2 v_cpB;\nvarying vec2 v_cpC;\n").concat(arrowHead ? "\nvarying float v_targetSize;\nvarying vec2 v_targetPoint;\nuniform float u_widenessToThicknessRatio;\n" : "", "\n\nconst float bias = 255.0 / 254.0;\nconst float epsilon = 0.7;\nconst float minThickness = 0.3;\n\nvec2 clipspaceToViewport(vec2 pos, vec2 dimensions) {\n return vec2(\n (pos.x + 1.0) * dimensions.x / 2.0,\n (pos.y + 1.0) * dimensions.y / 2.0\n );\n}\n\nvec2 viewportToClipspace(vec2 pos, vec2 dimensions) {\n return vec2(\n pos.x / dimensions.x * 2.0 - 1.0,\n pos.y / dimensions.y * 2.0 - 1.0\n );\n}\n\nvoid main() {\n // Selecting the correct position\n // Branchless \"position = a_source if a_current == 1.0 else a_target\"\n vec2 position = a_source * max(0.0, a_current) + a_target * max(0.0, 1.0 - a_current);\n position = (u_matrix * vec3(position, 1)).xy;\n\n vec2 source = (u_matrix * vec3(a_source, 1)).xy;\n vec2 target = (u_matrix * vec3(a_target, 1)).xy;\n\n vec2 viewportPosition = clipspaceToViewport(position, u_dimensions);\n vec2 viewportSource = clipspaceToViewport(source, u_dimensions);\n vec2 viewportTarget = clipspaceToViewport(target, u_dimensions);\n\n vec2 delta = viewportTarget.xy - viewportSource.xy;\n float len = length(delta);\n vec2 normal = vec2(-delta.y, delta.x) * a_direction;\n vec2 unitNormal = normal / len;\n float boundingBoxThickness = len * a_curvature;\n float curveThickness = max(minThickness, a_thickness / 2.0 / u_sizeRatio * u_pixelRatio);\n\n v_thickness = curveThickness;\n\n v_cpA = viewportSource;\n v_cpB = 0.5 * (viewportSource + viewportTarget) + unitNormal * a_direction * boundingBoxThickness;\n v_cpC = viewportTarget;\n\n vec2 viewportOffsetPosition = (\n viewportPosition +\n unitNormal * (boundingBoxThickness / 2.0 + sign(boundingBoxThickness) * (").concat(arrowHead ? "curveThickness * u_widenessToThicknessRatio" : "curveThickness", " + epsilon)) *\n max(0.0, a_direction) // NOTE: cutting the bounding box in half to avoid overdraw\n );\n\n position = viewportToClipspace(viewportOffsetPosition, u_dimensions);\n gl_Position = vec4(position, 0, 1);\n \n").concat(arrowHead ? "\n v_targetSize = a_targetSize * u_pixelRatio / u_sizeRatio;\n v_targetPoint = viewportTarget;\n" : "", "\n\n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_color = a_color;\n #endif\n\n v_color.a *= bias;\n}\n"); | ||
return SHADER; | ||
@@ -330,2 +330,3 @@ } | ||
edgeIndexAttribute: "parallelIndex", | ||
edgeMinIndexAttribute: "parallelMinIndex", | ||
edgeMaxIndexAttribute: "parallelMaxIndex" | ||
@@ -380,14 +381,27 @@ }; | ||
var _edge = edges[0]; | ||
graph.setEdgeAttribute(_edge, opts.edgeIndexAttribute, 0); | ||
graph.setEdgeAttribute(_edge, opts.edgeIndexAttribute, 1); | ||
graph.setEdgeAttribute(_edge, opts.edgeMaxIndexAttribute, 1); | ||
} | ||
// If the edge is not alone: | ||
else { | ||
// If the edge is not alone, and all edges are in the same direction: | ||
else if (directedCount === undirectedCount) { | ||
var max = (directedCount - 1) / 2; | ||
var min = -max; | ||
for (var i = 0; i < directedCount; i++) { | ||
var _edge2 = edges[i]; | ||
graph.setEdgeAttribute(_edge2, opts.edgeIndexAttribute, i); | ||
graph.setEdgeAttribute(_edge2, opts.edgeMaxIndexAttribute, directedCount); | ||
var edgeIndex = -(directedCount - 1) / 2 + i; | ||
graph.setEdgeAttribute(_edge2, opts.edgeIndexAttribute, edgeIndex); | ||
graph.setEdgeAttribute(_edge2, opts.edgeMinIndexAttribute, min); | ||
graph.setEdgeAttribute(_edge2, opts.edgeMaxIndexAttribute, max); | ||
} | ||
} | ||
// If the edge is not alone, and there are edges in both directions: | ||
else { | ||
for (var _i = 0; _i < directedCount; _i++) { | ||
var _edge3 = edges[_i]; | ||
graph.setEdgeAttribute(_edge3, opts.edgeIndexAttribute, _i + 1); | ||
graph.setEdgeAttribute(_edge3, opts.edgeMaxIndexAttribute, directedCount); | ||
} | ||
} | ||
} | ||
@@ -394,0 +408,0 @@ } |
@@ -313,3 +313,3 @@ 'use strict'; | ||
// language=GLSL | ||
var SHADER = /*glsl*/"\nattribute vec4 a_id;\nattribute vec4 a_color;\nattribute float a_direction;\nattribute float a_thickness;\nattribute vec2 a_source;\nattribute vec2 a_target;\nattribute float a_current;\nattribute float a_curvature;\n".concat(arrowHead ? "attribute float a_targetSize;\n" : "", "\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_pixelRatio;\nuniform vec2 u_dimensions;\n\nvarying vec4 v_color;\nvarying float v_thickness;\nvarying vec2 v_cpA;\nvarying vec2 v_cpB;\nvarying vec2 v_cpC;\n").concat(arrowHead ? "\nvarying float v_targetSize;\nvarying vec2 v_targetPoint;\nuniform float u_widenessToThicknessRatio;\n" : "", "\n\nconst float bias = 255.0 / 254.0;\nconst float epsilon = 0.7;\nconst float minThickness = 0.3;\n\nvec2 clipspaceToViewport(vec2 pos, vec2 dimensions) {\n return vec2(\n (pos.x + 1.0) * dimensions.x / 2.0,\n (pos.y + 1.0) * dimensions.y / 2.0\n );\n}\n\nvec2 viewportToClipspace(vec2 pos, vec2 dimensions) {\n return vec2(\n pos.x / dimensions.x * 2.0 - 1.0,\n pos.y / dimensions.y * 2.0 - 1.0\n );\n}\n\nvoid main() {\n // Selecting the correct position\n // Branchless \"position = a_source if a_current == 1.0 else a_target\"\n vec2 position = a_source * max(0.0, a_current) + a_target * max(0.0, 1.0 - a_current);\n position = (u_matrix * vec3(position, 1)).xy;\n\n vec2 source = (u_matrix * vec3(a_source, 1)).xy;\n vec2 target = (u_matrix * vec3(a_target, 1)).xy;\n\n vec2 viewportPosition = clipspaceToViewport(position, u_dimensions);\n vec2 viewportSource = clipspaceToViewport(source, u_dimensions);\n vec2 viewportTarget = clipspaceToViewport(target, u_dimensions);\n\n vec2 delta = viewportTarget.xy - viewportSource.xy;\n float len = length(delta);\n vec2 normal = vec2(-delta.y, delta.x) * a_direction;\n vec2 unitNormal = normal / len;\n float boundingBoxThickness = len * a_curvature;\n float curveThickness = max(minThickness, a_thickness / 2.0 / u_sizeRatio * u_pixelRatio);\n\n v_thickness = curveThickness;\n\n v_cpA = viewportSource;\n v_cpB = 0.5 * (viewportSource + viewportTarget) + unitNormal * a_direction * boundingBoxThickness;\n v_cpC = viewportTarget;\n\n vec2 viewportOffsetPosition = (\n viewportPosition +\n unitNormal * (boundingBoxThickness / 2.0 + ").concat(arrowHead ? "curveThickness * u_widenessToThicknessRatio" : "curveThickness", " + epsilon) *\n max(0.0, a_direction) // NOTE: cutting the bounding box in half to avoid overdraw\n );\n\n position = viewportToClipspace(viewportOffsetPosition, u_dimensions);\n gl_Position = vec4(position, 0, 1);\n \n").concat(arrowHead ? "\n v_targetSize = a_targetSize * u_pixelRatio / u_sizeRatio;\n v_targetPoint = viewportTarget;\n" : "", "\n\n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_color = a_color;\n #endif\n\n v_color.a *= bias;\n}\n"); | ||
var SHADER = /*glsl*/"\nattribute vec4 a_id;\nattribute vec4 a_color;\nattribute float a_direction;\nattribute float a_thickness;\nattribute vec2 a_source;\nattribute vec2 a_target;\nattribute float a_current;\nattribute float a_curvature;\n".concat(arrowHead ? "attribute float a_targetSize;\n" : "", "\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_pixelRatio;\nuniform vec2 u_dimensions;\n\nvarying vec4 v_color;\nvarying float v_thickness;\nvarying vec2 v_cpA;\nvarying vec2 v_cpB;\nvarying vec2 v_cpC;\n").concat(arrowHead ? "\nvarying float v_targetSize;\nvarying vec2 v_targetPoint;\nuniform float u_widenessToThicknessRatio;\n" : "", "\n\nconst float bias = 255.0 / 254.0;\nconst float epsilon = 0.7;\nconst float minThickness = 0.3;\n\nvec2 clipspaceToViewport(vec2 pos, vec2 dimensions) {\n return vec2(\n (pos.x + 1.0) * dimensions.x / 2.0,\n (pos.y + 1.0) * dimensions.y / 2.0\n );\n}\n\nvec2 viewportToClipspace(vec2 pos, vec2 dimensions) {\n return vec2(\n pos.x / dimensions.x * 2.0 - 1.0,\n pos.y / dimensions.y * 2.0 - 1.0\n );\n}\n\nvoid main() {\n // Selecting the correct position\n // Branchless \"position = a_source if a_current == 1.0 else a_target\"\n vec2 position = a_source * max(0.0, a_current) + a_target * max(0.0, 1.0 - a_current);\n position = (u_matrix * vec3(position, 1)).xy;\n\n vec2 source = (u_matrix * vec3(a_source, 1)).xy;\n vec2 target = (u_matrix * vec3(a_target, 1)).xy;\n\n vec2 viewportPosition = clipspaceToViewport(position, u_dimensions);\n vec2 viewportSource = clipspaceToViewport(source, u_dimensions);\n vec2 viewportTarget = clipspaceToViewport(target, u_dimensions);\n\n vec2 delta = viewportTarget.xy - viewportSource.xy;\n float len = length(delta);\n vec2 normal = vec2(-delta.y, delta.x) * a_direction;\n vec2 unitNormal = normal / len;\n float boundingBoxThickness = len * a_curvature;\n float curveThickness = max(minThickness, a_thickness / 2.0 / u_sizeRatio * u_pixelRatio);\n\n v_thickness = curveThickness;\n\n v_cpA = viewportSource;\n v_cpB = 0.5 * (viewportSource + viewportTarget) + unitNormal * a_direction * boundingBoxThickness;\n v_cpC = viewportTarget;\n\n vec2 viewportOffsetPosition = (\n viewportPosition +\n unitNormal * (boundingBoxThickness / 2.0 + sign(boundingBoxThickness) * (").concat(arrowHead ? "curveThickness * u_widenessToThicknessRatio" : "curveThickness", " + epsilon)) *\n max(0.0, a_direction) // NOTE: cutting the bounding box in half to avoid overdraw\n );\n\n position = viewportToClipspace(viewportOffsetPosition, u_dimensions);\n gl_Position = vec4(position, 0, 1);\n \n").concat(arrowHead ? "\n v_targetSize = a_targetSize * u_pixelRatio / u_sizeRatio;\n v_targetPoint = viewportTarget;\n" : "", "\n\n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_color = a_color;\n #endif\n\n v_color.a *= bias;\n}\n"); | ||
return SHADER; | ||
@@ -330,2 +330,3 @@ } | ||
edgeIndexAttribute: "parallelIndex", | ||
edgeMinIndexAttribute: "parallelMinIndex", | ||
edgeMaxIndexAttribute: "parallelMaxIndex" | ||
@@ -380,14 +381,27 @@ }; | ||
var _edge = edges[0]; | ||
graph.setEdgeAttribute(_edge, opts.edgeIndexAttribute, 0); | ||
graph.setEdgeAttribute(_edge, opts.edgeIndexAttribute, 1); | ||
graph.setEdgeAttribute(_edge, opts.edgeMaxIndexAttribute, 1); | ||
} | ||
// If the edge is not alone: | ||
else { | ||
// If the edge is not alone, and all edges are in the same direction: | ||
else if (directedCount === undirectedCount) { | ||
var max = (directedCount - 1) / 2; | ||
var min = -max; | ||
for (var i = 0; i < directedCount; i++) { | ||
var _edge2 = edges[i]; | ||
graph.setEdgeAttribute(_edge2, opts.edgeIndexAttribute, i); | ||
graph.setEdgeAttribute(_edge2, opts.edgeMaxIndexAttribute, directedCount); | ||
var edgeIndex = -(directedCount - 1) / 2 + i; | ||
graph.setEdgeAttribute(_edge2, opts.edgeIndexAttribute, edgeIndex); | ||
graph.setEdgeAttribute(_edge2, opts.edgeMinIndexAttribute, min); | ||
graph.setEdgeAttribute(_edge2, opts.edgeMaxIndexAttribute, max); | ||
} | ||
} | ||
// If the edge is not alone, and there are edges in both directions: | ||
else { | ||
for (var _i = 0; _i < directedCount; _i++) { | ||
var _edge3 = edges[_i]; | ||
graph.setEdgeAttribute(_edge3, opts.edgeIndexAttribute, _i + 1); | ||
graph.setEdgeAttribute(_edge3, opts.edgeMaxIndexAttribute, directedCount); | ||
} | ||
} | ||
} | ||
@@ -394,0 +408,0 @@ } |
@@ -309,3 +309,3 @@ import { EdgeProgram } from 'sigma/rendering'; | ||
// language=GLSL | ||
var SHADER = /*glsl*/"\nattribute vec4 a_id;\nattribute vec4 a_color;\nattribute float a_direction;\nattribute float a_thickness;\nattribute vec2 a_source;\nattribute vec2 a_target;\nattribute float a_current;\nattribute float a_curvature;\n".concat(arrowHead ? "attribute float a_targetSize;\n" : "", "\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_pixelRatio;\nuniform vec2 u_dimensions;\n\nvarying vec4 v_color;\nvarying float v_thickness;\nvarying vec2 v_cpA;\nvarying vec2 v_cpB;\nvarying vec2 v_cpC;\n").concat(arrowHead ? "\nvarying float v_targetSize;\nvarying vec2 v_targetPoint;\nuniform float u_widenessToThicknessRatio;\n" : "", "\n\nconst float bias = 255.0 / 254.0;\nconst float epsilon = 0.7;\nconst float minThickness = 0.3;\n\nvec2 clipspaceToViewport(vec2 pos, vec2 dimensions) {\n return vec2(\n (pos.x + 1.0) * dimensions.x / 2.0,\n (pos.y + 1.0) * dimensions.y / 2.0\n );\n}\n\nvec2 viewportToClipspace(vec2 pos, vec2 dimensions) {\n return vec2(\n pos.x / dimensions.x * 2.0 - 1.0,\n pos.y / dimensions.y * 2.0 - 1.0\n );\n}\n\nvoid main() {\n // Selecting the correct position\n // Branchless \"position = a_source if a_current == 1.0 else a_target\"\n vec2 position = a_source * max(0.0, a_current) + a_target * max(0.0, 1.0 - a_current);\n position = (u_matrix * vec3(position, 1)).xy;\n\n vec2 source = (u_matrix * vec3(a_source, 1)).xy;\n vec2 target = (u_matrix * vec3(a_target, 1)).xy;\n\n vec2 viewportPosition = clipspaceToViewport(position, u_dimensions);\n vec2 viewportSource = clipspaceToViewport(source, u_dimensions);\n vec2 viewportTarget = clipspaceToViewport(target, u_dimensions);\n\n vec2 delta = viewportTarget.xy - viewportSource.xy;\n float len = length(delta);\n vec2 normal = vec2(-delta.y, delta.x) * a_direction;\n vec2 unitNormal = normal / len;\n float boundingBoxThickness = len * a_curvature;\n float curveThickness = max(minThickness, a_thickness / 2.0 / u_sizeRatio * u_pixelRatio);\n\n v_thickness = curveThickness;\n\n v_cpA = viewportSource;\n v_cpB = 0.5 * (viewportSource + viewportTarget) + unitNormal * a_direction * boundingBoxThickness;\n v_cpC = viewportTarget;\n\n vec2 viewportOffsetPosition = (\n viewportPosition +\n unitNormal * (boundingBoxThickness / 2.0 + ").concat(arrowHead ? "curveThickness * u_widenessToThicknessRatio" : "curveThickness", " + epsilon) *\n max(0.0, a_direction) // NOTE: cutting the bounding box in half to avoid overdraw\n );\n\n position = viewportToClipspace(viewportOffsetPosition, u_dimensions);\n gl_Position = vec4(position, 0, 1);\n \n").concat(arrowHead ? "\n v_targetSize = a_targetSize * u_pixelRatio / u_sizeRatio;\n v_targetPoint = viewportTarget;\n" : "", "\n\n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_color = a_color;\n #endif\n\n v_color.a *= bias;\n}\n"); | ||
var SHADER = /*glsl*/"\nattribute vec4 a_id;\nattribute vec4 a_color;\nattribute float a_direction;\nattribute float a_thickness;\nattribute vec2 a_source;\nattribute vec2 a_target;\nattribute float a_current;\nattribute float a_curvature;\n".concat(arrowHead ? "attribute float a_targetSize;\n" : "", "\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_pixelRatio;\nuniform vec2 u_dimensions;\n\nvarying vec4 v_color;\nvarying float v_thickness;\nvarying vec2 v_cpA;\nvarying vec2 v_cpB;\nvarying vec2 v_cpC;\n").concat(arrowHead ? "\nvarying float v_targetSize;\nvarying vec2 v_targetPoint;\nuniform float u_widenessToThicknessRatio;\n" : "", "\n\nconst float bias = 255.0 / 254.0;\nconst float epsilon = 0.7;\nconst float minThickness = 0.3;\n\nvec2 clipspaceToViewport(vec2 pos, vec2 dimensions) {\n return vec2(\n (pos.x + 1.0) * dimensions.x / 2.0,\n (pos.y + 1.0) * dimensions.y / 2.0\n );\n}\n\nvec2 viewportToClipspace(vec2 pos, vec2 dimensions) {\n return vec2(\n pos.x / dimensions.x * 2.0 - 1.0,\n pos.y / dimensions.y * 2.0 - 1.0\n );\n}\n\nvoid main() {\n // Selecting the correct position\n // Branchless \"position = a_source if a_current == 1.0 else a_target\"\n vec2 position = a_source * max(0.0, a_current) + a_target * max(0.0, 1.0 - a_current);\n position = (u_matrix * vec3(position, 1)).xy;\n\n vec2 source = (u_matrix * vec3(a_source, 1)).xy;\n vec2 target = (u_matrix * vec3(a_target, 1)).xy;\n\n vec2 viewportPosition = clipspaceToViewport(position, u_dimensions);\n vec2 viewportSource = clipspaceToViewport(source, u_dimensions);\n vec2 viewportTarget = clipspaceToViewport(target, u_dimensions);\n\n vec2 delta = viewportTarget.xy - viewportSource.xy;\n float len = length(delta);\n vec2 normal = vec2(-delta.y, delta.x) * a_direction;\n vec2 unitNormal = normal / len;\n float boundingBoxThickness = len * a_curvature;\n float curveThickness = max(minThickness, a_thickness / 2.0 / u_sizeRatio * u_pixelRatio);\n\n v_thickness = curveThickness;\n\n v_cpA = viewportSource;\n v_cpB = 0.5 * (viewportSource + viewportTarget) + unitNormal * a_direction * boundingBoxThickness;\n v_cpC = viewportTarget;\n\n vec2 viewportOffsetPosition = (\n viewportPosition +\n unitNormal * (boundingBoxThickness / 2.0 + sign(boundingBoxThickness) * (").concat(arrowHead ? "curveThickness * u_widenessToThicknessRatio" : "curveThickness", " + epsilon)) *\n max(0.0, a_direction) // NOTE: cutting the bounding box in half to avoid overdraw\n );\n\n position = viewportToClipspace(viewportOffsetPosition, u_dimensions);\n gl_Position = vec4(position, 0, 1);\n \n").concat(arrowHead ? "\n v_targetSize = a_targetSize * u_pixelRatio / u_sizeRatio;\n v_targetPoint = viewportTarget;\n" : "", "\n\n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_color = a_color;\n #endif\n\n v_color.a *= bias;\n}\n"); | ||
return SHADER; | ||
@@ -326,2 +326,3 @@ } | ||
edgeIndexAttribute: "parallelIndex", | ||
edgeMinIndexAttribute: "parallelMinIndex", | ||
edgeMaxIndexAttribute: "parallelMaxIndex" | ||
@@ -376,14 +377,27 @@ }; | ||
var _edge = edges[0]; | ||
graph.setEdgeAttribute(_edge, opts.edgeIndexAttribute, 0); | ||
graph.setEdgeAttribute(_edge, opts.edgeIndexAttribute, 1); | ||
graph.setEdgeAttribute(_edge, opts.edgeMaxIndexAttribute, 1); | ||
} | ||
// If the edge is not alone: | ||
else { | ||
// If the edge is not alone, and all edges are in the same direction: | ||
else if (directedCount === undirectedCount) { | ||
var max = (directedCount - 1) / 2; | ||
var min = -max; | ||
for (var i = 0; i < directedCount; i++) { | ||
var _edge2 = edges[i]; | ||
graph.setEdgeAttribute(_edge2, opts.edgeIndexAttribute, i); | ||
graph.setEdgeAttribute(_edge2, opts.edgeMaxIndexAttribute, directedCount); | ||
var edgeIndex = -(directedCount - 1) / 2 + i; | ||
graph.setEdgeAttribute(_edge2, opts.edgeIndexAttribute, edgeIndex); | ||
graph.setEdgeAttribute(_edge2, opts.edgeMinIndexAttribute, min); | ||
graph.setEdgeAttribute(_edge2, opts.edgeMaxIndexAttribute, max); | ||
} | ||
} | ||
// If the edge is not alone, and there are edges in both directions: | ||
else { | ||
for (var _i = 0; _i < directedCount; _i++) { | ||
var _edge3 = edges[_i]; | ||
graph.setEdgeAttribute(_edge3, opts.edgeIndexAttribute, _i + 1); | ||
graph.setEdgeAttribute(_edge3, opts.edgeMaxIndexAttribute, directedCount); | ||
} | ||
} | ||
} | ||
@@ -390,0 +404,0 @@ } |
{ | ||
"name": "@sigma/edge-curve", | ||
"version": "3.0.0-beta.6", | ||
"version": "3.0.0-beta.7", | ||
"description": "An edge program that renders edges as curves for sigma.js", | ||
@@ -50,3 +50,3 @@ "main": "dist/sigma-edge-curve.cjs.js", | ||
}, | ||
"gitHead": "708bfed55d0eec0a24dee7e9c99d265a9f32b621" | ||
"gitHead": "6c1cf6dcf58b4b4116a8aedcd37cccd62018179b" | ||
} |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
78738
1587