Merged
Conversation
PaletteColor now resolves to Color.Resolved (iOS 17+) via init(colorSpace: .sRGB, red:green:blue:opacity:), so it can be passed directly to .fill, .foregroundStyle, .background, .border, .tint, and any other ShapeStyle accepting modifier without an adapter call. Apple handles the sRGB → linear sRGB extended range conversion internally. Tests cover boundary RGB values plus a sample linear gamma decode.
PaletteColor conforms to ShapeStyle now, so the .swiftUI Color adapter is redundant. The demo views use PaletteColor directly with .fill / .foregroundStyle. Optional swatch fallbacks are wrapped in AnyShapeStyle so the existing Color.gray / Color.primary placeholders still work for nil swatches. BREAKING: PaletteColor.swiftUI is removed. Use PaletteColor directly with any ShapeStyle-accepting modifier.
Mirrors Apple's UIColor.init(_ color: Color) conversion pattern. The init is sRGB-tagged with alpha = 1; chain .withAlphaComponent(_:) for non-opaque variants.
Direct CGColor without a UIColor hop. Uses CGColor(srgbRed:...) so the result is sRGB-tagged. Useful for CALayer.backgroundColor, CGContext fills, and other Core Graphics APIs.
PaletteKit now offers a UIColor(_ paletteColor:) convenience init and a direct PaletteColor.cgColor accessor (added in the previous two commits). The legacy .uiColor property is redundant. BREAKING: PaletteColor.uiColor is removed. Use UIColor(paletteColor) or paletteColor.cgColor instead.
Groups MetalContext.swift with the Histogram.metal shader source it pairs with. Support/ now contains only Logging.swift, which is its true purpose — shared infrastructure utilities. Package.swift exclusion path "Metal/Histogram.metal" is unchanged (already correct relative to the source root).
GettingStarted gets a new "Using the result" section with separate SwiftUI and UIKit subsections so users can find their platform's pattern at a glance. Options gains "SwiftUI integration" and "UIKit integration" sections describing the new conformance and accessors. README: - Quick start split into SwiftUI / UIKit sub-sections. - Features bullet mentions ShapeStyle conformance. - New "What's new in 1.3" section above the install snippet calls out the breaking adapter removals. - Install snippet bumped to from: "1.3.0". - Roadmap refreshed with v1.3 shipped and v1.4 / v2.0 next. Also fixes two stale .uiColor references in GettingStarted that broke after the adapter was removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PaletteColornow conforms to SwiftUI'sShapeStyle(iOS 17+) so it can be passed directly to.fill,.foregroundStyle,.background,.tint,.border, etc. without an adapter call.resolve(in:)produces aColor.Resolvedtagged sRGB.UIColor(_ paletteColor:)convenience initializer (mirrors Apple'sUIColor.init(_ color: Color)pattern) and a directpaletteColor.cgColoraccessor forCALayer/CGContextdrawing — noUIColorround-trip.Options.md+GettingStarted.mdreorganized with platform-tabbed### SwiftUIand### UIKitexamples so users find their pattern at a glance.MetalContext.swiftmoved fromSupport/toMetal/(groups withHistogram.metalshader source). BumpspaletteKitVersionto1.3.0.What's changed
Library (
Sources/PaletteKit/)Model/PaletteColor+ShapeStyle.swift—extension PaletteColor: ShapeStylereturningColor.Resolved(colorSpace: .sRGB, ...). Apple handles the sRGB → linear conversion internally.Model/PaletteColor+UIKit.swift—UIColor(_ paletteColor:)convenience init andpaletteColor.cgColordirect accessor (usesCGColor(srgbRed:...), noUIColorhop).Support/MetalContext.swift→Metal/MetalContext.swift.Support/is now justLogging.swift(its actual purpose).Model/PaletteColor+SwiftUI.swift— both legacy adapter properties (.swiftUIand.uiColor).paletteKitVersion = "1.3.0".Demo app (
Examples/PaletteKitDemo/)DominantColorView,PaletteGrid,SwatchesViewusePaletteColordirectly (no.swiftUIadapter call).SwatchCardwraps optional swatch fallbacks inAnyShapeStyle-typed computed properties since??cannot unifyPaletteColorandColordirectly.Docs
README.md: Quick Start split into### SwiftUI/### UIKitsub-sections. Features bullet mentionsShapeStyleconformance. New## What's new in 1.3section after the Install snippet calls out the BREAKING adapter removals with migration paths. Install snippet bumped tofrom: "1.3.0". Roadmap refreshed (v1.3 ✅ shipped, v1.4 / v2.0 next).PaletteKit.docc/Tutorials/GettingStarted.md: New## Using the resultsection with### SwiftUIand### UIKitsubsections. Two stale.uiColorreferences in the existing "Get semantic swatches" example fixed (replaced withUIColor(...)init pattern).PaletteKit.docc/Tutorials/Options.md: New### SwiftUI integrationand### UIKit integrationsections describing the new conformance and accessors.Audit notes
Color.Resolvedis iOS 17+ (Apple's "concrete RGBA value" type stored in linear sRGB extended range). PaletteKit targets iOS 17+ unconditionally so the conformance has no@availableguards. Apple'sinit(colorSpace: .sRGB, red:green:blue:opacity:)lets us pass our 8-bit sRGB-encoded values directly — gamma decode happens inside SwiftUI's pipeline.For UIKit,
UIColor.init(_ color: Color)(iOS 14+) is Apple's idiomatic SwiftUI/value-type → UIKit conversion pattern;UIColor(_ paletteColor:)mirrors it.CGColor(srgbRed:green:blue:alpha:)(iOS 13+) bypassesUIColorentirely sopaletteColor.cgColoris a single allocation.Display P3 fidelity is intentionally unchanged in this release (stays sRGB) — that's earmarked for v1.4 alongside
PaletteKitCardgraphics where wide-gamut rendering matters.Breaking changes
PaletteColor.swiftUIremoved. Replacement: passPaletteColordirectly to anyShapeStyle-accepting modifier.PaletteColor.uiColorremoved. Replacement:UIColor(paletteColor)(init) orpaletteColor.cgColor(Core Graphics).Test plan
swift test— 35/35 pass (was 31/31; +4 ShapeStyle boundary tests, +5 UIKit tests guarded by#if canImport(UIKit)).make demo-appregenerates the Xcode project; iOS Simulator build succeeds (iPhone 17 Pro).xcodebuild docbuildsucceeds..swiftUI/.uiColorreferences remain anywhere inSources/,Tests/,Examples/,PaletteKit.docc/,README.md(verified by grep).