Class: Fontisan::Models::ColorPalette
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Fontisan::Models::ColorPalette
- Defined in:
- lib/fontisan/models/color_palette.rb
Overview
Color palette information model
Represents a color palette from the CPAL table. Each palette contains an array of RGBA colors in hex format that can be referenced by COLR layer palette indices.
This model uses lutaml-model for structured serialization to YAML/JSON/XML.
Instance Attribute Summary collapse
-
#colors ⇒ Array<String>
Array of hex color strings (#RRGGBBAA).
-
#index ⇒ Integer
Palette index (0-based).
-
#num_colors ⇒ Integer
Number of colors in this palette.
Instance Method Summary collapse
-
#color_at(color_index) ⇒ String?
Get a color by index.
-
#empty? ⇒ Boolean
Check if palette is empty.
Instance Attribute Details
#colors ⇒ Array<String>
Returns Array of hex color strings (#RRGGBBAA).
40 |
# File 'lib/fontisan/models/color_palette.rb', line 40 attribute :colors, :string, collection: true |
#index ⇒ Integer
Returns Palette index (0-based).
32 |
# File 'lib/fontisan/models/color_palette.rb', line 32 attribute :index, :integer |
#num_colors ⇒ Integer
Returns Number of colors in this palette.
36 |
# File 'lib/fontisan/models/color_palette.rb', line 36 attribute :num_colors, :integer |
Instance Method Details
#color_at(color_index) ⇒ String?
Get a color by index
46 47 48 49 50 |
# File 'lib/fontisan/models/color_palette.rb', line 46 def color_at(color_index) return nil if color_index.negative? || color_index >= colors.length colors[color_index] end |
#empty? ⇒ Boolean
Check if palette is empty
55 56 57 |
# File 'lib/fontisan/models/color_palette.rb', line 55 def empty? colors.nil? || colors.empty? end |