Module: Center

Included in:
Dimensions
Defined in:
tomes/spells/geometry/center.rb

Overview

A module with methods that calculate various center points on a rectangle.

Instance Method Summary collapse

Instance Method Details

#horizontal_centerObject Also known as: center_x

The horizontal center coordinate.

Returns:

  • Integer



18
19
20
# File 'tomes/spells/geometry/center.rb', line 18

def horizontal_center
  x + (width / 2)
end

#true_centerArray<Integer, Integer> Also known as: center, center_point

Calculates the vertical and horizontal center and returns that point as an array.

Returns:

  • (Array<Integer, Integer>)


10
11
12
# File 'tomes/spells/geometry/center.rb', line 10

def true_center
  [horizontal_center, vertical_center]
end

#vertical_centerObject Also known as: center_y

The vertical center coordinate.

Returns:

  • Integer



25
26
27
# File 'tomes/spells/geometry/center.rb', line 25

def vertical_center
  y + (height / 2)
end