CrImage::Point
Inherits Struct / Value / Object
A Point represents an (x, y) coordinate on the integer grid.
Coordinate system:
- X-axis increases to the right
- Y-axis increases downward
- A Point is neither a pixel nor a grid square
- A Point has no intrinsic width, height, or color
Example:
p1 = CrImage::Point.new(10, 20)
p2 = CrImage.point(30, 40) # Factory method
p3 = p1 + p2 # Point arithmetic
Constructors
new(x : Int32, y : Int32)
SourceClass methods
zero
SourceInstance methods
*(o : Point)
Source+(o : Point)
Source-(o : Point)
Source/(o : Point)
Sourceeq(o : Point)
Sourcein(r : Rectangle) : Bool
Reports whether this point is inside the given rectangle.
A point is considered inside if it satisfies:
r.min.x <= x < r.max.xr.min.y <= y < r.max.y
Note: The max bounds are exclusive.
mod(r : Rectangle) : Point
Returns the point q in Rectangle r such that p.x - q.x is a multiple of r's width and p.y - q.y is a multiple of r's height.
This is useful for wrapping coordinates within a rectangular region, similar to modulo arithmetic but for 2D coordinates.
x=(x : Int32)
Sourcey=(y : Int32)
Source