class HexaPDF::Layout::InlineBox
An InlineBox
wraps a regular Box
so that it can be used as an item for a Line
. This enables inline graphics.
The wrapped box must have a fixed size!
Attributes
The wrapped Box
object.
The vertical alignment of the box.
Can be any supported value except :text - see Line
for all possible values.
Public Class Methods
Creates an InlineBox
that wraps a basic Box
. All arguments (except valign
) and the block are passed to Box::create
.
See ::new
for the valign
argument.
# File lib/hexapdf/layout/inline_box.rb, line 51 def self.create(valign: :baseline, **args, &block) new(Box.create(**args, &block), valign: valign) end
Public Instance Methods
Draws the wrapped box. If the box has margins specified, the x and y offsets are correctly adjusted.
# File lib/hexapdf/layout/inline_box.rb, line 89 def draw(canvas, x, y) box.draw(canvas, x + box.style.margin.left, y + box.style.margin.bottom) end
Returns true
if this inline box is just a placeholder without drawing operations.
# File lib/hexapdf/layout/inline_box.rb, line 73 def empty? box.empty? end
Returns the height of the wrapped box plus its top and bottom margins.
# File lib/hexapdf/layout/inline_box.rb, line 83 def height box.height + box.style.margin.top + box.style.margin.bottom end
Returns the width of the wrapped box plus its left and right margins.
# File lib/hexapdf/layout/inline_box.rb, line 78 def width box.width + box.style.margin.left + box.style.margin.right end
The maximum x-coordinate which is equivalent to the width of the inline box.
# File lib/hexapdf/layout/inline_box.rb, line 99 def x_max width end
The minimum x-coordinate which is always 0.
# File lib/hexapdf/layout/inline_box.rb, line 94 def x_min 0 end
The maximum y-coordinate which is equivalent to the height of the inline box.
# File lib/hexapdf/layout/inline_box.rb, line 109 def y_max height end
The minimum y-coordinate which is always 0.
# File lib/hexapdf/layout/inline_box.rb, line 104 def y_min 0 end