Class: MtgCardMaker::TextBoxLayer
- 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
Instance Attribute Summary collapse
- #color_scheme ⇒ Object readonly
- #flavor_text ⇒ Object readonly
- #rules_text ⇒ Object readonly
Attributes inherited from BaseLayer
#color, #height, #template, #width, #x, #y
Instance Method Summary collapse
-
#initialize(dimensions:, rules_text:, flavor_text: nil, color: nil, color_scheme: DEFAULT_COLOR_SCHEME) ⇒ TextBoxLayer
constructor
A new instance of TextBoxLayer.
-
#render ⇒ Object
Render the rules text and flavor text in a text box with a background and highlight.
Methods inherited from BaseLayer
Constructor Details
#initialize(dimensions:, rules_text:, flavor_text: nil, color: nil, color_scheme: DEFAULT_COLOR_SCHEME) ⇒ TextBoxLayer
Returns a new instance of TextBoxLayer.
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_scheme ⇒ Object (readonly)
7 8 9 |
# File 'lib/mtg_card_maker/layers/text_box_layer.rb', line 7 def color_scheme @color_scheme end |
#flavor_text ⇒ Object (readonly)
7 8 9 |
# File 'lib/mtg_card_maker/layers/text_box_layer.rb', line 7 def flavor_text @flavor_text end |
#rules_text ⇒ Object (readonly)
7 8 9 |
# File 'lib/mtg_card_maker/layers/text_box_layer.rb', line 7 def rules_text @rules_text end |
Instance Method Details
#render ⇒ Object
Render the rules text and flavor text in a text box with a background and highlight
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 |