Parent

Prawn::Document::BoundingBox

Low level layout helper that simplifies coordinate math.

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


Template methods to support ColumnBox extensions

Attributes

document[R]
parent[R]
total_left_padding[R]

The current indentation of the left side of the bounding box.

total_right_padding[R]

The current indentation of the right side of the bounding box.

Public Instance Methods

absolute_bottom() click to toggle source

Absolute bottom y-coordinate of the bottom box

     # File lib/prawn/document/bounding_box.rb, line 392
392:       def absolute_bottom
393:         @y - height
394:       end
absolute_bottom_left() click to toggle source

Absolute bottom-left point of the bounding box

     # File lib/prawn/document/bounding_box.rb, line 410
410:       def absolute_bottom_left
411:         [absolute_left, absolute_bottom]
412:       end
absolute_bottom_right() click to toggle source

Absolute bottom-left point of the bounding box

     # File lib/prawn/document/bounding_box.rb, line 416
416:       def absolute_bottom_right
417:         [absolute_right, absolute_bottom]
418:       end
absolute_left() click to toggle source

Absolute left x-coordinate of the bounding box

     # File lib/prawn/document/bounding_box.rb, line 374
374:       def absolute_left
375:         @x
376:       end
absolute_right() click to toggle source

Absolute right x-coordinate of the bounding box

     # File lib/prawn/document/bounding_box.rb, line 380
380:       def absolute_right
381:         @x + width
382:       end
absolute_top() click to toggle source

Absolute top y-coordinate of the bounding box

     # File lib/prawn/document/bounding_box.rb, line 386
386:       def absolute_top
387:         @y
388:       end
absolute_top_left() click to toggle source

Absolute top-left point of the bounding box

     # File lib/prawn/document/bounding_box.rb, line 398
398:       def absolute_top_left
399:         [absolute_left, absolute_top]
400:       end
absolute_top_right() click to toggle source

Absolute top-right point of the bounding box

     # File lib/prawn/document/bounding_box.rb, line 404
404:       def absolute_top_right
405:         [absolute_right, absolute_top]
406:       end
add_left_padding(left_padding) click to toggle source

Increase the left padding of the bounding box.

     # File lib/prawn/document/bounding_box.rb, line 267
267:       def add_left_padding(left_padding)
268:         @total_left_padding += left_padding
269:         @x += left_padding
270:         @width -= left_padding
271:       end
add_right_padding(right_padding) click to toggle source

Increase the right padding of the bounding box.

     # File lib/prawn/document/bounding_box.rb, line 281
281:       def add_right_padding(right_padding)
282:         @total_right_padding += right_padding
283:         @width -= right_padding
284:       end
anchor() click to toggle source

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 227
227:       def anchor
228:         [@x, @y - height]
229:       end
bottom() click to toggle source

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 318
318:       def bottom
319:         0
320:       end
bottom_left() click to toggle source

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 368
368:       def bottom_left
369:         [left,bottom]
370:       end
bottom_right() click to toggle source

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 356
356:       def bottom_right
357:         [right,bottom]
358:       end
height() click to toggle source

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 430
430:       def height
431:         return @height if @height
432:         @stretched_height = [(absolute_top - @document.y),
433:                              @stretched_height.to_f].max
434:       end
Also aliased as: update_height
indent(left_padding, right_padding = 0, &block) click to toggle source

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

 indent 20, 20 do
   text "indented on both sides"
 end
     # File lib/prawn/document/bounding_box.rb, line 257
257:       def indent(left_padding, right_padding = 0, &block)
258:         add_left_padding(left_padding)
259:         add_right_padding(right_padding)
260:         yield
261:       ensure
262:         @document.bounds.subtract_left_padding(left_padding)
263:         @document.bounds.subtract_right_padding(right_padding)
264:       end
left() click to toggle source

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 237
237:       def left
238:         0
239:       end
left_side() click to toggle source

an alias for absolute_left

     # File lib/prawn/document/bounding_box.rb, line 437
437:       def left_side
438:          absolute_left
439:       end
left_side() click to toggle source

an alias for absolute_left

    # File lib/prawn/document/column_box.rb, line 48
48:       def left_side
49:          absolute_left
50:       end
move_past_bottom() click to toggle source

starts a new page

     # File lib/prawn/document/bounding_box.rb, line 447
447:       def move_past_bottom
448:         @document.start_new_page
449:       end
move_past_bottom() click to toggle source

starts a new page

    # File lib/prawn/document/column_box.rb, line 58
58:       def move_past_bottom
59:          @document.start_new_page
60:       end
right() click to toggle source

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 298
298:       def right
299:         @width
300:       end
right_side() click to toggle source

an alias for absolute_right

    # File lib/prawn/document/column_box.rb, line 53
53:       def right_side
54:          absolute_right
55:       end
right_side() click to toggle source

an alias for absolute_right

     # File lib/prawn/document/bounding_box.rb, line 442
442:       def right_side
443:          absolute_right
444:       end
stretchy?() click to toggle source

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 457
457:       def stretchy?
458:         !@height
459:       end
subtract_left_padding(left_padding) click to toggle source

Decrease the left padding of the bounding box.

     # File lib/prawn/document/bounding_box.rb, line 274
274:       def subtract_left_padding(left_padding)
275:         @total_left_padding -= left_padding
276:         @x -= left_padding
277:         @width += left_padding
278:       end
subtract_right_padding(right_padding) click to toggle source

Decrease the right padding of the bounding box.

     # File lib/prawn/document/bounding_box.rb, line 287
287:       def subtract_right_padding(right_padding)
288:         @total_right_padding -= right_padding
289:         @width += right_padding
290:       end
top() click to toggle source

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 308
308:       def top
309:         height
310:       end
top_left() click to toggle source

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.top_left, bounds.bottom_right)
 end
     # File lib/prawn/document/bounding_box.rb, line 331
331:       def top_left
332:         [left,top]
333:       end
top_right() click to toggle source

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 344
344:       def top_right
345:         [right,top]
346:       end
update_height() click to toggle source
Alias for: height
width() click to toggle source

Width of the bounding box

     # File lib/prawn/document/bounding_box.rb, line 422
422:       def width
423:         @width
424:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.