Class: MtgCardMaker::TextBoxLayer

Inherits:
BaseLayer
  • Object
show all
Includes:
LayerInitializer
Defined in:
lib/mtg_card_maker/layers/text_box_layer.rb

Overview

TextBoxLayer is a specialized layer for the rules and flavor text

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:, rules_text:, flavor_text: nil, color: nil, color_scheme: DEFAULT_COLOR_SCHEME) ⇒ TextBoxLayer

Returns a new instance of TextBoxLayer.

Since:

  • 0.1.0



9
10
11
12
13
14
15
# File 'lib/mtg_card_maker/layers/text_box_layer.rb', line 9

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

Instance Attribute Details

#color_schemeObject (readonly)

Since:

  • 0.1.0



7
8
9
# File 'lib/mtg_card_maker/layers/text_box_layer.rb', line 7

def color_scheme
  @color_scheme
end

#flavor_textObject (readonly)

Since:

  • 0.1.0



7
8
9
# File 'lib/mtg_card_maker/layers/text_box_layer.rb', line 7

def flavor_text
  @flavor_text
end

#rules_textObject (readonly)

Since:

  • 0.1.0



7
8
9
# File 'lib/mtg_card_maker/layers/text_box_layer.rb', line 7

def rules_text
  @rules_text
end

Instance Method Details

#renderObject

Render the rules text and flavor text in a text box with a background and highlight

Since:

  • 0.1.0



18
19
20
21
22
23
# File 'lib/mtg_card_maker/layers/text_box_layer.rb', line 18

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

  render_text_box
end