Object
Template methods to support ColumnBox extensions
Low level layout helper that simplifies coordinate math.
See Prawn::Document#bounding_box for a description of what this class is used for.
Absolute bottom y-coordinate of the bottom box
# File lib/prawn/document/bounding_box.rb, line 354 354: def absolute_bottom 355: @y - height 356: end
Absolute bottom-left point of the bounding box
# File lib/prawn/document/bounding_box.rb, line 372 372: def absolute_bottom_left 373: [absolute_left, absolute_bottom] 374: end
Absolute bottom-left point of the bounding box
# File lib/prawn/document/bounding_box.rb, line 378 378: def absolute_bottom_right 379: [absolute_right, absolute_bottom] 380: end
Absolute left x-coordinate of the bounding box
# File lib/prawn/document/bounding_box.rb, line 336 336: def absolute_left 337: @x 338: end
Absolute right x-coordinate of the bounding box
# File lib/prawn/document/bounding_box.rb, line 342 342: def absolute_right 343: @x + width 344: end
Absolute top y-coordinate of the bounding box
# File lib/prawn/document/bounding_box.rb, line 348 348: def absolute_top 349: @y 350: end
Absolute top-left point of the bounding box
# File lib/prawn/document/bounding_box.rb, line 360 360: def absolute_top_left 361: [absolute_left, absolute_top] 362: end
Absolute top-right point of the bounding box
# File lib/prawn/document/bounding_box.rb, line 366 366: def absolute_top_right 367: [absolute_right, absolute_top] 368: end
The translated origin (x,y-height) which describes the location of the bottom left corner of the bounding box
# File lib/prawn/document/bounding_box.rb, line 219 219: def anchor 220: [@x, @y - height] 221: end
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)])
# File lib/prawn/document/bounding_box.rb, line 280 280: def bottom 281: 0 282: end
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
# File lib/prawn/document/bounding_box.rb, line 330 330: def bottom_left 331: [left,bottom] 332: 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
# File lib/prawn/document/bounding_box.rb, line 318 318: def bottom_right 319: [right,bottom] 320: 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.
# File lib/prawn/document/bounding_box.rb, line 392 392: def height 393: return @height if @height 394: @stretched_height = [(absolute_top - @parent.y), @stretched_height.to_f].max 395: end
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
# File lib/prawn/document/bounding_box.rb, line 245 245: def indent(left_padding, &block) 246: @x += left_padding 247: @width -= left_padding 248: yield 249: ensure 250: @x -= left_padding 251: @width += left_padding 252: 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])
# File lib/prawn/document/bounding_box.rb, line 229 229: def left 230: 0 231: end
an alias for absolute_left
# File lib/prawn/document/column_box.rb, line 49 49: def left_side 50: absolute_left 51: end
starts a new page
# File lib/prawn/document/column_box.rb, line 59 59: def move_past_bottom 60: @parent.start_new_page 61: end
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])
# File lib/prawn/document/bounding_box.rb, line 260 260: def right 261: @width 262: end
an alias for absolute_right
# File lib/prawn/document/column_box.rb, line 54 54: def right_side 55: absolute_right 56: end
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.
# File lib/prawn/document/bounding_box.rb, line 402 402: def stretchy? 403: !@height 404: end
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)])
# File lib/prawn/document/bounding_box.rb, line 270 270: def top 271: height 272: end
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
# File lib/prawn/document/bounding_box.rb, line 293 293: def top_left 294: [left,top] 295: 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
# File lib/prawn/document/bounding_box.rb, line 306 306: def top_right 307: [right,top] 308: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.