public Highlight CheckHighlight(Vector2D pos, float scale) { float distance = float.MaxValue; float d; Highlight highlight = Highlight.None; // Find a line to highlight foreach (Highlight h in (Highlight[])Enum.GetValues(typeof(Highlight))) { if (h >= Highlight.OuterLeft && h <= Highlight.OuterBottom) { d = Line2D.GetDistanceToLine(lines[h].v1, lines[h].v2, pos, true); if (d <= BuilderModes.BuilderPlug.Me.HighlightRange / scale && d < distance) { distance = d; highlight = h; } } } distance = float.MaxValue; // Find a corner to highlight foreach (Highlight h in (Highlight[])Enum.GetValues(typeof(Highlight))) { if (h >= Highlight.OuterTopLeft && h <= Highlight.OuterBottomRight) { d = Vector2D.Distance(pos, points[h]); if (d <= BuilderModes.BuilderPlug.Me.HighlightRange / scale && d < distance) { distance = d; highlight = h; } } } if (highlight != Highlight.None) { return(highlight); } if (OuterLeft < pos.x && OuterRight > pos.x && OuterTop > pos.y && OuterBottom < pos.y) { return(Highlight.Body); } return(Highlight.None); }
public float GetDistanceToLine(LuaVector2D p, bool bounded) { return(l2d.GetDistanceToLine(p.vec, bounded)); }
public float GetDistanceToLine(Vector2 p, bool bounded) { return(Line2D.GetDistanceToLine(v1, v2, p, bounded)); }