Class: Draught::BoundingBox

Inherits:
Object
  • Object
show all
Includes:
Boxlike
Defined in:
lib/draught/bounding_box.rb

Constant Summary

Constants included from Boxlike

Draught::Boxlike::POSITION_METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Boxlike

#bottom_edge, #centre, #centre_left, #centre_right, #corners, #disjoint?, #include_point?, #left_edge, #lower_centre, #lower_right, #min_gap, #move_to, #overlaps?, #right_edge, #top_edge, #upper_centre, #upper_left, #upper_right

Constructor Details

#initialize(*paths) ⇒ BoundingBox

Returns a new instance of BoundingBox.



10
11
12
# File 'lib/draught/bounding_box.rb', line 10

def initialize(*paths)
  @paths = paths
end

Instance Attribute Details

#pathsObject (readonly)

Returns the value of attribute paths.



8
9
10
# File 'lib/draught/bounding_box.rb', line 8

def paths
  @paths
end

Instance Method Details

#==(other) ⇒ Object



38
39
40
# File 'lib/draught/bounding_box.rb', line 38

def ==(other)
  paths == other.paths
end

#box_typeObject



46
47
48
# File 'lib/draught/bounding_box.rb', line 46

def box_type
  [:container]
end

#containersObject



42
43
44
# File 'lib/draught/bounding_box.rb', line 42

def containers
  []
end

#heightObject



18
19
20
# File 'lib/draught/bounding_box.rb', line 18

def height
  y_max - y_min
end

#lower_leftObject



22
23
24
# File 'lib/draught/bounding_box.rb', line 22

def lower_left
  @lower_left ||= Point.new(x_min, y_min)
end

#transform(transformer) ⇒ Object



30
31
32
# File 'lib/draught/bounding_box.rb', line 30

def transform(transformer)
  self.class.new(*paths.map { |path| path.transform(transformer) })
end

#translate(point) ⇒ Object



26
27
28
# File 'lib/draught/bounding_box.rb', line 26

def translate(point)
  self.class.new(*paths.map { |path| path.translate(point) })
end

#widthObject



14
15
16
# File 'lib/draught/bounding_box.rb', line 14

def width
  x_max - x_min
end

#zero_originObject



34
35
36
# File 'lib/draught/bounding_box.rb', line 34

def zero_origin
  move_to(Point::ZERO)
end