public static bool segment_rect_intersection(Rect bounds, Drawing_tc1.point_class p) { float num = p.p2.x - p.p1.x; float num2 = 0f; Drawing_tc1.clip_class clip_class = new Drawing_tc1.clip_class((float)0, 1f); int arg_173_0; if (Drawing_tc1.clip_test(-num, p.p1.x - bounds.xMin, clip_class) && Drawing_tc1.clip_test(num, bounds.xMax - p.p1.x, clip_class)) { num2 = p.p2.y - p.p1.y; if (Drawing_tc1.clip_test(-num2, p.p1.y - bounds.yMin, clip_class) && Drawing_tc1.clip_test(num2, bounds.yMax - p.p1.y, clip_class)) { if (clip_class.u2 < 1f) { p.p2.x = p.p1.x + clip_class.u2 * num; p.p2.y = p.p1.y + clip_class.u2 * num2; } if (clip_class.u1 > (float)0) { p.p1.x = p.p1.x + clip_class.u1 * num; p.p1.y = p.p1.y + clip_class.u1 * num2; } arg_173_0 = 1; return(arg_173_0 != 0); } } arg_173_0 = 0; return(arg_173_0 != 0); }
public static void DrawLine(Vector2 start, Vector2 end, Color color, float width) { if (!RuntimeServices.EqualityOperator(Event.current, null)) { if (Event.current.type == EventType.Repaint) { Drawing_tc1.point_class point_class = new Drawing_tc1.point_class(start, end); Drawing_tc1.CreateMaterial(); Drawing_tc1.lineMaterial.SetPass(0); Vector3 vector = default(Vector3); Vector3 vector2 = default(Vector3); if (width == (float)1) { GL.Begin(1); GL.Color(color); vector = new Vector3(start.x, start.y, (float)0); vector2 = new Vector3(end.x, end.y, (float)0); GL.Vertex(vector); GL.Vertex(vector2); } else { GL.Begin(7); GL.Color(color); vector = new Vector3(end.y, start.x, (float)0); vector2 = new Vector3(start.y, end.x, (float)0); Vector3 b = (vector - vector2).normalized * width / 2f; Vector3 a = new Vector3(start.x, start.y, (float)0); Vector3 a2 = new Vector3(end.x, end.y, (float)0); GL.Vertex(a - b); GL.Vertex(a + b); GL.Vertex(a2 + b); GL.Vertex(a2 - b); } GL.End(); } } }