Class: Fontisan::Models::ColorLayer

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/fontisan/models/color_layer.rb

Overview

Color layer information model

Represents a single color layer in a COLR glyph. Each layer specifies a glyph ID to render and the palette index for its color.

This model uses lutaml-model for structured serialization to YAML/JSON/XML.

Examples:

Creating a color layer

layer = ColorLayer.new
layer.glyph_id = 42
layer.palette_index = 2
layer.color = "#FF0000FF"

Serializing to YAML

yaml = layer.to_yaml
# glyph_id: 42
# palette_index: 2
# color: "#FF0000FF"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#colorString?

Returns Hex color from palette (#RRGGBBAA), nil if foreground.

Returns:

  • (String, nil)

    Hex color from palette (#RRGGBBAA), nil if foreground



36
# File 'lib/fontisan/models/color_layer.rb', line 36

attribute :color, :string

#glyph_idInteger

Returns Glyph ID of the layer.

Returns:

  • (Integer)

    Glyph ID of the layer



28
# File 'lib/fontisan/models/color_layer.rb', line 28

attribute :glyph_id, :integer

#palette_indexInteger

Returns Index into CPAL palette (0xFFFF = foreground).

Returns:

  • (Integer)

    Index into CPAL palette (0xFFFF = foreground)



32
# File 'lib/fontisan/models/color_layer.rb', line 32

attribute :palette_index, :integer

Instance Method Details

#uses_foreground_color?Boolean

Check if this layer uses the foreground color

Returns:

  • (Boolean)

    True if using text foreground color



41
42
43
# File 'lib/fontisan/models/color_layer.rb', line 41

def uses_foreground_color?
  palette_index == 0xFFFF
end

#uses_palette_color?Boolean

Check if this layer uses a palette color

Returns:

  • (Boolean)

    True if using CPAL palette color



48
49
50
# File 'lib/fontisan/models/color_layer.rb', line 48

def uses_palette_color?
  !uses_foreground_color?
end