mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Fixed formatting, fixed dashed stroke style
This commit is contained in:
parent
ec9c5a99de
commit
4edcc3f099
@ -116,7 +116,7 @@ namespace XNodeEditor {
|
|||||||
contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
|
contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
|
||||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector2 CalculateBezierPoint(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float t) {
|
static Vector2 CalculateBezierPoint(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float t) {
|
||||||
float u = 1 - t;
|
float u = 1 - t;
|
||||||
float tt = t * t, uu = u * u;
|
float tt = t * t, uu = u * u;
|
||||||
@ -135,7 +135,7 @@ namespace XNodeEditor {
|
|||||||
polyLineTempArray[1].y = p1.y;
|
polyLineTempArray[1].y = p1.y;
|
||||||
Handles.DrawAAPolyLine(thickness, polyLineTempArray);
|
Handles.DrawAAPolyLine(thickness, polyLineTempArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <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 gradient, NoodlePath path, NoodleStroke stroke, float thickness, List<Vector2> gridPoints) {
|
public void DrawNoodle(Gradient gradient, NoodlePath path, NoodleStroke stroke, float thickness, List<Vector2> gridPoints) {
|
||||||
// convert grid points to window points
|
// convert grid points to window points
|
||||||
@ -178,16 +178,16 @@ namespace XNodeEditor {
|
|||||||
// Coloring and bezier drawing.
|
// Coloring and bezier drawing.
|
||||||
int draw = 0;
|
int draw = 0;
|
||||||
Vector2 bezierPrevious = point_a;
|
Vector2 bezierPrevious = point_a;
|
||||||
for (int j = 1; j <= division; ++j)
|
for (int j = 1; j <= division; ++j) {
|
||||||
{
|
|
||||||
if (stroke == NoodleStroke.Dashed) {
|
if (stroke == NoodleStroke.Dashed) {
|
||||||
draw++;
|
draw++;
|
||||||
if (draw >= 2) draw = -2;
|
if (draw >= 2) draw = -2;
|
||||||
if (draw < 0) continue;
|
if (draw < 0) continue;
|
||||||
|
if (draw == 0) bezierPrevious = CalculateBezierPoint(point_a, tangent_a, tangent_b, point_b, (j - 1f) / (float) division);
|
||||||
}
|
}
|
||||||
if (i == length - 2)
|
if (i == length - 2)
|
||||||
Handles.color = gradient.Evaluate((j + 1f) / division);
|
Handles.color = gradient.Evaluate((j + 1f) / division);
|
||||||
Vector2 bezierNext = CalculateBezierPoint(point_a, tangent_a, tangent_b, point_b, j / (float)division);
|
Vector2 bezierNext = CalculateBezierPoint(point_a, tangent_a, tangent_b, point_b, j / (float) division);
|
||||||
DrawAAPolyLineNonAlloc(thickness, bezierPrevious, bezierNext);
|
DrawAAPolyLineNonAlloc(thickness, bezierPrevious, bezierNext);
|
||||||
bezierPrevious = bezierNext;
|
bezierPrevious = bezierNext;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user