# `GSPaletteColor`

*Class*

A color that references a base color from a color palette and multiplies the alpha component with an additional factor.

## Declaration

```swift
class GSPaletteColor
```

```objc
@interface GSPaletteColor : NSColor
```

```python
class GSPaletteColor(NSColor)
```

## Overview

Before using the color, update effective color values using [`GSPaletteColor updateForEnvironment:`](/Core/GlyphsCore/GSPaletteColor/updateForEnvironment:). A palette color with an invalid palette container or color index renders as `NSColor/errorReplacementColor` (bright pink).

Palette colors are not immutable, as changes to the referenced palette affect the value of the color. Access must happen on the main thread.

## Topics

### Instance Properties

- [`GSPaletteColor.alphaFactor`](/Core/GlyphsCore/GSPaletteColor/alphaFactor) — A factor that is multiplied with the alpha component of the base color to create the effective color.
- [`GSPaletteColor.colorIndex`](/Core/GlyphsCore/GSPaletteColor/colorIndex) — The index into a color palette referencing the base color.
- [`GSPaletteColor.effectiveColor`](/Core/GlyphsCore/GSPaletteColor/effectiveColor) — Resolves the palette color to a regular color object.

### Instance Methods

- [`GSPaletteColor drawSwatchInRect:`](/Core/GlyphsCore/GSPaletteColor/drawSwatchInRect:)
- [`GSPaletteColor effectiveColorInSetting:`](/Core/GlyphsCore/GSPaletteColor/effectiveColorInSetting:) — Resolves the palette color to a regular color object.
- [`GSPaletteColor initWithIndex:alphaFactor:baseColor:`](/Core/GlyphsCore/GSPaletteColor/initWithIndex:alphaFactor:baseColor:) — Creates a palette color.
- [`GSPaletteColor initWithIndex:alphaFactor:environment:`](/Core/GlyphsCore/GSPaletteColor/initWithIndex:alphaFactor:environment:) — Creates a palette color.
- [`GSPaletteColor propertyListToData:format:error:`](/Core/GlyphsCore/GSPaletteColor/propertyListToData:format:error:)
- [`GSPaletteColor propertyListValueFormat:error:`](/Core/GlyphsCore/GSPaletteColor/propertyListValueFormat:error:)
- [`GSPaletteColor updateForEnvironment:`](/Core/GlyphsCore/GSPaletteColor/updateForEnvironment:) — Updates the effective color values of the palette color to match the given environment.

### Type Properties

- [`GSPaletteColor.textColor`](/Core/GlyphsCore/GSPaletteColor/textColor) — Dynamic color that adapts to the user-selected foreground color.

### Type Methods

- [`GSPaletteColor textColorWithAlphaComponent:`](/Core/GlyphsCore/GSPaletteColor/textColorWithAlphaComponent:) — Dynamic color that adapts to the user-selected foreground color.

## Relationships

### Inherits From

- `NSColor`

