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

Attributes

parent  [R] 

Public Instance methods

Absolute bottom y-coordinate of the bottom box

Absolute bottom-left point of the bounding box

Absolute bottom-left point of the bounding box

Absolute left x-coordinate of the bounding box

Absolute right x-coordinate of the bounding box

Absolute top y-coordinate of the bounding box

Absolute top-left point of the bounding box

Absolute top-right point of the bounding box

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

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)])

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

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 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.

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

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])

starts a new page

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])

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.

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)])

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

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 of the bounding box

[Validate]