Home > OS >  The point within the range of rectangle
The point within the range of rectangle

Time:02-06

In easy English can someone please explain to me this line of code.

public bool IsAt(Point2D pt)
    {
        return (pt.X > Width && pt.X < Width   X && pt.Y > Height && pt.Y < Height   Y);
    }

CodePudding user response:

Return true if the coordinates pt.X, pt.Y are outside a rectangle with width: WIDTH and height: HEIGHT with an origin at coordinates X, Y.

CodePudding user response:

Assuming Width and Height are actually the width and the height of a defined rectangle, then I'd go with the class System.Drawing.Rectangle and use the method Contains() to check if a point is in a rectangle.

Read: https://docs.microsoft.com/en-us/dotnet/api/system.drawing.rectangle.contains?view=net-6.0#system-drawing-rectangle-contains(system-drawing-point)

  •  Tags:  
  • Related