-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from RougeWare/feature/Scaling
`Rectangle` & `TwoDimensional` can now be scaled!
- Loading branch information
Showing
9 changed files
with
1,880 additions
and
12 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
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,16 @@ | ||
name: macOS | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
|
||
timeout-minutes: 5 | ||
runs-on: macOS-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Build | ||
run: swift build -v | ||
- name: Run tests | ||
run: swift test -v |
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
471 changes: 471 additions & 0 deletions
471
Sources/RectangleTools/Synthesized Conveniences/scaled.swift
Large diffs are not rendered by default.
Oops, something went wrong.
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
59 changes: 59 additions & 0 deletions
59
Tests/RectangleToolsTests/Testing convenience functions.swift
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,59 @@ | ||
// | ||
// Testing convenience functions.swift | ||
// | ||
// | ||
// Created by Ky Leggiero on 2022-01-11. | ||
// | ||
|
||
import Foundation | ||
import RectangleTools | ||
|
||
|
||
|
||
infix operator &&= : AssignmentPrecedence | ||
infix operator ≈≈ : ComparisonPrecedence | ||
|
||
|
||
|
||
/// Shorthand for `lhs = lhs && rhs` | ||
func &&= (lhs: inout Bool, rhs: @autoclosure () -> Bool) { | ||
if lhs, !rhs() { | ||
lhs = false | ||
} | ||
} | ||
|
||
|
||
|
||
/// Whether the left-hand-side argument is approximately equal to the right-hand-side | ||
func ≈≈ <Value> (lhs: Value, rhs: Value) -> Bool | ||
where Value: FloatingPoint, | ||
Value: ExpressibleByFloatLiteral | ||
{ | ||
abs(rhs - lhs) < .approximationTolerance | ||
} | ||
|
||
|
||
|
||
/// Whether the left-hand-side argument is approximately equal to the right-hand-side | ||
func ≈≈ <Value> (lhs: Value, rhs: Value) -> Bool | ||
where Value: TwoDimensional, | ||
Value.Length: FloatingPoint, | ||
Value.Length: ExpressibleByFloatLiteral | ||
{ | ||
lhs.measurementX ≈≈ rhs.measurementX | ||
&& lhs.measurementY ≈≈ rhs.measurementY | ||
} | ||
|
||
|
||
|
||
/// Whether the left-hand-side argument is approximately equal to the right-hand-side | ||
func ≈≈ <Value> (lhs: Value, rhs: Value) -> Bool | ||
where Value: DualTwoDimensional, | ||
Value.FirstDimensionPair.Length: FloatingPoint, | ||
Value.FirstDimensionPair.Length: ExpressibleByFloatLiteral, | ||
Value.SecondDimensionPair.Length: FloatingPoint, | ||
Value.SecondDimensionPair.Length: ExpressibleByFloatLiteral | ||
{ | ||
lhs.firstDimensionPair ≈≈ rhs.firstDimensionPair | ||
&& lhs.secondDimensionPair ≈≈ rhs.secondDimensionPair | ||
} |
Oops, something went wrong.