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
21 changes: 12 additions & 9 deletions .github/workflows/wasmBuild.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: WebAssembly build
on: [push, pull_request]
jobs:
test:
build:
name: BezierKit WASM support
runs-on: ubuntu-latest
container: ghcr.io/swiftwasm/carton:0.16.0

steps:
- uses: actions/checkout@v2

# Carton is not able to find our tests if LinuxMain.swift file is defined
- name: Remove LinuxMain.swift file
run: rm BezierKit/LinuxMain.swift
- uses: actions/checkout@v4

- name: Test
run: carton test
- uses: swift-actions/setup-swift@v3
with:
swift-version: main-snapshot-2026-06-24
skip-verify-signature: true

- name: Install WebAssembly SDK
run: swift sdk install --checksum b8e808d6c1b83636c68668eea27f504ac07973f0f8c68d0d053d11ef4eb96a44 https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2026-06-24-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2026-06-24-a-wasm32-unknown-wasip1-threads.artifactbundle.zip

- name: Build
run: swift build --build-system native --swift-sdk DEVELOPMENT-SNAPSHOT-2026-06-24-a-wasm32-unknown-wasip1-threads
16 changes: 9 additions & 7 deletions BezierKit/BezierKitTests/BoundingBoxTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ class BoundingBoxTests: XCTestCase {
XCTAssertEqual(box2.union(Point(x: 1, y: 7)), BoundingBox(p1: Point(x: -2, y: -1), p2: Point(x: 3, y: 7)))
}

func testCGRect() {
// test a standard box
let box1 = BoundingBox(p1: Point(x: 2.0, y: 3.0), p2: Point(x: 3.0, y: 5.0))
XCTAssertEqual(box1.cgRect, Rect(origin: Point(x: 2.0, y: 3.0), size: CGSize(width: 1.0, height: 2.0)).cgRect)
// test the empty box
XCTAssertEqual(BoundingBox.empty.cgRect, CGRect.null)
}
#if canImport(CoreGraphics)
func testCGRect() {
// test a standard box
let box1 = BoundingBox(p1: Point(x: 2.0, y: 3.0), p2: Point(x: 3.0, y: 5.0))
XCTAssertEqual(box1.cgRect, Rect(origin: Point(x: 2.0, y: 3.0), size: CGSize(width: 1.0, height: 2.0)).cgRect)
// test the empty box
XCTAssertEqual(BoundingBox.empty.cgRect, CGRect.null)
}
#endif

func testInitFirstSecond() {
let box1 = BoundingBox(p1: Point(x: 2.0, y: 3.0), p2: Point(x: 3.0, y: 5.0))
Expand Down
24 changes: 24 additions & 0 deletions BezierKit/Library/Math.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ enum BezierMath {
WASILibc.sqrt(x)
}
}
#elseif canImport(Android)
import Android

enum BezierMath {
static func acos(_ x: Double) -> Double {
Android.acos(x)
}

static func atan2(_ y: Double, _ x: Double) -> Double {
Android.atan2(y, x)
}

static func cos(_ x: Double) -> Double {
Android.cos(x)
}

static func pow(_ x: Double, _ y: Double) -> Double {
Android.pow(x, y)
}

static func sqrt(_ x: Double) -> Double {
Android.sqrt(x)
}
}
#elseif canImport(Glibc)
import Glibc

Expand Down
Loading