Skip to content

Commit 9c210c6

Browse files
authored
Merge pull request #15 from KvColorPalette/feature/color-blending
Feature/color blending
2 parents e0ce9a3 + 1a61fca commit 9c210c6

4 files changed

Lines changed: 211 additions & 139 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This library simplifies the process of building consistent and visually appealin
2222
```
2323
dependencies: [
2424
....
25-
.package(url: "https://github.com/KvColorPalette/KvColorPalette-iOS", from: "1.3.0"),
25+
.package(url: "https://github.com/KvColorPalette/KvColorPalette-iOS", from: "2.0.0"),
2626
]
2727
```
2828

Sources/KvColorPalette-iOS/KvColorPalette.swift

Lines changed: 75 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,43 @@ import Foundation
44
import UIKit
55
import SwiftUICore
66

7-
/**
8-
* This is the KvColorPalette-iOS library.
9-
*/
7+
8+
///
9+
/// This is the KvColorPalette-iOS library.
10+
///
1011
public class KvColorPalette {
1112

1213
nonisolated(unsafe) public static var instance: KvColorPalette = KvColorPalette()
1314
nonisolated(unsafe) public static var appThemePalette: AppThemePalette? = nil
1415

15-
/**
16-
* This is a basic initialization without a basic color. When consumer use this initialization, in default KvColorPalette with not
17-
* provide a theme color pallet. Consumer can generate their own by invoking `#generateThemeColorPalette(givenColor: KvColor)` method
18-
* in the package.
19-
*/
16+
///
17+
/// This is a basic initialization without a basic color. When consumer use this initialization, in default KvColorPalette with not
18+
/// provide a theme color pallet. Consumer can generate their own by invoking `#generateThemeColorPalette(givenColor: KvColor)` method
19+
/// in the package.
20+
///
2021
public init () {}
2122

22-
/**
23-
* KvColorPalette initialization. Consumer can use this to initialize the KvColorPalette from their application delegate if they need a
24-
* Theme color pallet at the application start-up.
25-
*
26-
* On this initiation of kv-color-pallet, we generate a theme color pallet using the given color.
27-
* `basicColor` is mandatory parameter while initiate the library.
28-
*/
23+
24+
///
25+
/// KvColorPalette initialization. Consumer can use this to initialize the KvColorPalette from their application delegate if they need a
26+
/// Theme color pallet at the application start-up.
27+
///
28+
/// On this initiation of kv-color-pallet, we generate a theme color pallet using the given color.
29+
/// `basicColor` is mandatory parameter while initiate the library.
30+
///
2931
public static func initialize(basicColor: Color) {
3032
appThemePalette = instance.generateThemeColorPalette(givenColor: basicColor)
3133
}
32-
33-
/**
34-
* Generate a list of colors with pre-defined color packages. According to the feeding color,
35-
* this method generate a list of colors.
36-
*
37-
* @param givenColor The color to generate the color packages for.
38-
* @return A list of colors.
39-
*/
34+
35+
///
36+
/// Generate a list of colors with pre-defined color packages. According to the feeding color,
37+
/// this method generate a list of colors.
38+
///
39+
/// - Parameters:
40+
/// - givenColor: The color to generate the color packages for.
41+
///
42+
/// - Returns: A list of colors.
43+
///
4044
public func generateColorPalette(givenColor: KvColor, alphaChange: Double = 1) -> [Color] {
4145
return [
4246
Mat900Package().getColor(colorName: givenColor.colorName).alphaChange(modifyAlpha: alphaChange).color,
@@ -51,16 +55,17 @@ public class KvColorPalette {
5155
Mat50Package().getColor(colorName: givenColor.colorName).alphaChange(modifyAlpha: alphaChange).color
5256
]
5357
}
54-
55-
/**
56-
* Generate a list of colors with alpha values. According to the feeding color,
57-
* this method generate a list of colors with different alpha values.
58-
*
59-
* @param givenColor The color to generate the alpha values for.
60-
* @param colorCount The number of colors to generate. In default that returns 10 colors. This accept integer value in a range of 2 - 30.
61-
* Even someone passes number more than 30, this will returns only 30 colors.
62-
* @return A list of colors with alpha values.
63-
*/
58+
59+
///
60+
/// Generate a list of colors with alpha values. According to the feeding color,
61+
/// this method generate a list of colors with different alpha values.
62+
///
63+
/// - Parameters:
64+
/// - givenColor: The color to generate the alpha values for.
65+
/// - colorCount: The number of colors to generate. In default that returns 10 colors. This accept integer value in a range of 2 - 30. Even someone passes number more than 30, this will returns only 30 colors.
66+
///
67+
/// - Returns: A list of colors with alpha values.
68+
///
6469
public func generateAlphaColorPalette(givenColor: Color, colorCount: Int = 10) -> [Color] {
6570
var colorList: [Color] = []
6671
let reviceColorCount = ColorUtil.validateAndReviseColorCount(colorCount: colorCount)
@@ -73,15 +78,16 @@ public class KvColorPalette {
7378
return colorList
7479
}
7580

76-
/**
77-
* Generate a list of colors with brightness property change in given color. According to the feeding color,
78-
* this method generate a list of colors with different brightnesses.
79-
*
80-
* @param givenColor The color to generate the brightness values for.
81-
* @param colorCount The number of colors to generate. In default that returns 10 colors. This accept integer value in a range of 2 - 30.
82-
* Even someone passes number more than 30, this will returns only 30 colors.
83-
* @return A list of colors.
84-
*/
81+
///
82+
/// Generate a list of colors with brightness property change in given color. According to the feeding color,
83+
/// this method generate a list of colors with different brightnesses.
84+
///
85+
/// - Parameters:
86+
/// - givenColor: The color to generate the brightness values for.
87+
/// - colorCount: The number of colors to generate. In default that returns 10 colors. This accept integer value in a range of 2 - 30. Even someone passes number more than 30, this will returns only 30 colors.
88+
///
89+
/// - Returns: A list of colors.
90+
///
8591
public func generateBrightnessColorPalette(givenColor: Color, colorCount: Int = 10) -> [Color] {
8692
let hue = givenColor.hsl.hue
8793
let saturation = givenColor.hsl.saturation
@@ -97,15 +103,16 @@ public class KvColorPalette {
97103
return colorList
98104
}
99105

100-
/**
101-
* Generate a list of colors with saturation property change in given color. According to the feeding color,
102-
* this method generate a list of colors with different saturations.
103-
*
104-
* @param givenColor The color to generate the saturation values for.
105-
* @param colorCount The number of colors to generate. In default that returns 10 colors. This accept integer value in a range of 2 - 30.
106-
* Even someone passes number more than 30, this will returns only 30 colors.
107-
* @return A list of colors.
108-
*/
106+
///
107+
/// Generate a list of colors with saturation property change in given color. According to the feeding color,
108+
/// this method generate a list of colors with different saturations.
109+
///
110+
/// - Parameters:
111+
/// - givenColor: The color to generate the saturation values for.
112+
/// - colorCount: The number of colors to generate. In default that returns 10 colors. This accept integer value in a range of 2 - 30. Even someone passes number more than 30, this will returns only 30 colors.
113+
///
114+
/// - Returns: A list of colors.
115+
///
109116
public func generateSaturationColorPalette(givenColor: Color, colorCount: Int = 10) -> [Color] {
110117
let hue = givenColor.hsl.hue
111118
let brightness = givenColor.hsl.brightness
@@ -121,23 +128,27 @@ public class KvColorPalette {
121128
return colorList
122129
}
123130

124-
/**
125-
* Generate a theme color pallet. According to the feeding color,
126-
* this method generate a theme color pallet.
127-
*
128-
* @param givenColor The color to generate the theme color pallet for.
129-
* @return A theme color pallet.
130-
*/
131+
///
132+
/// Generate a theme color pallet. According to the feeding color,
133+
/// this method generate a theme color pallet.
134+
///
135+
/// - Parameters:
136+
/// - givenColor: The color to generate the theme color pallet for.
137+
///
138+
/// - Returns: A theme color pallet.
139+
///
131140
public func generateThemeColorPalette(givenColor: Color) -> AppThemePalette {
132141
return ThemeGenUtil.generateThemeColorSet(givenColor: givenColor)
133142
}
134143

135-
/**
136-
* This method finds the closest KvColor available in the KvColorPalette-iOS to the given color
137-
*
138-
* @param givenColor: The color to find closest KvColor from color packages
139-
* @return KvColor
140-
*/
144+
///
145+
/// This method finds the closest KvColor available in the `KvColorPalette-iOS` to the given color
146+
///
147+
/// - Parameters:
148+
/// - givenColor: The color to find closest KvColor from color packages
149+
///
150+
/// - Returns: `KvColor`
151+
///
141152
public func findClosestKvColor(givenColor: Color) -> KvColor {
142153
return ColorUtil.findClosestColor(givenColor: givenColor)
143154
}

0 commit comments

Comments
 (0)