Class: Tuile::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/tuile/point.rb,
sig/tuile.rbs

Overview

A point with x and y integer coordinates, both 0-based.

Constant Summary collapse

ZERO =

(0, 0), named for the value rather than for a role. Every coordinate space has an origin, and Canvas#origin is a different point — where a canvas's zero lands on its backend, which is rarely this one.

Returns:

new(0, 0)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#x ⇒ Integer (readonly)

@return — x coordinate, 0-based.

Returns:

  • (Integer)


10
11
12
13
14
15
16
17
18
19
# File 'lib/tuile/point.rb', line 10

class Point < Data.define(:x, :y)
  # @return [String]
  def to_s = "#{x},#{y}"

  # `(0, 0)`, named for the value rather than for a role. Every coordinate
  # space has an origin, and {Canvas#origin} is a *different* point — where a
  # canvas's zero lands on its backend, which is rarely this one.
  # @return [Point]
  ZERO = new(0, 0)
end

#y ⇒ Integer (readonly)

@return — y coordinate, 0-based.

Returns:

  • (Integer)


10
11
12
13
14
15
16
17
18
19
# File 'lib/tuile/point.rb', line 10

class Point < Data.define(:x, :y)
  # @return [String]
  def to_s = "#{x},#{y}"

  # `(0, 0)`, named for the value rather than for a role. Every coordinate
  # space has an origin, and {Canvas#origin} is a *different* point — where a
  # canvas's zero lands on its backend, which is rarely this one.
  # @return [Point]
  ZERO = new(0, 0)
end

Instance Method Details

#to_s ⇒ String

Returns:

  • (String)


12
# File 'lib/tuile/point.rb', line 12

def to_s = "#{x},#{y}"