Class: MtgCardMaker::BaseLayer Abstract
- Inherits:
-
Object
- Object
- MtgCardMaker::BaseLayer
- Defined in:
- lib/mtg_card_maker.rb
Overview
Subclasses must implement the #render method
Base class for all card layers that provides common attributes and rendering interface. All layer classes (frames, text areas, art) inherit from this base class and implement their own specific rendering logic.
Direct Known Subclasses
ArtLayer, BorderLayer, FrameLayer, NameLayer, PowerLayer, TextBoxLayer, TypeLineLayer
Instance Attribute Summary collapse
-
#color ⇒ String
readonly
The color of the layer.
-
#height ⇒ Integer
readonly
The height of the layer.
-
#template ⇒ Template?
The template instance this layer belongs to.
-
#width ⇒ Integer
readonly
The width of the layer.
-
#x ⇒ Integer
readonly
The x-coordinate of the layer.
-
#y ⇒ Integer
readonly
The y-coordinate of the layer.
Instance Method Summary collapse
-
#initialize(dimensions:, color: 'white') ⇒ BaseLayer
constructor
Initialize a new layer with the given dimensions and color.
-
#render ⇒ Object
abstract
Render the layer to the SVG canvas.
-
#svg ⇒ Victor::SVG?
Access the SVG canvas through the template.
Constructor Details
#initialize(dimensions:, color: 'white') ⇒ BaseLayer
Initialize a new layer with the given dimensions and color
92 93 94 95 96 97 98 99 |
# File 'lib/mtg_card_maker.rb', line 92 def initialize(dimensions:, color: 'white') @x = dimensions[:x] @y = dimensions[:y] @width = dimensions[:width] @height = dimensions[:height] @color = color @template = nil end |
Instance Attribute Details
#color ⇒ String (readonly)
Returns the color of the layer.
82 83 84 |
# File 'lib/mtg_card_maker.rb', line 82 def color @color end |
#height ⇒ Integer (readonly)
Returns the height of the layer.
79 80 81 |
# File 'lib/mtg_card_maker.rb', line 79 def height @height end |
#template ⇒ Template?
Returns the template instance this layer belongs to.
67 68 69 |
# File 'lib/mtg_card_maker.rb', line 67 def template @template end |
#width ⇒ Integer (readonly)
Returns the width of the layer.
76 77 78 |
# File 'lib/mtg_card_maker.rb', line 76 def width @width end |
#x ⇒ Integer (readonly)
Returns the x-coordinate of the layer.
70 71 72 |
# File 'lib/mtg_card_maker.rb', line 70 def x @x end |
#y ⇒ Integer (readonly)
Returns the y-coordinate of the layer.
73 74 75 |
# File 'lib/mtg_card_maker.rb', line 73 def y @y end |
Instance Method Details
#render ⇒ Object
Subclasses must implement this method
Render the layer to the SVG canvas
105 106 107 |
# File 'lib/mtg_card_maker.rb', line 105 def render raise NotImplementedError, "Subclasses must implement the 'render' method." end |
#svg ⇒ Victor::SVG?
Access the SVG canvas through the template
112 113 114 |
# File 'lib/mtg_card_maker.rb', line 112 def svg @template&.instance_variable_get(:@svg) end |