Class: MtgCardMaker::BorderLayer

Inherits:
BaseLayer show all
Includes:
LayerInitializer, MetallicRenderer
Defined in:
lib/mtg_card_maker/layers/border_layer.rb

Overview

BorderLayer is a specialized layer for the border of the card. It renders the outermost border of the card and supports four color options: white, black, silver (colorless), and gold. The layer includes QR codes and copyright text at the bottom.

Examples:

layer = MtgCardMaker::BorderLayer.new(
  dimensions: { x: 0, y: 0, width: 630, height: 880 },
  color: :gold,
  mask_id: 'artWindowMask'
)
layer.render

Since:

  • 0.1.0

Constant Summary collapse

SUPPORTED_COLORS =

Supported colors for the border

Returns:

  • (Hash)

    the supported color mappings

Since:

  • 0.1.0

{
  white: '#EEE',
  black: '#000',
  silver: :colorless,
  gold: :gold
}.freeze

Instance Attribute Summary collapse

Attributes inherited from BaseLayer

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

Instance Method Summary collapse

Methods included from MetallicRenderer

#render_metallic_elements

Methods inherited from BaseLayer

#svg

Constructor Details

#initialize(dimensions:, color: :white, mask_id: 'artWindowMask') ⇒ BorderLayer

Initialize a new border layer

Parameters:

  • dimensions (Hash)

    the layer dimensions

  • color (Symbol) (defaults to: :white)

    the frame color (default: :white)

  • mask_id (String) (defaults to: 'artWindowMask')

    the mask ID for art window (default: 'artWindowMask')

Options Hash (dimensions:):

  • :x (Integer)

    the x-coordinate

  • :y (Integer)

    the y-coordinate

  • :width (Integer)

    the width

  • :height (Integer)

    the height

Raises:

  • (ArgumentError)

    if the color is not supported

Since:

  • 0.1.0



49
50
51
52
53
54
55
56
57
# File 'lib/mtg_card_maker/layers/border_layer.rb', line 49

def initialize(dimensions:, color: :white, mask_id: 'artWindowMask')
  @color = color.to_sym
  validate_color!

  @mask_id = mask_id
  @icon_service = IconService.new
  @color_scheme = ColorScheme.new(color_key_for(@color))
  super(dimensions: dimensions, color: @color)
end

Instance Attribute Details

#color_schemeColorScheme (readonly)

Returns the color scheme for this layer.

Returns:

Since:

  • 0.1.0



25
26
27
# File 'lib/mtg_card_maker/layers/border_layer.rb', line 25

def color_scheme
  @color_scheme
end

#mask_idString (readonly)

Returns the mask ID for the art window.

Returns:

  • (String)

    the mask ID for the art window

Since:

  • 0.1.0



28
29
30
# File 'lib/mtg_card_maker/layers/border_layer.rb', line 28

def mask_id
  @mask_id
end

Instance Method Details

#rendervoid

This method returns an undefined value.

Render the border layer with QR code and copyright text

Since:

  • 0.1.0



62
63
64
65
66
67
68
69
70
# File 'lib/mtg_card_maker/layers/border_layer.rb', line 62

def render
  layer_config = LayerConfig.default
  corners = layer_config.corner_radius(:outer)
  color_key = color_key_for(@color)

  render_frame_by_color(color_key, corners)
  render_qr_code
  render_copyright_texts(layer_config)
end