mirror of
https://github.com/Siccity/xNode.git
synced 2026-03-26 22:49:02 +08:00
Fixed formatting inconsistensies.
This commit is contained in:
parent
49c0f40539
commit
dfdfab4b04
@ -473,8 +473,8 @@ namespace XNodeEditor {
|
||||
Color col = NodeEditorPreferences.GetTypeColor(draggedOutput.ValueType);
|
||||
col.a = draggedOutputTarget != null ? 1.0f : 0.6f;
|
||||
|
||||
Gradient g = new Gradient();
|
||||
g.SetKeys(new GradientColorKey[] { new GradientColorKey(col, 0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1f, 0f) });
|
||||
Gradient gradient = new Gradient();
|
||||
gradient.SetKeys(new GradientColorKey[] { new GradientColorKey(col, 0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1f, 0f) });
|
||||
|
||||
Rect fromRect;
|
||||
if (!_portConnectionPoints.TryGetValue(draggedOutput, out fromRect)) return;
|
||||
@ -486,7 +486,7 @@ namespace XNodeEditor {
|
||||
if (draggedOutputTarget != null) gridPoints.Add(portConnectionPoints[draggedOutputTarget].center);
|
||||
else gridPoints.Add(WindowToGridPosition(Event.current.mousePosition));
|
||||
|
||||
DrawNoodle(g, gridPoints, true);
|
||||
DrawNoodle(gradient, gridPoints, false);
|
||||
|
||||
Color bgcol = Color.black;
|
||||
Color frcol = col;
|
||||
|
||||
@ -117,9 +117,9 @@ namespace XNodeEditor {
|
||||
}
|
||||
|
||||
/// <summary> Draw a bezier from output to input in grid coordinates </summary>
|
||||
public void DrawNoodle(Gradient grad, List<Vector2> gridPoints, bool disableHover = false) {
|
||||
public void DrawNoodle(Gradient gradient, List<Vector2> gridPoints, bool enableHoveringHighlight = true) {
|
||||
Vector2[] windowPoints = gridPoints.Select(x => GridToWindowPosition(x)).ToArray();
|
||||
Handles.color = grad.Evaluate(0f);
|
||||
Handles.color = gradient.Evaluate(0f);
|
||||
int length = gridPoints.Count;
|
||||
switch (NodeEditorPreferences.GetSettings().noodleType) {
|
||||
case NodeEditorPreferences.NoodleType.Curve:
|
||||
@ -154,7 +154,7 @@ namespace XNodeEditor {
|
||||
int bezier_width = 4;
|
||||
int division = Mathf.RoundToInt(.1f * dist_ab) + 3;
|
||||
Vector3[] points = Handles.MakeBezierPoints(point_a, point_b, tangent_a, tangent_b, division);
|
||||
if (!disableHover) {
|
||||
if (enableHoveringHighlight) {
|
||||
for (int j = 0; j < points.Length; j++) {
|
||||
Vector3 current = points[j];
|
||||
bool next_has_mouse = false;
|
||||
@ -170,7 +170,7 @@ namespace XNodeEditor {
|
||||
}
|
||||
// Coloring and bezier drawing.
|
||||
for (int j = 0; j < points.Length - 1; j++) {
|
||||
Handles.color = grad.Evaluate((j + 1f) / (points.Length));
|
||||
Handles.color = gradient.Evaluate((j + 1f) / (points.Length));
|
||||
Handles.DrawAAPolyLine(bezier_width / zoom, points[j], points[j + 1]);
|
||||
}
|
||||
outputTangent = -inputTangent;
|
||||
@ -182,12 +182,12 @@ namespace XNodeEditor {
|
||||
Vector2 point_b = windowPoints[i + 1];
|
||||
// Hover effect.
|
||||
int line_width = 5;
|
||||
if (!disableHover && LineContainsMouse(point_a, point_b)) line_width += 2;
|
||||
if (enableHoveringHighlight && LineContainsMouse(point_a, point_b)) line_width += 2;
|
||||
// Draws the line with the coloring.
|
||||
Vector2 prev_point = point_a;
|
||||
for (float j = 0; j < 1; j += 10f / Vector2.Distance(point_a, point_b)) {
|
||||
Vector2 lerp = Vector2.Lerp(point_a, point_b, j);
|
||||
Handles.color = grad.Evaluate(j);
|
||||
Handles.color = gradient.Evaluate(j);
|
||||
Handles.DrawAAPolyLine(line_width / zoom, prev_point, lerp);
|
||||
prev_point = lerp;
|
||||
}
|
||||
@ -202,11 +202,11 @@ namespace XNodeEditor {
|
||||
Vector2 end_1 = windowPoints[i + 1];
|
||||
start_1.x = midpoint;
|
||||
end_1.x = midpoint;
|
||||
Handles.color = grad.Evaluate(0f);
|
||||
Handles.color = gradient.Evaluate(0f);
|
||||
Handles.DrawAAPolyLine(5, windowPoints[i], start_1);
|
||||
Handles.color = grad.Evaluate(0.5f);
|
||||
Handles.color = gradient.Evaluate(0.5f);
|
||||
Handles.DrawAAPolyLine(5, start_1, end_1);
|
||||
Handles.color = grad.Evaluate(1f);
|
||||
Handles.color = gradient.Evaluate(1f);
|
||||
Handles.DrawAAPolyLine(5, end_1, windowPoints[i + 1]);
|
||||
} else {
|
||||
float midpoint = (windowPoints[i].y + windowPoints[i + 1].y) * 0.5f;
|
||||
@ -218,15 +218,15 @@ namespace XNodeEditor {
|
||||
Vector2 end_2 = end_1;
|
||||
start_2.y = midpoint;
|
||||
end_2.y = midpoint;
|
||||
Handles.color = grad.Evaluate(0f);
|
||||
Handles.color = gradient.Evaluate(0f);
|
||||
Handles.DrawAAPolyLine(5, windowPoints[i], start_1);
|
||||
Handles.color = grad.Evaluate(0.25f);
|
||||
Handles.color = gradient.Evaluate(0.25f);
|
||||
Handles.DrawAAPolyLine(5, start_1, start_2);
|
||||
Handles.color = grad.Evaluate(0.5f);
|
||||
Handles.color = gradient.Evaluate(0.5f);
|
||||
Handles.DrawAAPolyLine(5, start_2, end_2);
|
||||
Handles.color = grad.Evaluate(0.75f);
|
||||
Handles.color = gradient.Evaluate(0.75f);
|
||||
Handles.DrawAAPolyLine(5, end_2, end_1);
|
||||
Handles.color = grad.Evaluate(1f);
|
||||
Handles.color = gradient.Evaluate(1f);
|
||||
Handles.DrawAAPolyLine(5, end_1, windowPoints[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user