Class: MtgCardMaker::NameLayer

Inherits:
BaseLayer show all
Includes:
LayerInitializer
Defined in:
lib/mtg_card_maker/layers/name_layer.rb

Overview

NameLayer is a specialized layer This is the area that surrounds the name and cost of the card

Since:

  • 0.1.0

Instance Attribute Summary collapse

Attributes inherited from BaseLayer

#color, #height, #template, #width, #x, #y

Instance Method Summary collapse

Methods inherited from BaseLayer

#svg

Constructor Details

#initialize(dimensions:, name:, cost:, color: nil, color_scheme: DEFAULT_COLOR_SCHEME) ⇒ NameLayer

Returns a new instance of NameLayer.

Since:

  • 0.1.0



12
13
14
15
16
17
18
# File 'lib/mtg_card_maker/layers/name_layer.rb', line 12

def initialize(dimensions:, name:, cost:, color: nil, color_scheme: DEFAULT_COLOR_SCHEME)
  frame_color = initialize_layer_color(color, color_scheme, :background_color)
  super(dimensions: dimensions, color: frame_color)
  @name = name
  @cost = cost
  @color_scheme = color_scheme
end

Instance Attribute Details

#color_schemeObject (readonly)

Since:

  • 0.1.0



10
11
12
# File 'lib/mtg_card_maker/layers/name_layer.rb', line 10

def color_scheme
  @color_scheme
end

#costObject (readonly)

Since:

  • 0.1.0



10
11
12
# File 'lib/mtg_card_maker/layers/name_layer.rb', line 10

def cost
  @cost
end

#nameObject (readonly)

Since:

  • 0.1.0



10
11
12
# File 'lib/mtg_card_maker/layers/name_layer.rb', line 10

def name
  @name
end

Instance Method Details

#renderObject

Since:

  • 0.1.0



20
21
22
23
24
25
26
27
28
29
# File 'lib/mtg_card_maker/layers/name_layer.rb', line 20

def render
  # Ensure gradients are defined for this color scheme
  SvgGradientService.define_all_gradients(svg, color_scheme)

  svg.g do
    render_name_area
    render_card_name
    render_mana_cost if cost && !cost.empty?
  end
end