Class: HexaPDF::Layout::Style::Border
- Inherits:
-
Object
- Object
- HexaPDF::Layout::Style::Border
- Defined in:
- lib/hexapdf/layout/style.rb
Overview
Represents the border of a rectangular area.
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
The colors of each edge.
-
#style ⇒ Object
readonly
The styles of each edge.
-
#width ⇒ Object
readonly
The widths of each edge.
Instance Method Summary collapse
-
#draw(canvas, x, y, w, h) ⇒ Object
Draws the border onto the canvas, inside the rectangle (x, y, w, h).
-
#initialize(width: 0, color: 0, style: :solid) ⇒ Border
constructor
Creates a new border style.
-
#initialize_copy(other) ⇒ Object
Duplicates a Border object’s properties.
-
#none? ⇒ Boolean
Returns
true
if there is no border.
Constructor Details
#initialize(width: 0, color: 0, style: :solid) ⇒ Border
Creates a new border style. All arguments can be set to any value that a Quad can process.
210 211 212 213 214 |
# File 'lib/hexapdf/layout/style.rb', line 210 def initialize(width: 0, color: 0, style: :solid) @width = Quad.new(width) @color = Quad.new(color) @style = Quad.new(style) end |
Instance Attribute Details
#color ⇒ Object (readonly)
The colors of each edge. See Quad.
204 205 206 |
# File 'lib/hexapdf/layout/style.rb', line 204 def color @color end |
#style ⇒ Object (readonly)
The styles of each edge. See Quad.
207 208 209 |
# File 'lib/hexapdf/layout/style.rb', line 207 def style @style end |
#width ⇒ Object (readonly)
The widths of each edge. See Quad.
201 202 203 |
# File 'lib/hexapdf/layout/style.rb', line 201 def width @width end |
Instance Method Details
#draw(canvas, x, y, w, h) ⇒ Object
Draws the border onto the canvas, inside the rectangle (x, y, w, h).
230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/hexapdf/layout/style.rb', line 230 def draw(canvas, x, y, w, h) return if none? canvas.save_graphics_state do if width.simple? && color.simple? && style.simple? draw_simple_border(canvas, x, y, w, h) else draw_complex_border(canvas, x, y, w, h) end end end |
#initialize_copy(other) ⇒ Object
Duplicates a Border object’s properties.
217 218 219 220 221 222 |
# File 'lib/hexapdf/layout/style.rb', line 217 def initialize_copy(other) super @width = @width.dup @color = @color.dup @style = @style.dup end |
#none? ⇒ Boolean
Returns true
if there is no border.
225 226 227 |
# File 'lib/hexapdf/layout/style.rb', line 225 def none? width.simple? && width.top == 0 end |