Skip to content

Commit fcd3f60

Browse files
committed
docs: Add comprehensive documentation for color conversion utilities
1 parent ba10d16 commit fcd3f60

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Sources/SwiftDevKit/Conversion/Color+Conversion.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,34 @@
44
// Copyright (c) 2025 owdax and The SwiftDevKit Contributors
55
// MIT License - https://opensource.org/licenses/MIT
66

7+
/// This file provides comprehensive color conversion utilities for iOS and macOS.
8+
/// It supports conversion between different color spaces including:
9+
/// - RGB (Red, Green, Blue)
10+
/// - HSL (Hue, Saturation, Lightness)
11+
/// - HSV (Hue, Saturation, Value)
12+
/// - CMYK (Cyan, Magenta, Yellow, Key/Black)
13+
/// - Hex string representation
14+
///
15+
/// All color components are normalized to the range 0-1, except for hue which uses 0-360 degrees.
16+
/// The implementation handles color space conversion automatically and works consistently
17+
/// across UIKit and AppKit.
18+
///
19+
/// Example usage:
20+
/// ```swift
21+
/// // Create colors from different formats
22+
/// let redFromHex = Color(hex: "#FF0000")
23+
/// let greenFromHSL = Color(hsl: HSL(hue: 120, saturation: 1.0, lightness: 0.5))
24+
/// let blueFromHSV = Color(hsv: HSV(hue: 240, saturation: 1.0, value: 1.0))
25+
/// let yellowFromCMYK = Color(cmyk: CMYK(cyan: 0, magenta: 0, yellow: 1.0, key: 0))
26+
///
27+
/// // Convert colors to different formats
28+
/// let color = Color.red
29+
/// let hex = color.toHex() // "#FF0000"
30+
/// let hsl = color.toHSL() // HSL(hue: 0, saturation: 1.0, lightness: 0.5)
31+
/// let hsv = color.toHSV() // HSV(hue: 0, saturation: 1.0, value: 1.0)
32+
/// let cmyk = color.toCMYK() // CMYK(cyan: 0, magenta: 1.0, yellow: 1.0, key: 0)
33+
/// ```
34+
735
import Foundation
836
#if canImport(UIKit)
937
import UIKit

0 commit comments

Comments
 (0)