Class: MtgCardMaker::ColorPalette
- Inherits:
-
Object
- Object
- MtgCardMaker::ColorPalette
- 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.).
Constant Summary collapse
- FRAME_STROKE_COLOR =
Default frame stroke color used across the application
'#111'
Instance Attribute Summary collapse
-
#accent_color ⇒ String
readonly
The accent color.
-
#background_color ⇒ String
readonly
The background color.
-
#border_color ⇒ String
readonly
The border color.
-
#frame_stroke_color ⇒ String
readonly
The frame stroke color.
-
#primary_color ⇒ String
readonly
The primary color.
Class Method Summary collapse
-
.dark ⇒ ColorPalette
Dark theme palette.
-
.default ⇒ ColorPalette
Default palette using the default color scheme.
-
.from_color_scheme(color_scheme) ⇒ ColorPalette
Create a palette from a color scheme.
-
.light ⇒ ColorPalette
Light theme palette.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Check if this palette matches another.
-
#hash ⇒ Object
Generate a hash for this palette.
-
#initialize(primary_color: nil, background_color: nil, border_color: nil, frame_stroke_color: FRAME_STROKE_COLOR, accent_color: nil) ⇒ ColorPalette
constructor
Initialize a new color palette.
-
#to_a ⇒ Object
Return all colors as an array.
-
#to_h ⇒ Object
Return all colors as a hash for easy access.
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
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_color ⇒ String (readonly)
Returns the accent color.
37 38 39 |
# File 'lib/mtg_card_maker/color_palette.rb', line 37 def accent_color @accent_color end |
#background_color ⇒ String (readonly)
Returns the background color.
28 29 30 |
# File 'lib/mtg_card_maker/color_palette.rb', line 28 def background_color @background_color end |
#border_color ⇒ String (readonly)
Returns the border color.
31 32 33 |
# File 'lib/mtg_card_maker/color_palette.rb', line 31 def border_color @border_color end |
#frame_stroke_color ⇒ String (readonly)
Returns the frame stroke color.
34 35 36 |
# File 'lib/mtg_card_maker/color_palette.rb', line 34 def frame_stroke_color @frame_stroke_color end |
#primary_color ⇒ String (readonly)
Returns the primary color.
25 26 27 |
# File 'lib/mtg_card_maker/color_palette.rb', line 25 def primary_color @primary_color end |
Class Method Details
.dark ⇒ ColorPalette
Dark theme palette
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 |
.default ⇒ ColorPalette
Default palette using the default color scheme
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
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 |
.light ⇒ ColorPalette
Light theme palette
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
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 |
#hash ⇒ Object
Generate a hash for this palette
131 132 133 |
# File 'lib/mtg_card_maker/color_palette.rb', line 131 def hash to_h.hash end |
#to_a ⇒ Object
Return all colors as an array
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_h ⇒ Object
Return all colors as a hash for easy access
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 |