Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,20 @@ jobs:
uses: skiptools/swift-android-action@v2
with:
swift-version: 6.2

windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Swift
uses: compnerd/gha-setup-swift@main
with:
branch: swift-6.1.2-release
tag: 6.1.2-RELEASE
- name: Version
run: swift --version
- name: Build
run: swift build --build-tests
- name: Test
run: swift test --skip-build
2 changes: 2 additions & 0 deletions CommandLine/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import Darwin.POSIX
#elseif canImport(Android)
import Android
#elseif canImport(ucrt)
import ucrt
#else
import Glibc
#endif
Expand Down
6 changes: 4 additions & 2 deletions SwiftDraw/Sources/LayerTree/LayerTree.Transform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import Darwin
#elseif canImport(Android)
import Android
#elseif canImport(ucrt)
import ucrt
#else
import Glibc
#endif
Expand Down Expand Up @@ -117,8 +119,8 @@ extension Array where Element == LayerTree.Transform {
}
}

#if os(Android)
// The Android module does not have Float overloads for the various math functions
#if os(Android) || os(Windows)
// The Android/Windows modules do not have Float overloads for the various math functions
func tan(_ value: Float) -> Float { tanf(value) }
func atan(_ value: Float) -> Float { atanf(value) }
func cos(_ value: Float) -> Float { cosf(value) }
Expand Down
12 changes: 9 additions & 3 deletions SwiftDraw/Tests/LayerTree/LayerTree.TransformTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ final class LayerTreeTransformTests: XCTestCase {

func testSkewXMatrix() {
let transform = Transform.skewX(angle: LayerTree.Float.pi/4)
XCTAssertEqual(transform.toMatrix(), Matrix(a: 1, b: 0, c: tan(LayerTree.Float.pi/4), d: 1, tx: 0, ty: 0))
let angle = LayerTree.Float.pi / 4
XCTAssertEqual(transform.toMatrix(), Matrix(a: 1, b: 0, c: LayerTree.Float(tan(Double(angle))), d: 1, tx: 0, ty: 0))
}

func testSkewYMatrix() {
let transform = Transform.skewY(angle: LayerTree.Float.pi/4)
XCTAssertEqual(transform.toMatrix(), Matrix(a: 1, b: tan(LayerTree.Float.pi/4), c: 0, d: 1, tx: 0, ty: 0))
let angle = LayerTree.Float.pi / 4
XCTAssertEqual(transform.toMatrix(), Matrix(a: 1, b: LayerTree.Float(tan(Double(angle))), c: 0, d: 1, tx: 0, ty: 0))
}

func testScaleMatrix() {
Expand All @@ -59,7 +61,11 @@ final class LayerTreeTransformTests: XCTestCase {
let angle = LayerTree.Float.pi/4
let transform = Transform.rotate(radians: angle)
XCTAssertEqual(transform.toMatrix(),
Matrix(a: cos(angle), b: sin(angle), c: -sin(angle), d: cos(angle), tx: 0, ty: 0))
Matrix(a: LayerTree.Float(cos(Double(angle))),
b: LayerTree.Float(sin(Double(angle))),
c: -LayerTree.Float(sin(Double(angle))),
d: LayerTree.Float(cos(Double(angle))),
tx: 0, ty: 0))
}

func testMatrixConcatenation() {
Expand Down
Loading