public static bool Contains(this Rect rect, Vector2 start, Vector2 startDir, Vector2 end, Vector3 endDir, int tesselationSegments) { bool contains = false; List <KeyValuePair <Vector2, Vector2> > segments = GUILineHelper.TesselateLine(start, startDir, end, endDir, 10); foreach (KeyValuePair <Vector2, Vector2> segment in segments) { if (rect.Contains(segment.Key, segment.Value) == true) { contains = true; break; } } return(contains); }
public static void DrawRect(Rect r, Color col) { //SR TODO Stuff a rect draw into the LineHelper clas Vector2 itemStartLine = new Vector2(r.x, r.y); Vector2 itemEndLine = new Vector2(r.x + r.width, r.y); GUILineHelper.DrawLine(itemStartLine, itemEndLine, col); // itemStartLine = new Vector2(r.x + r.width, r.y); itemEndLine = new Vector2(r.x + r.width, r.y + r.height); GUILineHelper.DrawLine(itemStartLine, itemEndLine, col); // itemStartLine = new Vector2(r.x + r.width, r.y + r.height); itemEndLine = new Vector2(r.x, r.y + r.height); GUILineHelper.DrawLine(itemStartLine, itemEndLine, col); // itemStartLine = new Vector2(r.x, r.y + r.height); itemEndLine = new Vector2(r.x, r.y); GUILineHelper.DrawLine(itemStartLine, itemEndLine, col); // }
public static void DrawCurve(Vector2 start, Vector2 startDir, Vector2 end, Vector3 endDir, int segments, Color c) { Vector2 last = start; for (int i = 0; i < segments; ++i) { float a = ((float)i + 1.0f) / (float)segments; Vector2 next = CubicInterp(start, startDir, end, endDir, a); GUILineHelper.DrawLine(last, next, c); //Drawing.DrawLine( last, next, c, 2.0f, true ); // If this is the last section, use its direction to draw the arrowhead. if ((i == segments - 1)) { Vector2 dir = (next - last); dir.Normalize(); DrawArrowhead(last, dir, c); } last = next; } }