hue
PoolModern Swift color utilities with hex parsing, HSL conversion, WCAG accessibility, color theory, and platform bridging
These docs were generated by AI and may not be fully accurate.
Sources/Hue/Hue.swift
Classes
A modern, type-safe color representation with hex parsing, HSL conversion, WCAG accessibility, and platform bridging.
constructor(red: Double, green: Double, blue: Double, alpha?: Double)
| Property | Type | Description |
|---|---|---|
red | Double | Red component (0.0–1.0) |
green | Double | Green component (0.0–1.0) |
blue | Double | Blue component (0.0–1.0) |
alpha | Double | Alpha component (0.0–1.0) |
black | Hue | Pure black (#000000) |
white | Hue | Pure white (#FFFFFF) |
red | Hue | Pure red (#FF0000) |
green | Hue | Pure green (#00FF00) |
blue | Hue | Pure blue (#0000FF) |
clear | Hue | Fully transparent black |
description | String | Textual representation as hex string |
Sources/Hue/Hue+Components.swift
Classes
Component accessor extensions for Hue.
| Method | Return Type | Description |
|---|---|---|
withAlpha(alpha) | Hue | Returns a new color with the specified alpha value. |
withRed(red) | Hue | Returns a new color with the specified red component. |
withGreen(green) | Hue | Returns a new color with the specified green component. |
withBlue(blue) | Hue | Returns a new color with the specified blue component. |
| Property | Type | Description |
|---|---|---|
rgba | (red: Double, green: Double, blue: Double, alpha: Double) | The RGBA components as a tuple. |
Sources/Hue/Hue+Accessibility.swift
Classes
WCAG accessibility extensions for Hue.
| Method | Return Type | Description |
|---|---|---|
contrastRatio(other) | Double | Calculates the contrast ratio between this color and another (1.0–21.0). |
meetsWCAG(level, size, against) | Bool | Checks whether this color meets WCAG contrast requirements against another color. |
bestTextColor(from) | Hue | Returns the candidate color with the best contrast against this color. |
| Property | Type | Description |
|---|---|---|
relativeLuminance | Double | The relative luminance of the color per WCAG 2.0. |
isLight | Bool | Whether the color is perceived as light (luminance > 0.5). |
isDark | Bool | Whether the color is perceived as dark (luminance ≤ 0.5). |
Enums
WCAG conformance levels.
| Member | Value |
|---|---|
aa | null |
aaa | null |
WCAG text size categories.
| Member | Value |
|---|---|
normal | null |
large | null |
Sources/Hue/Hue+Hex.swift
Functions
function init(hex:)(hex: String): Hue
Creates a color from a hex string. Supports #RGB, #RRGGBB, #RRGGBBAA formats.
| Parameter | Type | Description |
|---|---|---|
hex | String | A hex color string |
function init(hex:)(hex: UInt32): Hue
Creates a color from a 24-bit RGB hex integer.
| Parameter | Type | Description |
|---|---|---|
hex | UInt32 | A 24-bit RGB hex value |
Classes
Hex parsing extensions for Hue.
| Method | Return Type | Description |
|---|---|---|
toHex(includeAlpha) | String | Converts the color to a hex string with # prefix. |
Sources/Hue/Hue+HSL.swift
Functions
function init(hue:saturation:lightness:alpha:)(hue: Double, saturation: Double, lightness: Double, alpha?: Double): Hue
Creates a color from HSL components.
| Parameter | Type | Description |
|---|---|---|
hue | Double | Hue angle in degrees (0–360) |
saturation | Double | Saturation (0.0–1.0) |
lightness | Double | Lightness (0.0–1.0) |
alphaoptional | Double | Alpha (0.0–1.0). Defaults to 1.0 |
Classes
HSL conversion extensions for Hue.
| Property | Type | Description |
|---|---|---|
hue | Double | The hue angle in degrees (0–360). |
saturation | Double | The HSL saturation (0.0–1.0). |
lightness | Double | The HSL lightness (0.0–1.0). |
hsla | (hue: Double, saturation: Double, lightness: Double, alpha: Double) | The HSLA components as a tuple. |
Sources/Hue/Hue+Manipulation.swift
Classes
Color manipulation extensions for Hue.
| Method | Return Type | Description |
|---|---|---|
lighter(by) | Hue | Returns a lighter version of the color. |
darker(by) | Hue | Returns a darker version of the color. |
saturated(by) | Hue | Returns a more saturated version of the color. |
desaturated(by) | Hue | Returns a less saturated version of the color. |
adjustHue(by) | Hue | Returns a color with the hue rotated by the given degrees. |
inverted() | Hue | Returns the inverted (RGB complement) color. |
grayscale() | Hue | Returns a grayscale version of the color. |
Sources/Hue/Hue+Mixing.swift
Classes
Color mixing extensions for Hue.
| Method | Return Type | Description |
|---|---|---|
mixed(with, amount) | Hue | Mixes this color with another using linear interpolation. |
Sources/Hue/Hue+ColorTheory.swift
Classes
Color theory extensions for Hue.
| Property | Type | Description |
|---|---|---|
complementary | Hue | The complementary color (hue rotated 180 degrees). |
analogous | (Hue, Hue) | The two analogous colors (hue ±30 degrees). |
triadic | (Hue, Hue) | The two triadic colors (hue ±120 degrees). |
splitComplementary | (Hue, Hue) | The two split-complementary colors (150° and 210°). |
tetradic | (Hue, Hue, Hue) | The three tetradic colors (90°, 180°, 270°). |
Sources/Hue/Hue+SwiftUI.swift
Functions
function init(hex:)(hex: String): Color
Creates a SwiftUI Color from a hex string.
| Parameter | Type | Description |
|---|---|---|
hex | String | A hex color string (#RGB, #RRGGBB, or #RRGGBBAA) |
function init(_:)(hue: Hue): Color
Creates a SwiftUI Color from a Hue value.
| Parameter | Type | Description |
|---|---|---|
hue | Hue | A Hue color value |
Classes
SwiftUI integration extensions for Hue.
| Property | Type | Description |
|---|---|---|
color | Color | Converts to a SwiftUI Color. |
SwiftUI Color extensions for Hue integration.
Sources/Hue/Hue+Platform.swift
Functions
function init(cgColor:)(cgColor: CGColor): Hue
Creates a Hue from a CGColor.
| Parameter | Type | Description |
|---|---|---|
cgColor | CGColor | A Core Graphics color |
function init(uiColor:)(uiColor: UIColor): Hue
Creates a Hue from a UIColor (iOS/watchOS/tvOS/visionOS only).
| Parameter | Type | Description |
|---|---|---|
uiColor | UIColor | A UIKit color |
function init(nsColor:)(nsColor: NSColor): Hue
Creates a Hue from an NSColor (macOS only).
| Parameter | Type | Description |
|---|---|---|
nsColor | NSColor | An AppKit color |
Classes
Platform bridging extensions for Hue.
| Property | Type | Description |
|---|---|---|
cgColor | CGColor | Converts to a CGColor. |
uiColor | UIColor | Converts to a UIColor (iOS/watchOS/tvOS/visionOS only). |
nsColor | NSColor | Converts to an NSColor (macOS only). |
Taxes calculated at checkout based on your location.