Module: Dimensions

Includes:
Apex, Center, Location, Size
Included in:
Rectangle
Defined in:
tomes/spells/geometry/dimensions.rb

Overview

A method for handling some basic properties of a rectangle.

Instance Attribute Summary

Attributes included from Size

#height, #width

Attributes included from Location

#x, #y

Instance Method Summary collapse

Methods included from Center

#horizontal_center, #true_center, #vertical_center

Methods included from Apex

#apex, #apex_x, #apex_y

Methods included from Size

#adjust_size, #size, #size=

Methods included from Location

#adjust_location, #location, #location=

Instance Method Details

#change_dimensions(location, size) ⇒ Void Also known as: set_dimensions

Sets the location and size of a rectangle.

Parameters:

  • location (Array<Integer, Integer>)
  • size (Array<Integer, Integer>)

Returns:

  • (Void)


36
37
38
39
# File 'tomes/spells/geometry/dimensions.rb', line 36

def change_dimensions(location, size)
  set_location location
  set_size size
end

#dimensionsHash

Returns a has with the X and Y coordinates of a rectangle, along with its width and height.

Returns:

  • (Hash)


23
24
25
26
27
28
29
30
# File 'tomes/spells/geometry/dimensions.rb', line 23

def dimensions
  {
    x: x,
    y: y,
    w: width,
    h: height
  }
end

#rectHash

Returns the #dimensions of a rectangle, along with a default border ‘primitive_marker` to help DragonRuby render it.

Returns:

  • (Hash)


17
18
19
# File 'tomes/spells/geometry/dimensions.rb', line 17

def rect
  dimensions.merge({ primitive_marker: :border })
end