Class | Prawn::Document::BoundingBox
In: | lib/prawn/document/column_box.rb lib/prawn/document/bounding_box.rb
Parent: | Object

Low level layout helper that simplifies coordinate math.

See Prawn::Document#bounding_box for a description of what this class is used for.

### Methods

absolute_bottom absolute_bottom_left absolute_bottom_right absolute_left absolute_right absolute_top absolute_top_left absolute_top_right anchor bottom bottom_left bottom_right height indent left left_side move_past_bottom right right_side stretchy? top top_left top_right update_height width

### Attributes

parent | [R] |

### Public Instance methods

absolute_bottom()

Absolute bottom y-coordinate of the bottom box

absolute_bottom_left()

Absolute bottom-left point of the bounding box

absolute_bottom_right()

Absolute bottom-left point of the bounding box

absolute_left()

Absolute left x-coordinate of the bounding box

absolute_right()

Absolute right x-coordinate of the bounding box

absolute_top()

Absolute top y-coordinate of the bounding box

absolute_top_left()

Absolute top-left point of the bounding box

absolute_top_right()

Absolute top-right point of the bounding box

anchor()

The translated origin (x,y-height) which describes the location of the bottom left corner of the bounding box

bottom()

Relative bottom y-coordinate of the bounding box (Always 0)

Example, position some text 3 pts from the bottom of the containing box:

     draw_text('hello', :at => [0, (bounds.bottom + 3)])

bottom_left()

Relative bottom-left point of the bounding box

Example, draw a line along the left hand side of the page:

     stroke do
       line(bounds.bottom_left, bounds.top_left)
     end

bottom_right()

Relative bottom-right point of the bounding box

Example, draw a line along the right hand side of the page:

     stroke do
       line(bounds.bottom_right, bounds.top_right)
     end

height()

Height of the bounding box. If the box is ‘stretchy’ (unspecified height attribute), height is calculated as the distance from the top of the box to the current drawing position.

indent(left_padding) {|| ...}

Temporarily adjust the @x coordinate to allow for left_padding

Example:

     indent 20 do
        text "20 points in"
        indent 30 do
          text "50 points in"
        end
      end

left()

Relative left x-coordinate of the bounding box. (Always 0)

Example, position some text 3 pts from the left of the containing box:

     draw_text('hello', :at => [(bounds.left + 3), 0])

left_side()

an alias for absolute_left

move_past_bottom()

starts a new page

right()

Relative right x-coordinate of the bounding box. (Equal to the box width)

Example, position some text 3 pts from the right of the containing box:

     draw_text('hello', :at => [(bounds.right - 3), 0])

right_side()

an alias for absolute_right

stretchy?()

Returns `false` when the box has a defined height, `true` when the height is being calculated on the fly based on the current vertical position.

top()

Relative top y-coordinate of the bounding box. (Equal to the box height)

Example, position some text 3 pts from the top of the containing box:

     draw_text('hello', :at => [0, (bounds.top - 3)])

top_left()

Relative top-left point of the bounding_box

Example, draw a line from the top left of the box diagonally to the bottom right:

     stroke do
       line(bounds., bounds.bottom_right)
     end

top_right()

Relative top-right point of the bounding box

Example, draw a line from the top_right of the box diagonally to the bottom left:

     stroke do
       line(bounds.top_right, bounds.bottom_left)
     end

update_height()

Alias for height

width()

Width of the bounding box

[Validate]