Class: Sevgi::Graphics::Canvas
- Inherits:
-
Object
- Object
- Sevgi::Graphics::Canvas
- Extended by:
- Forwardable
- Defined in:
- lib/sevgi/graphics/auxilary/canvas.rb
Instance Attribute Summary collapse
-
#dim ⇒ Object
readonly
Returns the value of attribute dim.
-
#inner ⇒ Object
readonly
Returns the value of attribute inner.
-
#margin ⇒ Object
readonly
Returns the value of attribute margin.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #conforming ⇒ Object
-
#initialize(width:, height:, unit: "mm", margins: []) ⇒ Canvas
constructor
A new instance of Canvas.
- #viewbox ⇒ Object
- #viewport ⇒ Object
- #with(*margins) ⇒ Object
Constructor Details
#initialize(width:, height:, unit: "mm", margins: []) ⇒ Canvas
Returns a new instance of Canvas.
14 15 16 17 18 19 20 |
# File 'lib/sevgi/graphics/auxilary/canvas.rb', line 14 def initialize(width:, height:, unit: "mm", margins: []) @dim = Dim[width, height, unit] @margin = Margin[*margins] compute freeze end |
Instance Attribute Details
#dim ⇒ Object (readonly)
Returns the value of attribute dim.
12 13 14 |
# File 'lib/sevgi/graphics/auxilary/canvas.rb', line 12 def dim @dim end |
#inner ⇒ Object (readonly)
Returns the value of attribute inner.
12 13 14 |
# File 'lib/sevgi/graphics/auxilary/canvas.rb', line 12 def inner @inner end |
#margin ⇒ Object (readonly)
Returns the value of attribute margin.
12 13 14 |
# File 'lib/sevgi/graphics/auxilary/canvas.rb', line 12 def margin @margin end |
Class Method Details
.call(arg = Paper.default) ⇒ Object
39 40 41 |
# File 'lib/sevgi/graphics/auxilary/canvas.rb', line 39 def call(arg = Paper.default, *) canvas(arg).with(*) end |
Instance Method Details
#attributes ⇒ Object
22 |
# File 'lib/sevgi/graphics/auxilary/canvas.rb', line 22 def attributes = { **, viewBox: viewbox } |
#conforming ⇒ Object
24 |
# File 'lib/sevgi/graphics/auxilary/canvas.rb', line 24 def conforming(...) = self.class.conforming(self, ...) |
#viewbox ⇒ Object
28 |
# File 'lib/sevgi/graphics/auxilary/canvas.rb', line 28 def viewbox = F.prettify(-margin.left, -margin.top, width, height).join(" ") |
#viewport ⇒ Object
26 |
# File 'lib/sevgi/graphics/auxilary/canvas.rb', line 26 def = { width: "#{width}#{unit}", height: "#{height}#{unit}" } |
#with(*margins) ⇒ Object
30 |
# File 'lib/sevgi/graphics/auxilary/canvas.rb', line 30 def with(*margins) = margins.empty? ? self : self.class.new(**dim.to_h, margins:) |