struct

Image::Point

Inherits Struct < Value < Object

============================================================================ Geometry Types

Point represents a 2D coordinate on the integer grid.

Points specify positions in images and rectangles. The coordinate system follows standard image conventions: X increases to the right, Y increases downward (origin at top-left).

Points are value types (structs) and support arithmetic operations for easy coordinate manipulation. They're used throughout the image API for positioning, offsets, and size calculations.

Arithmetic operations:

  • Addition/subtraction: Translate coordinates
  • Multiplication/division: Scale coordinates
  • in?(rect): Test if point is inside rectangle

Memory layout: 8 bytes (2 Int32 values)

Example:

origin = Image::Point.new(0, 0)
offset = Image::Point.new(10, 20)
position = origin + offset # Point.new(10, 20)

rect = Image.rect(0, 0, 100, 100)
position.in?(rect) # true

Constructors

new(x : Int32, y : Int32)
Source

Instance methods

*(other : Point) : Point
Source
+(other : Point) : Point
Source
-(other : Point) : Point
Source
/(other : Point) : Point
Source
in?(rect : Rectangle) : Bool

Check if point is inside rectangle (max bounds are exclusive)

Source