class ChunkyPNG::Point

@see ChunkyPNG.Point
bounds checking that make it easier to work with coordinates.
This class implements some basic methods to handle comparison, the splat operator and
Simple class that represents a point on a canvas using an x and y coordinate.

def <=>(other)

Returns:
  • (-1, 0, 1) - -1 If this point comes before the other one, 1

Parameters:
  • other (ChunkyPNG::Point) -- The point to compare this point with.
def <=>(other)
  (y <=> other.y) == 0 ? x <=> other.x : y <=> other.y
end

def eql?(other)

Returns:
  • (true, false) - true iff the x and y coordinates match
def eql?(other)
  other.x == x && other.y == y
end

def initialize(x, y)

Parameters:
  • y (Integer, :to_i) -- The y-coordinate.
  • x (Integer, :to_i) -- The x-coordinate.
def initialize(x, y)
  @x, @y = x.to_i, y.to_i
end

def to_a

Returns:
  • (Array) - A 2-element array, i.e. [x, y].
def to_a
  [x, y]
end

def within_bounds?(*dimension_like)

Returns:
  • (true, false) - true iff the x and y coordinate fall width the width

Parameters:
  • dimension_like (ChunkyPNG::Dimension, ...) -- The dimension of which the bounds
def within_bounds?(*dimension_like)
  ChunkyPNG::Dimension(*dimension_like).include?(self)
end