MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / DrawConnection

Method DrawConnection

Source/Editor/Surface/Elements/OutputBox.cs:51–82  ·  view source on GitHub ↗

Draws the connection between two boxes. The Visject surface style. The start location. The end location. The connection color. The connection thickness.

(SurfaceStyle style, ref Float2 start, ref Float2 end, ref Color color, float thickness = DefaultConnectionThickness)

Source from the content-addressed store, hash-verified

49 /// <param name="color">The connection color.</param>
50 /// <param name="thickness">The connection thickness.</param>
51 public static void DrawConnection(SurfaceStyle style, ref Float2 start, ref Float2 end, ref Color color, float thickness = DefaultConnectionThickness)
52 {
53 if (style.DrawConnection != null)
54 {
55 style.DrawConnection(start, end, color, thickness);
56 return;
57 }
58
59 float connectionOffset = Mathf.Max(0f, DefaultConnectionOffset * (1 - Editor.Instance.Options.Options.Interface.ConnectionCurvature));
60 Float2 offsetStart = new Float2(start.X + connectionOffset, start.Y);
61 Float2 offsetEnd = new Float2(end.X - connectionOffset, end.Y);
62
63 // Calculate control points
64 CalculateBezierControlPoints(offsetStart, offsetEnd, out var control1, out var control2);
65
66 // Draw offset lines only if necessary
67 if (connectionOffset >= float.Epsilon)
68 {
69 Render2D.DrawLine(start, offsetStart, color, thickness);
70 Render2D.DrawLine(offsetEnd, end, color, thickness);
71 }
72
73 // Draw line
74 Render2D.DrawBezier(offsetStart, control1, control2, offsetEnd, color, thickness);
75
76 /*
77 // Debug drawing control points
78 var bSize = new Float2(4, 4);
79 Render2D.FillRectangle(new Rectangle(control1 - bSize * 0.5f, bSize), Color.Blue);
80 Render2D.FillRectangle(new Rectangle(control2 - bSize * 0.5f, bSize), Color.Gold);
81 */
82 }
83
84 private static void CalculateBezierControlPoints(Float2 start, Float2 end, out Float2 control1, out Float2 control2)
85 {

Callers 3

DrawInputBracketsMethod · 0.80
DrawConnectingLineMethod · 0.80
DrawConnectingLineMethod · 0.80

Calls 3

MaxMethod · 0.45
DrawLineMethod · 0.45
DrawBezierMethod · 0.45

Tested by

no test coverage detected