Skip to content

Commit b7170bd

Browse files
Update docs (#4)
* Update docs * Make examples more obvious * Update README
1 parent 8351a44 commit b7170bd

File tree

5 files changed

+66
-39
lines changed

5 files changed

+66
-39
lines changed

.swiftlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ opt_in_rules:
2323
- identical_operands
2424
- implicit_return
2525
- implicitly_unwrapped_optional
26-
# - missing_docs
26+
- missing_docs
2727
- number_separator
2828
- operator_usage_whitespace
2929
- overridden_super_call

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,35 @@ pod 'SmoothGradient', '~> 1.0.0'
3333

3434
## Usage
3535

36-
### Pre-iOS 17
36+
### Pre-iOS 17/Pre-macOS 14
3737

3838
```swift
3939
import SmoothGradient
4040

4141
struct ContentView: View {
4242
var body: some View {
4343
LinearGradient(
44-
gradient: .smooth(from: .black, to: .white, curve: .easeInOut),
44+
gradient: .smooth(from: .black, to: .white, curve: .easeInOut), // ⬅️
4545
startPoint: .top,
4646
endPoint: .bottom
4747
)
4848
}
4949
}
5050
```
5151

52-
## iOS 17+
52+
## iOS 17+/macOS 14+
5353

5454
```swift
5555
import SmoothGradient
5656

5757
struct ContentView: View {
5858
var body: some View {
59-
SmoothLinearGradient(
59+
SmoothLinearGradient( // ⬅️
6060
from: .black,
6161
to: .white,
62-
curve: .easeInOut,
6362
startPoint: .top,
64-
endPoint: .bottom
63+
endPoint: .bottom,
64+
curve: .easeInOut
6565
)
6666
}
6767
}

Sources/SmoothGradient/CubicBezierCurve.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,29 @@ public struct CubicBezierCurve: Curve {
2626
let b: CGPoint
2727
let c: CGPoint
2828

29+
/// A bezier curve that starts out slowly, then speeds up as it finishes.
2930
public static let easeIn = CubicBezierCurve(
3031
p1: UnitPoint(x: 0.42, y: 0),
3132
p2: UnitPoint(x: 1, y: 1)
3233
)
3334

35+
/// A bezier curve that starts out quickly, then slows down as it approaches the end.
3436
public static let easeOut = CubicBezierCurve(
3537
p1: UnitPoint(x: 0, y: 0),
3638
p2: UnitPoint(x: 0.58, y: 1)
3739
)
3840

41+
/// A bezier curve that starts out slowly, speeds up over the middle, then slows down again as it approaches the end.
3942
public static let easeInOut = CubicBezierCurve(
4043
p1: UnitPoint(x: 0.42, y: 0),
4144
p2: UnitPoint(x: 0.58, y: 1)
4245
)
4346

47+
/// Creates a new Cubic Bezier curve with the given control points.
48+
///
49+
/// - Parameters:
50+
/// - p1: Control point 1.
51+
/// - p2: Control point 2.
4452
public init(p1: UnitPoint, p2: UnitPoint) {
4553
self.p1 = p1
4654
self.p2 = p2

Sources/SmoothGradient/Gradient+Smooth.swift

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import SwiftUI
1414

1515
#if compiler(>=5.9)
1616
extension Gradient {
17-
// Creates a gradient with the given easing function.
18-
//
19-
// - Parameters:
20-
// - from: The start color.
21-
// - to: The end color.
22-
// - curve: The easing function to use.
23-
// - steps: The number of steps to use when generating the gradient. Defaults to 16.
24-
// - Returns: A gradient.
17+
/// Creates a gradient with the given easing function.
18+
///
19+
/// - Parameters:
20+
/// - from: The start color.
21+
/// - to: The end color.
22+
/// - curve: The easing function to use.
23+
/// - steps: The number of steps to use when generating the gradient. Defaults to 16.
24+
/// - Returns: A gradient.
2525
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
2626
public static func smooth(
2727
from: Color,
@@ -37,14 +37,14 @@ extension Gradient {
3737
)
3838
}
3939

40-
// Creates a gradient with the given easing function.
41-
//
42-
// - Parameters:
43-
// - from: The start color.
44-
// - to: The end color.
45-
// - curve: The easing function to use.
46-
// - steps: The number of steps to use when generating the gradient. Defaults to 16.
47-
// - Returns: A gradient.
40+
/// Creates a gradient with the given easing function.
41+
///
42+
/// - Parameters:
43+
/// - from: The start color.
44+
/// - to: The end color.
45+
/// - curve: The easing function to use.
46+
/// - steps: The number of steps to use when generating the gradient. Defaults to 16.
47+
/// - Returns: A gradient.
4848
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
4949
public static func smooth(
5050
from: Stop,
@@ -65,14 +65,14 @@ extension Gradient {
6565
// MARK: - Pre iOS 17
6666

6767
extension Gradient {
68-
// Creates a gradient with the given easing function.
69-
//
70-
// - Parameters:
71-
// - from: The start color.
72-
// - to: The end color.
73-
// - curve: The easing function to use.
74-
// - steps: The number of steps to use when generating the gradient. Defaults to 16.
75-
// - Returns: A gradient.
68+
/// Creates a gradient with the given easing function.
69+
///
70+
/// - Parameters:
71+
/// - from: The start color.
72+
/// - to: The end color.
73+
/// - curve: The easing function to use.
74+
/// - steps: The number of steps to use when generating the gradient. Defaults to 16.
75+
/// - Returns: A gradient.
7676
@available(iOS, introduced: 14.0, deprecated: 17.0, renamed: "smooth(from:to:curve:steps:)")
7777
@available(macOS, introduced: 11.0, deprecated: 14.0, renamed: "smooth(from:to:curve:steps:)")
7878
@available(tvOS, introduced: 14.0, deprecated: 17.0, renamed: "smooth(from:to:curve:steps:)")
@@ -92,14 +92,14 @@ extension Gradient {
9292
)
9393
}
9494

95-
// Creates a gradient with the given easing function.
96-
//
97-
// - Parameters:
98-
// - from: The start color.
99-
// - to: The end color.
100-
// - curve: The easing function to use.
101-
// - steps: The number of steps to use when generating the gradient. Defaults to 16.
102-
// - Returns: A gradient.
95+
/// Creates a gradient with the given easing function.
96+
///
97+
/// - Parameters:
98+
/// - from: The start color.
99+
/// - to: The end color.
100+
/// - curve: The easing function to use.
101+
/// - steps: The number of steps to use when generating the gradient. Defaults to 16.
102+
/// - Returns: A gradient.
103103
@available(iOS, introduced: 14.0, deprecated: 17.0, renamed: "smooth(from:to:curve:steps:)")
104104
@available(macOS, introduced: 11.0, deprecated: 14.0, renamed: "smooth(from:to:curve:steps:)")
105105
@available(tvOS, introduced: 14.0, deprecated: 17.0, renamed: "smooth(from:to:curve:steps:)")

Sources/SmoothGradient/SmoothLinearGradient.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import SwiftUI
1212

1313
#if compiler(>=5.9)
14+
/// A smooth linear gradient.
1415
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
1516
public struct SmoothLinearGradient: ShapeStyle, View {
1617
let from: Gradient.Stop
@@ -20,6 +21,15 @@ public struct SmoothLinearGradient: ShapeStyle, View {
2021
let curve: UnitCurve
2122
let steps: Int
2223

24+
/// Creates a smooth gradient from two colors.
25+
///
26+
/// - Parameters:
27+
/// - from: The start color.
28+
/// - to: The end color.
29+
/// - startPoint: Origin of the gradient.
30+
/// - endPoint: End point of the gradient. Together with `startPoint` defines the gradient's direction.
31+
/// - curve: Easing curve to use.
32+
/// - steps: Number of steps to use when generating the gradient. Defaults to 16.
2333
public init(
2434
from: Color,
2535
to: Color,
@@ -38,6 +48,15 @@ public struct SmoothLinearGradient: ShapeStyle, View {
3848
)
3949
}
4050

51+
/// Creates a smooth gradient from two color stops.
52+
///
53+
/// - Parameters:
54+
/// - from: The start color.
55+
/// - to: The end color.
56+
/// - startPoint: Origin of the gradient.
57+
/// - endPoint: End point of the gradient. Together with `startPoint` defines the gradient's direction.
58+
/// - curve: Easing curve to use.
59+
/// - steps: Number of steps to use when generating the gradient. Defaults to 16.
4160
public init(
4261
from: Gradient.Stop,
4362
to: Gradient.Stop,

0 commit comments

Comments
 (0)