-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71e2113
commit b2e2220
Showing
20 changed files
with
451 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,3 +89,4 @@ fastlane/test_output | |
|
||
iOSInjectionProject/ | ||
*.DS_Store | ||
*.swiftpm |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
/// Returns x, such that min ≤ x ≤ max | ||
/// | ||
/// - parameter x: value to be clamped | ||
/// - parameter min: minimum | ||
/// - parameter max: maximum | ||
/// Clamps a value to the specified range | ||
/// - Parameters: | ||
/// - x: The value to be clamped | ||
/// - min: The minimum value | ||
/// - max: The maximum value | ||
/// - Returns: The clamped value | ||
public func clamp<T>(_ x: T, min _min: T, max _max: T) -> T where T: Comparable { | ||
return min(max(x, _min), _max) | ||
} | ||
|
||
/// Returns x, where 0.0 ≤ x ≤ 1.0 | ||
/// Clamps a value to the range [0.0, 1.0] | ||
/// - Parameter x: The value to be clamped | ||
/// - Returns: The clamped value | ||
public func saturate<T>(_ x: T) -> T where T: BinaryFloatingPoint { | ||
return clamp(x, min: 0.0, max: 1.0) | ||
} | ||
|
||
/// Performs a linear interpolation between a and b by the interpolant t | ||
/// | ||
/// - parameter a: start value | ||
/// - parameter b: end value | ||
/// - parameter t: interpolant | ||
/// | ||
/// - returns: a value interpolated from a to b | ||
public func interpolate<T>(a: T, b: T, t: T) -> T where T: BinaryFloatingPoint { | ||
/// Performs a linear interpolation between two values | ||
/// - Parameters: | ||
/// - a: The start value | ||
/// - b: The end value | ||
/// - t: The interpolant | ||
/// - Returns: A value interpolated from a to b | ||
public func interpolate<T>(a: T, b: T, t: T) -> T where T: BinaryFloatingPoint { | ||
return a + (b - a) * t | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Helper Functions | ||
|
||
## Clamping Values | ||
|
||
Clamp a value to a specified range: | ||
|
||
```swift | ||
let clampedValue = clamp(5, min: 1, max: 10) // 5 | ||
let clampedValue2 = clamp(15, min: 1, max: 10) // 10 | ||
``` | ||
|
||
## Saturating Values | ||
|
||
Saturate a value to the range [0.0, 1.0]: | ||
|
||
```swift | ||
let saturatedValue = saturate(1.5) // 1.0 | ||
let saturatedValue2 = saturate(-0.5) // 0.0 | ||
``` | ||
|
||
## Linear Interpolation | ||
|
||
Perform a linear interpolation between two values: | ||
|
||
```swift | ||
let start: Float = 0.0 | ||
let end: Float = 10.0 | ||
let t: Float = 0.5 | ||
let interpolatedValue = interpolate(a: start, b: end, t: t) // 5.0 | ||
``` |
Binary file added
BIN
+797 KB
Sources/SIMDTools/SIMDTools.docc/Resources/documentation-art/simd-tools@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+176 KB
...SIMDTools.docc/Resources/rotate-image-art/preview-01-creating-code-04-06@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+182 KB
...ools.docc/Resources/rotate-image-art/preview-01-creating-code-04-06~dark@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-19.7 KB
(89%)
...ols/SIMDTools.docc/Resources/rotate-image-art/select-interface-type~dark@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
6 changes: 3 additions & 3 deletions
6
Sources/SIMDTools/SIMDTools.docc/Tutorials/SIMDTools.tutorial
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
@Tutorials(name: "SIMDTools") { | ||
@Intro(title: "Meet SIMDTools") { | ||
Learn how to use SIMD matrices to calculate affine transform for rotating images. Get started with SIMDTools by buildiong the demo app _RotateImage_. | ||
Learn how to use SIMD matrices to calculate affine transform for rotating SwiftUI views. Get started with SIMDTools by building the demo app _RotateImage_. | ||
|
||
@Image(source: simd-tools.png, alt: "SIMDTools icon.") | ||
} | ||
@Chapter(name: "Rotating Image In SwiftUI") { | ||
@Chapter(name: "SIMDTools Essentials") { | ||
@Image(source: chapter1-rotate-image.png, alt: "Rotate Image app main sceen.") | ||
|
||
Construct a rotation affine transform using SIMDTools and apply it to rotate an image. | ||
|
||
@TutorialReference(tutorial: "doc:RotatingImageInSwiftUI") | ||
@TutorialReference(tutorial: "doc:ApplyingAffineTransformsToSwiftUIViewsWithMetal") | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.