Skip to content

Commit db6b657

Browse files
Standard Library Conformances (#3)
1 parent f77bafb commit db6b657

20 files changed

+406
-338
lines changed

.github/workflows/swift.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,28 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
workflow_dispatch:
89

910
jobs:
10-
macos-build:
11+
SwiftActions:
12+
strategy:
13+
matrix:
14+
os: [macos-latest, ubuntu-latest]
1115

12-
runs-on: macos-latest
16+
runs-on: ${{ matrix.os }}
1317

1418
steps:
15-
- uses: actions/checkout@v2
16-
- name: Build (macOS)
17-
run: swift build -v
18-
- name: Run tests
19-
run: swift test -v
20-
21-
ubuntu-build:
19+
- name: Checkout Source
20+
uses: actions/checkout@v4
2221

23-
runs-on: ubuntu-latest
22+
- name: Lint
23+
if: ${{ runner.os == 'macOS' }}
24+
shell: bash
25+
run: swiftformat --lint . --reporter github-actions-log
2426

25-
steps:
26-
- uses: actions/checkout@v2
27-
- name: Build (Ubuntu)
28-
run: swift build -v
29-
- name: Run tests
30-
run: swift test -v
27+
- name: Swift Build
28+
uses: SwiftActions/SwiftBuild@main
29+
30+
- name: Swift Test
31+
uses: SwiftActions/SwiftTest@main
32+

.spi.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- documentation_targets: [GraphPoint]

.swiftformat

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Compiler
2+
--languagemode 5
3+
--swiftversion 5.9
4+
5+
# Options
6+
--exclude derivedData
7+
--ifdef no-indent
8+
--indent 4
9+
10+
# Rules
11+
--disable blankLinesAtStartOfScope
12+
--disable hoistPatternLet
13+
--disable redundantType
14+
--disable unusedArguments
15+
--disable wrapArguments

Package.resolved

Lines changed: 20 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.9
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
77
name: "GraphPoint",
88
platforms: [
9-
.macOS(.v10_13),
10-
.iOS(.v11),
11-
.tvOS(.v11),
12-
.watchOS(.v4),
9+
.macOS(.v13),
10+
.macCatalyst(.v16),
11+
.iOS(.v16),
12+
.tvOS(.v16),
13+
.watchOS(.v9),
1314
],
1415
products: [
1516
.library(
1617
name: "GraphPoint",
1718
targets: ["GraphPoint"]),
1819
],
1920
dependencies: [
20-
.package(url: "https://github.com/richardpiazza/Swift2D", .upToNextMajor(from: "2.0.0")),
21+
.package(url: "https://github.com/richardpiazza/Swift2D", .upToNextMajor(from: "2.2.0")),
22+
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.55.0"),
2123
],
2224
targets: [
2325
.target(

README.md

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,16 @@
22
<img src="Resources/GraphPoint.png" width="1000" max-width="90%" alt="GraphPoint" />
33
</p>
44

5-
<p align="center">
6-
<img src="https://github.com/richardpiazza/GraphPoint/workflows/Swift/badge.svg?branch=main" />
7-
<img src="https://img.shields.io/badge/Swift-5.0-orange.svg" />
8-
<a href="https://twitter.com/richardpiazza">
9-
<img src="https://img.shields.io/badge/twitter-@richardpiazza-blue.svg?style=flat" alt="Twitter: @richardpiazza" />
10-
</a>
11-
</p>
12-
13-
<p align="center">
14-
A Swift implementation of the <a href="https://en.wikipedia.org/wiki/Cartesian_coordinate_system">Cartesian Coordinate System</a>.
15-
</p>
16-
17-
## Installation
18-
19-
**GraphPoint** is distributed using the [Swift Package Manager](https://swift.org/package-manager). To install it into a project, add it as a
20-
dependency within your `Package.swift` manifest:
21-
22-
```swift
23-
let package = Package(
24-
...
25-
dependencies: [
26-
.package(url: "https://github.com/richardpiazza/GraphPoint.git", from: "4.0.0")
27-
],
28-
...
29-
)
30-
```
31-
32-
Then import **GraphPoint** wherever you'd like to use it:
5+
A Swift implementation of the <a href="https://en.wikipedia.org/wiki/Cartesian_coordinate_system">Cartesian Coordinate System</a>.
336

34-
```swift
35-
import GraphPoint
36-
```
7+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Frichardpiazza%2FGraphPoint%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/richardpiazza/GraphPoint)
8+
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Frichardpiazza%2FGraphPoint%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/richardpiazza/GraphPoint)
379

3810
## Dependencies
3911

4012
**GraphPoint** relies heavily on the **[Swift2D](https://github.com/richardpiazza/Swift2D)** library, which reimplements `Rect`, `Size`, and
4113
`Point` in a cross-platform, non-Foundation reliant way.
4214

43-
## Deprecations
44-
45-
The `CoreGraphics` aliases have been deprecated and replaced by their _Cartesian_ counterparts. These type-aliases and
46-
**GraphPointUI** will be removed in a future version.
47-
4815
## Usage
4916

5017
There are several key aspects to understand when using **GraphPoint**.
@@ -73,3 +40,29 @@ cartesianFrame == Rect(origin: Point(x: -10, y: 10), size: Size(width: 10, heigh
7340
### `CartesianPoint`
7441

7542
A point within a `CartesianPlane`. The x & y coordinates of a `CartesianPoint` represent the offset from the planes 'origin' (0, 0).
43+
44+
## Deprecations
45+
46+
The `CoreGraphics` aliases have been deprecated and replaced by their _Cartesian_ counterparts. These type-aliases and
47+
**GraphPointUI** will be removed in a future version.
48+
49+
## Installation
50+
51+
**GraphPoint** is distributed using the [Swift Package Manager](https://swift.org/package-manager). To install it into a project, add it as a
52+
dependency within your `Package.swift` manifest:
53+
54+
```swift
55+
let package = Package(
56+
...
57+
dependencies: [
58+
.package(url: "https://github.com/richardpiazza/GraphPoint.git", from: "4.0.0")
59+
],
60+
...
61+
)
62+
```
63+
64+
Then import **GraphPoint** wherever you'd like to use it:
65+
66+
```swift
67+
import GraphPoint
68+
```

Sources/GraphPoint/Arc.swift

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
/// Arc of a circle (a continuous length around the circumference)
2-
public struct Arc {
2+
public struct Arc: Hashable, Codable, Sendable {
33
public var radius: Radius
44
public var startingDegree: Degree
55
public var endingDegree: Degree
66
public var clockwise: Bool
7-
8-
public init(radius: Radius = 0.0, startingDegree: Degree = 0.0, endingDegree: Degree = 0.0, clockwise: Bool = true) {
7+
8+
public init(
9+
radius: Radius = 0.0,
10+
startingDegree: Degree = 0.0,
11+
endingDegree: Degree = 0.0,
12+
clockwise: Bool = true
13+
) {
914
self.radius = radius
1015
self.startingDegree = startingDegree
1116
self.endingDegree = endingDegree
@@ -19,37 +24,41 @@ public extension Arc {
1924
guard let point = try? CartesianPoint.make(for: radius, degree: startingDegree) else {
2025
return .zero
2126
}
22-
27+
2328
return point
2429
}
25-
30+
2631
/// The `CartesianPoint` that represents the ending point
2732
var endingPoint: CartesianPoint {
2833
guard let point = try? CartesianPoint.make(for: radius, degree: endingDegree) else {
2934
return .zero
3035
}
31-
36+
3237
return point
3338
}
34-
39+
3540
/// Calculates the point of the right angle that joins the start and end points.
3641
var pivotPoint: CartesianPoint {
3742
var pivot = CartesianPoint(x: 0, y: 0)
38-
43+
3944
if startingDegree < 90 {
40-
pivot.x = endingPoint.x
41-
pivot.y = startingPoint.y
45+
pivot = pivot
46+
.with(x: endingPoint.x)
47+
.with(y: startingPoint.y)
4248
} else if startingDegree < 180 {
43-
pivot.x = startingPoint.x
44-
pivot.y = endingPoint.y
49+
pivot = pivot
50+
.with(x: startingPoint.x)
51+
.with(y: endingPoint.y)
4552
} else if startingDegree < 270 {
46-
pivot.x = endingPoint.x
47-
pivot.y = startingPoint.y
53+
pivot = pivot
54+
.with(x: endingPoint.x)
55+
.with(y: startingPoint.y)
4856
} else {
49-
pivot.x = startingPoint.x
50-
pivot.y = endingPoint.y
57+
pivot = pivot
58+
.with(x: startingPoint.x)
59+
.with(y: endingPoint.y)
5160
}
52-
61+
5362
return pivot
5463
}
5564
}

0 commit comments

Comments
 (0)