Class: Charta::BoundingBox
- Inherits:
-
Object
- Object
- Charta::BoundingBox
- Defined in:
- lib/charta/bounding_box.rb
Instance Attribute Summary collapse
-
#x_max ⇒ Object
readonly
Returns the value of attribute x_max.
-
#x_min ⇒ Object
readonly
Returns the value of attribute x_min.
-
#y_max ⇒ Object
readonly
Returns the value of attribute y_max.
-
#y_min ⇒ Object
readonly
Returns the value of attribute y_min.
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(y_min, x_min, y_max, x_max) ⇒ BoundingBox
constructor
A new instance of BoundingBox.
- #svg_view_box ⇒ Object
- #to_a ⇒ Object
- #to_bbox_string ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(y_min, x_min, y_max, x_max) ⇒ BoundingBox
Returns a new instance of BoundingBox.
5 6 7 8 9 10 |
# File 'lib/charta/bounding_box.rb', line 5 def initialize(y_min, x_min, y_max, x_max) @y_min = y_min @x_min = x_min @y_max = y_max @x_max = x_max end |
Instance Attribute Details
#x_max ⇒ Object (readonly)
Returns the value of attribute x_max.
3 4 5 |
# File 'lib/charta/bounding_box.rb', line 3 def x_max @x_max end |
#x_min ⇒ Object (readonly)
Returns the value of attribute x_min.
3 4 5 |
# File 'lib/charta/bounding_box.rb', line 3 def x_min @x_min end |
#y_max ⇒ Object (readonly)
Returns the value of attribute y_max.
3 4 5 |
# File 'lib/charta/bounding_box.rb', line 3 def y_max @y_max end |
#y_min ⇒ Object (readonly)
Returns the value of attribute y_min.
3 4 5 |
# File 'lib/charta/bounding_box.rb', line 3 def y_min @y_min end |
Instance Method Details
#height ⇒ Object
16 17 18 |
# File 'lib/charta/bounding_box.rb', line 16 def height @y_max - @y_min end |
#svg_view_box ⇒ Object
20 21 22 |
# File 'lib/charta/bounding_box.rb', line 20 def svg_view_box [x_min, y_min, width, height] end |
#to_a ⇒ Object
24 25 26 |
# File 'lib/charta/bounding_box.rb', line 24 def to_a [[@y_min, @x_min], [@y_max, @x_max]] end |
#to_bbox_string ⇒ Object
28 29 30 |
# File 'lib/charta/bounding_box.rb', line 28 def to_bbox_string "#{@x_min}, #{@y_min}, #{x_max}, #{y_max}" end |
#width ⇒ Object
12 13 14 |
# File 'lib/charta/bounding_box.rb', line 12 def width @x_max - @x_min end |