Swift package · v0.1.0
KLAdaptiveSurface
Normalize image-derived colors before they become muddy surfaces.
A synchronous color policy that keeps a source hue when possible, raises dark or overly saturated colors into a readable range, and selects a foreground color for the resulting surface.
Functions
- Configurable brightness and saturation bounds
- Dirtiness threshold to leave clean colors untouched
- Preserve-hue, neutral, cool, and warm preferences
- Automatic, dark, or light foreground strategy
Not included
It normalizes a CGColor. Image loading, pixel sampling, recomputation timing, caching, and SwiftUI or UIKit presentation remain the integrating application's responsibility.
Install with SwiftPM
.package(url: "https://github.com/KoenLee1023/KLAdaptiveSurface.git", from: "0.1.0")Usage
let surface = KLAdaptiveSurface.normalize(
sampledColor,
using: .reading
)
apply(surface.background, foreground: surface.foreground)API documentation
Open the complete API documentation.KLAdaptiveSurface.normalize(_:using:)Normalizes one CGColor with a value-type configuration.
KLAdaptiveSurface.ConfigurationDefines thresholds, strength, color preference, and foreground strategy.
KLAdaptiveSurface.ResultReturns the background, foreground, contrast direction, and normalization state.
Demo apps
Reading Surface Demo
Compare clean and muddy sampled colors with the reading policy.
Widget Surface Demo
Tune thresholds and foreground behavior for compact surfaces.