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);
|
Color col = NodeEditorPreferences.GetTypeColor(draggedOutput.ValueType);
|
||||||
col.a = draggedOutputTarget != null ? 1.0f : 0.6f;
|
col.a = draggedOutputTarget != null ? 1.0f : 0.6f;
|
||||||
|
|
||||||
Gradient g = new Gradient();
|
Gradient gradient = new Gradient();
|
||||||
g.SetKeys(new GradientColorKey[] { new GradientColorKey(col, 0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1f, 0f) });
|
gradient.SetKeys(new GradientColorKey[] { new GradientColorKey(col, 0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1f, 0f) });
|
||||||
|
|
||||||
Rect fromRect;
|
Rect fromRect;
|
||||||
if (!_portConnectionPoints.TryGetValue(draggedOutput, out fromRect)) return;
|
if (!_portConnectionPoints.TryGetValue(draggedOutput, out fromRect)) return;
|
||||||
@ -486,7 +486,7 @@ namespace XNodeEditor {
|
|||||||
if (draggedOutputTarget != null) gridPoints.Add(portConnectionPoints[draggedOutputTarget].center);
|
if (draggedOutputTarget != null) gridPoints.Add(portConnectionPoints[draggedOutputTarget].center);
|
||||||
else gridPoints.Add(WindowToGridPosition(Event.current.mousePosition));
|
else gridPoints.Add(WindowToGridPosition(Event.current.mousePosition));
|
||||||
|
|
||||||
DrawNoodle(g, gridPoints, true);
|
DrawNoodle(gradient, gridPoints, false);
|
||||||
|
|
||||||
Color bgcol = Color.black;
|
Color bgcol = Color.black;
|
||||||
Color frcol = col;
|
Color frcol = col;
|
||||||
|
|||||||
@ -117,9 +117,9 @@ namespace XNodeEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Draw a bezier from output to input in grid coordinates </summary>
|
/// <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();
|
Vector2[] windowPoints = gridPoints.Select(x => GridToWindowPosition(x)).ToArray();
|
||||||
Handles.color = grad.Evaluate(0f);
|
Handles.color = gradient.Evaluate(0f);
|
||||||
int length = gridPoints.Count;
|
int length = gridPoints.Count;
|
||||||
switch (NodeEditorPreferences.GetSettings().noodleType) {
|
switch (NodeEditorPreferences.GetSettings().noodleType) {
|
||||||
case NodeEditorPreferences.NoodleType.Curve:
|
case NodeEditorPreferences.NoodleType.Curve:
|
||||||
@ -154,7 +154,7 @@ namespace XNodeEditor {
|
|||||||
int bezier_width = 4;
|
int bezier_width = 4;
|
||||||
int division = Mathf.RoundToInt(.1f * dist_ab) + 3;
|
int division = Mathf.RoundToInt(.1f * dist_ab) + 3;
|
||||||
Vector3[] points = Handles.MakeBezierPoints(point_a, point_b, tangent_a, tangent_b, division);
|
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++) {
|
for (int j = 0; j < points.Length; j++) {
|
||||||
Vector3 current = points[j];
|
Vector3 current = points[j];
|
||||||
bool next_has_mouse = false;
|
bool next_has_mouse = false;
|
||||||
@ -170,7 +170,7 @@ namespace XNodeEditor {
|
|||||||
}
|
}
|
||||||
// Coloring and bezier drawing.
|
// Coloring and bezier drawing.
|
||||||
for (int j = 0; j < points.Length - 1; j++) {
|
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]);
|
Handles.DrawAAPolyLine(bezier_width / zoom, points[j], points[j + 1]);
|
||||||
}
|
}
|
||||||
outputTangent = -inputTangent;
|
outputTangent = -inputTangent;
|
||||||
@ -182,12 +182,12 @@ namespace XNodeEditor {
|
|||||||
Vector2 point_b = windowPoints[i + 1];
|
Vector2 point_b = windowPoints[i + 1];
|
||||||
// Hover effect.
|
// Hover effect.
|
||||||
int line_width = 5;
|
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.
|
// Draws the line with the coloring.
|
||||||
Vector2 prev_point = point_a;
|
Vector2 prev_point = point_a;
|
||||||
for (float j = 0; j < 1; j += 10f / Vector2.Distance(point_a, point_b)) {
|
for (float j = 0; j < 1; j += 10f / Vector2.Distance(point_a, point_b)) {
|
||||||
Vector2 lerp = Vector2.Lerp(point_a, point_b, j);
|
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);
|
Handles.DrawAAPolyLine(line_width / zoom, prev_point, lerp);
|
||||||
prev_point = lerp;
|
prev_point = lerp;
|
||||||
}
|
}
|
||||||
@ -202,11 +202,11 @@ namespace XNodeEditor {
|
|||||||
Vector2 end_1 = windowPoints[i + 1];
|
Vector2 end_1 = windowPoints[i + 1];
|
||||||
start_1.x = midpoint;
|
start_1.x = midpoint;
|
||||||
end_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.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.DrawAAPolyLine(5, start_1, end_1);
|
||||||
Handles.color = grad.Evaluate(1f);
|
Handles.color = gradient.Evaluate(1f);
|
||||||
Handles.DrawAAPolyLine(5, end_1, windowPoints[i + 1]);
|
Handles.DrawAAPolyLine(5, end_1, windowPoints[i + 1]);
|
||||||
} else {
|
} else {
|
||||||
float midpoint = (windowPoints[i].y + windowPoints[i + 1].y) * 0.5f;
|
float midpoint = (windowPoints[i].y + windowPoints[i + 1].y) * 0.5f;
|
||||||
@ -218,15 +218,15 @@ namespace XNodeEditor {
|
|||||||
Vector2 end_2 = end_1;
|
Vector2 end_2 = end_1;
|
||||||
start_2.y = midpoint;
|
start_2.y = midpoint;
|
||||||
end_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.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.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.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.DrawAAPolyLine(5, end_2, end_1);
|
||||||
Handles.color = grad.Evaluate(1f);
|
Handles.color = gradient.Evaluate(1f);
|
||||||
Handles.DrawAAPolyLine(5, end_1, windowPoints[i + 1]);
|
Handles.DrawAAPolyLine(5, end_1, windowPoints[i + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user