public override bool HitTest(PointF point) { PointF[] rect = new PointF[4]; rect[0] = new PointF(Pos.X, Pos.Y); rect[1] = new PointF(Pos.X, Pos.Y + Height); rect[2] = new PointF(Pos.X + Width, Pos.Y + Height); rect[3] = new PointF(Pos.X + Width, Pos.Y); return(CanvasMath.PointInPoly(rect, point)); }
public override bool HitTest(PointF point) { PointF[] poly = new PointF[Points.Count]; int idx = 0; foreach (PointF pathPoint in Points) { poly[idx++] = new PointF(pathPoint.X, pathPoint.Y); } return(CanvasMath.PointInPoly(poly, point)); }
public static bool PointOnLine(PointF start, PointF end, PointF point, float lineWidth) { PointF[] rect = new PointF[4]; if (lineWidth <= 0) { return(false); } if (end.X < start.X) { PointF temp = start; start = end; end = temp; } if (point.X < start.X || point.X > end.X) { return(false); } PointF ortho = new PointF(end.X - start.X, end.Y - start.Y); float len = (float)Math.Sqrt(Math.Pow(ortho.X, 2) + Math.Pow(ortho.Y, 2)); len = Math.Max(1.0F, len); PointF rot = CanvasMath.RotatePoint(ortho, -90); PointF normalized = new PointF(rot.X / len, rot.Y / len); PointF baseVect = new PointF(normalized.X * (lineWidth / 2), normalized.Y * (lineWidth / 2)); rect[0].X = baseVect.X + start.X; rect[0].Y = baseVect.Y + start.Y; rect[3].X = baseVect.X + end.X; rect[3].Y = baseVect.Y + end.Y; rot = CanvasMath.RotatePoint(ortho, +90); normalized = new PointF(rot.X / len, rot.Y / len); baseVect = new PointF(normalized.X * (lineWidth / 2), normalized.Y * (lineWidth / 2)); rect[1].X = baseVect.X + start.X; rect[1].Y = baseVect.Y + start.Y; rect[2].X = baseVect.X + end.X; rect[2].Y = baseVect.Y + end.Y; return(CanvasMath.PointInPoly(rect, point)); }
public override bool HitTest(PointF point) { PointF[] rect = new PointF[4]; float radius = Width / 2; rect[0].X = Pos.X - radius; rect[0].Y = Pos.Y - radius; rect[1].X = Pos.X + radius; rect[1].Y = Pos.Y - radius; rect[2].X = Pos.X + radius; rect[2].Y = Pos.Y + radius; rect[3].X = Pos.X - radius; rect[3].Y = Pos.Y + radius; return(CanvasMath.PointInPoly(rect, point)); }
public override bool HitTest(PointF point) { if (Points.Count < 2) { return(false); } for (int i = 0; i < Points.Count; i++) { if (i == 0) { continue; } if (CanvasMath.PointOnLine(Points[i], Points[i - 1], point, Width)) { return(true); } } return(false); }
public override bool BoxTest(RectangleF rect) { if (Points.Count < 2) { return(false); } for (int i = 0; i < Points.Count; i++) { if (i == 0) { continue; } if (CanvasMath.LineIntersectsRect(Points[i], Points[i - 1], rect)) { return(true); } } return(false); }
public override bool BoxTest(RectangleF rect) { return(CanvasMath.LineIntersectsRect(Pos, PosEnd, rect)); }
public override bool HitTest(PointF point) { return(CanvasMath.PointOnLine(Pos, PosEnd, point, Width)); }