Skip to content

Commit

Permalink
Merge branch 'hfutrell:master' into geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
Legonaftik authored Jan 30, 2024
2 parents ac09a2c + 11a87c2 commit d383df5
Show file tree
Hide file tree
Showing 27 changed files with 289 additions and 127 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: BezierKit Mac + Linux

on: [push, pull_request]

jobs:
Mac:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: swift build
- name: Run tests
run: |
swift test --enable-test-discovery --enable-code-coverage
xcrun llvm-cov export -format="lcov" .build/debug/BezierKitPackageTests.xctest/Contents/MacOS/BezierKitPackageTests -instr-profile .build/debug/codecov/default.profdata > info.lcov
- name: code coverage upload to codecov.io
uses: codecov/[email protected]
with:
file: info.lcov
Linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: swift build
- name: Run tests
run: swift test --enable-test-discovery
17 changes: 17 additions & 0 deletions .github/workflows/wasmBuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: WebAssembly build
on: [push, pull_request]
jobs:
test:
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

- name: Test
run: carton test
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion BezierKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Pod::Spec.new do |s|
s.name = "BezierKit"
s.version = "0.13.0"
s.version = "0.15.0"
s.summary = "comprehensive Bezier Path library written in Swift"
s.homepage = "https://github.com/hfutrell/BezierKit"
s.license = "MIT"
Expand Down
8 changes: 7 additions & 1 deletion BezierKit/BezierKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
FD26253F1EAC7B9A00C64652 /* BezierKit_iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = FD26253D1EAC7B9A00C64652 /* BezierKit_iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
FD26915C238B628B002036A6 /* ReversibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD26915B238B628B002036A6 /* ReversibleTests.swift */; };
FD26915D238B628B002036A6 /* ReversibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD26915B238B628B002036A6 /* ReversibleTests.swift */; };
FD3530F327DC140F006E9726 /* BezierKit-ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3530F227DC140E006E9726 /* BezierKit-ObjC.swift */; };
FD3530F427DC140F006E9726 /* BezierKit-ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD3530F227DC140E006E9726 /* BezierKit-ObjC.swift */; };
FD4024502110CF5100FA723C /* QuadraticCurveTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD40244F2110CF5100FA723C /* QuadraticCurveTests.swift */; };
FD4024512110CF5100FA723C /* QuadraticCurveTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD40244F2110CF5100FA723C /* QuadraticCurveTests.swift */; };
FD4A0DC41EAAD01F0031A393 /* BezierKit_Mac.h in Headers */ = {isa = PBXBuildFile; fileRef = FD4A0DC21EAAD01F0031A393 /* BezierKit_Mac.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -176,6 +178,7 @@
FD26253D1EAC7B9A00C64652 /* BezierKit_iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BezierKit_iOS.h; sourceTree = "<group>"; };
FD26253E1EAC7B9A00C64652 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
FD26915B238B628B002036A6 /* ReversibleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReversibleTests.swift; sourceTree = "<group>"; };
FD3530F227DC140E006E9726 /* BezierKit-ObjC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BezierKit-ObjC.swift"; sourceTree = "<group>"; };
FD40244F2110CF5100FA723C /* QuadraticCurveTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuadraticCurveTests.swift; sourceTree = "<group>"; };
FD4A0DC01EAAD01F0031A393 /* BezierKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BezierKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FD4A0DC21EAAD01F0031A393 /* BezierKit_Mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BezierKit_Mac.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -378,6 +381,7 @@
FD4A63FD200AA50B00930E10 /* Shape.swift */,
FDB6B3FF1EAFD6DF00001C61 /* Types.swift */,
FDB6B4001EAFD6DF00001C61 /* Utils.swift */,
FD3530F227DC140E006E9726 /* BezierKit-ObjC.swift */,
);
path = Library;
sourceTree = "<group>";
Expand Down Expand Up @@ -536,7 +540,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1340;
ORGANIZATIONNAME = "Holmes Futrell";
TargetAttributes = {
FD0F54F41DC43FFB0084CDCD = {
Expand Down Expand Up @@ -704,6 +708,7 @@
FDB6B4031EAFD6DF00001C61 /* BezierCurve.swift in Sources */,
FDB6B4051EAFD6DF00001C61 /* CubicCurve.swift in Sources */,
FDE6CD8D1EC8F2F800FAB479 /* LineSegment.swift in Sources */,
FD3530F427DC140F006E9726 /* BezierKit-ObjC.swift in Sources */,
FD149EBB2135CBFF009E791D /* AugmentedGraph.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -735,6 +740,7 @@
FDB6B4021EAFD6DF00001C61 /* BezierCurve.swift in Sources */,
FDB6B4041EAFD6DF00001C61 /* CubicCurve.swift in Sources */,
FDE6CD8C1EC8F2F800FAB479 /* LineSegment.swift in Sources */,
FD3530F327DC140F006E9726 /* BezierKit-ObjC.swift in Sources */,
FD149EBA2135CBFF009E791D /* AugmentedGraph.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
3 changes: 3 additions & 0 deletions BezierKit/BezierKitTests/CubicCurveTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ class CubicCurveTests: XCTestCase {
XCTAssertEqual(c1.intersections(with: c2, accuracy: 1.0e-8), expectedIntersections)
}

// Skip on platforms where CGFloat is 32bit
#if !(arch(i386) || arch(arm) || arch(wasm32))
func testRealWorldNearlyCoincidentCurvesIntersection() {
// these curves are nearly coincident over from c1's t = 0.278 to 1.0
// staying roughly 0.0002 distance of eachother
Expand All @@ -524,6 +526,7 @@ class CubicCurveTests: XCTestCase {
XCTAssertEqual(intersections[1].t1, 1)
XCTAssertEqual(intersections[1].t2, 0)
}
#endif

func testIntersectionsCubicButActuallyLinear() {
// this test presents a challenge for an implicitization based approach
Expand Down
2 changes: 2 additions & 0 deletions BezierKit/BezierKitTests/LockTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import XCTest
@testable import BezierKit

#if !os(WASI)
class LockTests: XCTestCase {
func testPathPropertyAtomicity() {
// ensure that lazy properties of Path are only initialized once
Expand Down Expand Up @@ -53,3 +54,4 @@ class LockTests: XCTestCase {
XCTAssertTrue(boundingBoxes.values.allSatisfy { $0 == expectedBoundingBox })
}
}
#endif
3 changes: 3 additions & 0 deletions BezierKit/BezierKitTests/Path+VectorBooleanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

@testable import BezierKit
#if canImport(CoreGraphics)
import CoreGraphics
#endif
import XCTest

internal extension Path {
Expand Down
2 changes: 2 additions & 0 deletions BezierKit/BezierKitTests/PathTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,7 @@ class PathTests: XCTestCase {
XCTAssertEqual(path2.boundingBoxOfPath, BoundingBox(p1: CGPoint(x: 1, y: 0), p2: CGPoint(x: 3, y: 4)))
}

#if !os(WASI)
func testNSCoder() {
// just some random curves, but we ensure they're continuous
let l1 = LineSegment(p0: CGPoint(x: 4.9652, y: 8.2774),
Expand Down Expand Up @@ -1762,6 +1763,7 @@ class PathTests: XCTestCase {
}
XCTAssertEqual(path, decodedPath)
}
#endif

func testIndexedPathLocation() {
let location1 = IndexedPathLocation(componentIndex: 0, elementIndex: 1, t: 0.5)
Expand Down
2 changes: 2 additions & 0 deletions BezierKit/BezierKitTests/PerformanceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import BezierKit
import XCTest

#if !os(WASI)
private extension PerformanceTests {

func generateRandomCurves(count: Int, selfIntersect: Bool? = nil, reseed: Int? = nil) -> [CubicCurve] {
Expand Down Expand Up @@ -229,3 +230,4 @@ class PerformanceTests: XCTestCase {

#endif
}
#endif
5 changes: 3 additions & 2 deletions BezierKit/BezierKitTests/PolynomialTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class PolynomialTests: XCTestCase {
XCTAssertEqual(roots[2], 1, accuracy: accuracy)
XCTAssertEqual(roots[3], 1.2, accuracy: accuracy)
}

// Skip on platforms where CGFloat is 32bit
#if !(arch(i386) || arch(arm) || arch(wasm32))
func testDegree4RepeatedRoots() {
// x^4 - 2x^2 + 1
let polynomial = BernsteinPolynomial4(b0: 1, b1: 1, b2: 2.0 / 3.0, b3: 0, b4: 0)
Expand All @@ -102,7 +103,7 @@ class PolynomialTests: XCTestCase {
XCTAssertEqual(roots[0], -1, accuracy: accuracy)
XCTAssertEqual(roots[1], 1, accuracy: accuracy)
}

#endif
func testDegree5() {
// 0.2x^5 - 0.813333x^3 - 8.56x
let polynomial = BernsteinPolynomial5(b0: 0, b1: -1.712, b2: -3.424, b3: -5.2173333, b4: -7.1733332, b5: -9.173333)
Expand Down
2 changes: 2 additions & 0 deletions BezierKit/BezierKitTests/TransformableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import XCTest
@testable import BezierKit

#if canImport(CoreGraphics)
class TransformableTests: XCTestCase {

// rotates by 90 degrees ccw and then shifts (-1, 1)
Expand Down Expand Up @@ -82,3 +83,4 @@ class TransformableTests: XCTestCase {
}

}
#endif
Loading

0 comments on commit d383df5

Please sign in to comment.