Class: HexaPDF::Layout::Frame::FitResult
- Inherits:
-
Object
- Object
- HexaPDF::Layout::Frame::FitResult
- Defined in:
- lib/hexapdf/layout/frame.rb
Overview
Stores the result of fitting a box in a Frame.
Instance Attribute Summary collapse
-
#available_height ⇒ Object
The available height in the frame for this particular box.
-
#available_width ⇒ Object
The available width in the frame for this particular box.
-
#box ⇒ Object
The box that was fitted into the frame.
-
#mask ⇒ Object
The rectangle (a Geom2D::Polygon object) that will be removed from the frame when drawing the box.
-
#x ⇒ Object
The horizontal position where the box will be drawn.
-
#y ⇒ Object
The vertical position where the box will be drawn.
Instance Method Summary collapse
-
#draw(canvas) ⇒ Object
Draws the #box onto the canvas at (#x, #y).
-
#initialize(box) ⇒ FitResult
constructor
Initialize the result object for the given box.
-
#success! ⇒ Object
Marks the fitting status as success.
-
#success? ⇒ Boolean
Returns
trueif fitting was successful.
Constructor Details
#initialize(box) ⇒ FitResult
Initialize the result object for the given box.
114 115 116 117 118 119 |
# File 'lib/hexapdf/layout/frame.rb', line 114 def initialize(box) @box = box @available_width = 0 @available_height = 0 @success = false end |
Instance Attribute Details
#available_height ⇒ Object
The available height in the frame for this particular box.
107 108 109 |
# File 'lib/hexapdf/layout/frame.rb', line 107 def available_height @available_height end |
#available_width ⇒ Object
The available width in the frame for this particular box.
104 105 106 |
# File 'lib/hexapdf/layout/frame.rb', line 104 def available_width @available_width end |
#box ⇒ Object
The box that was fitted into the frame.
95 96 97 |
# File 'lib/hexapdf/layout/frame.rb', line 95 def box @box end |
#mask ⇒ Object
The rectangle (a Geom2D::Polygon object) that will be removed from the frame when drawing the box.
111 112 113 |
# File 'lib/hexapdf/layout/frame.rb', line 111 def mask @mask end |
#x ⇒ Object
The horizontal position where the box will be drawn.
98 99 100 |
# File 'lib/hexapdf/layout/frame.rb', line 98 def x @x end |
#y ⇒ Object
The vertical position where the box will be drawn.
101 102 103 |
# File 'lib/hexapdf/layout/frame.rb', line 101 def y @y end |
Instance Method Details
#draw(canvas) ⇒ Object
Draws the #box onto the canvas at (#x, #y).
The configuration option “debug” can be used to add visual debug output with respect to box placement.
135 136 137 138 139 140 141 142 143 144 |
# File 'lib/hexapdf/layout/frame.rb', line 135 def draw(canvas) if canvas.context.document.config['debug'] canvas.save_graphics_state do canvas.fill_color("green").stroke_color("darkgreen"). opacity(fill_alpha: 0.1, stroke_alpha: 0.2). draw(:geom2d, object: mask, path_only: true).fill_stroke end end box.draw(canvas, x, y) end |
#success! ⇒ Object
Marks the fitting status as success.
122 123 124 |
# File 'lib/hexapdf/layout/frame.rb', line 122 def success! @success = true end |
#success? ⇒ Boolean
Returns true if fitting was successful.
127 128 129 |
# File 'lib/hexapdf/layout/frame.rb', line 127 def success? @success end |