Class: MtgCardMaker::ColorPalette

Inherits:
Object
  • Object
show all
Defined in:
lib/mtg_card_maker/color_palette.rb

Overview

ColorPalette aggregates the five core interface colors for cohesive design. It focuses on background elements, buttons, borders, and other UI components, excluding text color. Multiple instances can be created for different themes (default, dark, corporate, etc.).

Examples:

palette = MtgCardMaker::ColorPalette.new(
  primary_color: '#42A5F5',
  background_color: '#E3F2FD',
  border_color: '#1565C0'
)
palette.primary_color # => "#42A5F5"

Using predefined themes

dark_palette = MtgCardMaker::ColorPalette.dark
light_palette = MtgCardMaker::ColorPalette.light
default_palette = MtgCardMaker::ColorPalette.default

Since:

  • 0.1.0

Constant Summary collapse

FRAME_STROKE_COLOR =

Default frame stroke color used across the application

Since:

  • 0.1.0

'#111'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(primary_color: nil, background_color: nil, border_color: nil, frame_stroke_color: FRAME_STROKE_COLOR, accent_color: nil) ⇒ ColorPalette

Initialize a new color palette

Since:

  • 0.1.0



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

def initialize(primary_color: nil, background_color: nil, border_color: nil,
               frame_stroke_color: FRAME_STROKE_COLOR, accent_color: nil)
  @primary_color = primary_color || DEFAULT_COLOR_SCHEME.primary_color
  @background_color = background_color || DEFAULT_COLOR_SCHEME.background_color
  @border_color = border_color || DEFAULT_COLOR_SCHEME.border_color
  @frame_stroke_color = frame_stroke_color
  @accent_color = accent_color || DEFAULT_COLOR_SCHEME.primary_color
end

Instance Attribute Details

#accent_colorString (readonly)

Returns the accent color.

Since:

  • 0.1.0



37
38
39
# File 'lib/mtg_card_maker/color_palette.rb', line 37

def accent_color
  @accent_color
end

#background_colorString (readonly)

Returns the background color.

Since:

  • 0.1.0



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

def background_color
  @background_color
end

#border_colorString (readonly)

Returns the border color.

Since:

  • 0.1.0



31
32
33
# File 'lib/mtg_card_maker/color_palette.rb', line 31

def border_color
  @border_color
end

#frame_stroke_colorString (readonly)

Returns the frame stroke color.

Since:

  • 0.1.0



34
35
36
# File 'lib/mtg_card_maker/color_palette.rb', line 34

def frame_stroke_color
  @frame_stroke_color
end

#primary_colorString (readonly)

Returns the primary color.

Since:

  • 0.1.0



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

def primary_color
  @primary_color
end

Class Method Details

.darkColorPalette

Dark theme palette

Since:

  • 0.1.0



82
83
84
85
86
87
88
89
90
# File 'lib/mtg_card_maker/color_palette.rb', line 82

def self.dark
  new(
    primary_color: '#2A2A2A',
    background_color: '#1A1A1A',
    border_color: '#4A4A4A',
    frame_stroke_color: '#333',
    accent_color: '#6B6B6B'
  )
end

.defaultColorPalette

Default palette using the default color scheme

Since:

  • 0.1.0



75
76
77
# File 'lib/mtg_card_maker/color_palette.rb', line 75

def self.default
  from_color_scheme(DEFAULT_COLOR_SCHEME)
end

.from_color_scheme(color_scheme) ⇒ ColorPalette

Create a palette from a color scheme

Since:

  • 0.1.0



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

def self.from_color_scheme(color_scheme)
  new(
    primary_color: color_scheme.primary_color,
    background_color: color_scheme.background_color,
    border_color: color_scheme.border_color,
    accent_color: color_scheme.primary_color
  )
end

.lightColorPalette

Light theme palette

Since:

  • 0.1.0



95
96
97
98
99
100
101
102
103
# File 'lib/mtg_card_maker/color_palette.rb', line 95

def self.light
  new(
    primary_color: '#E8E8E8',
    background_color: '#F5F5F5',
    border_color: '#D4D4D4',
    frame_stroke_color: '#666',
    accent_color: '#8B8B8B'
  )
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

Check if this palette matches another

Since:

  • 0.1.0



122
123
124
125
126
# File 'lib/mtg_card_maker/color_palette.rb', line 122

def ==(other)
  return false unless other.is_a?(ColorPalette)

  to_h == other.to_h
end

#hashObject

Generate a hash for this palette

Since:

  • 0.1.0



131
132
133
# File 'lib/mtg_card_maker/color_palette.rb', line 131

def hash
  to_h.hash
end

#to_aObject

Return all colors as an array

Since:

  • 0.1.0



117
118
119
# File 'lib/mtg_card_maker/color_palette.rb', line 117

def to_a
  [@primary_color, @background_color, @border_color, @frame_stroke_color, @accent_color]
end

#to_hObject

Return all colors as a hash for easy access

Since:

  • 0.1.0



106
107
108
109
110
111
112
113
114
# File 'lib/mtg_card_maker/color_palette.rb', line 106

def to_h
  {
    primary_color: @primary_color,
    background_color: @background_color,
    border_color: @border_color,
    frame_stroke_color: @frame_stroke_color,
    accent_color: @accent_color
  }
end