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
84 changes: 84 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Pull Request

on:
pull_request:
branches: [ main ]
workflow_dispatch:

env:
SCHEME: "GraphPoint"

jobs:
Lint:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Lint
run: swiftformat --lint . --reporter github-actions-log

Swift:
strategy:
fail-fast: false
matrix:
os: [
macos-latest,
ubuntu-latest,
]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache
uses: actions/cache@v5
with:
path: |
.build
~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex
~/Library/Caches/org.swift.swiftpm
~/Library/org.swift.swiftpm
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.swift', '**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Package Resolution
run: swift package resolve
- name: Build
run: swift build
- name: Test
run: swift test

Xcode:
strategy:
fail-fast: false
matrix:
platform: [
"macOS",
"iOS",
"tvOS",
"watchOS",
"visionOS",
"macOS,variant=Mac Catalyst",
]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache
uses: actions/cache@v5
with:
path: |
.build
~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex
~/Library/Caches/org.swift.swiftpm
~/Library/org.swift.swiftpm
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.swift', '**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Package Resolution
shell: bash
run: xcodebuild -resolvePackageDependencies | xcbeautify
- name: Build
shell: bash
env:
DESTINATION: "generic/platform=${{ matrix.platform }}"
run: xcodebuild build -scheme "$SCHEME" -destination "$DESTINATION" | xcbeautify
32 changes: 0 additions & 32 deletions .github/workflows/swift.yml

This file was deleted.

6 changes: 5 additions & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Compiler
--languagemode 5
--swiftversion 5.9
--swiftversion 6.2

# Options
--exclude derivedData
Expand All @@ -10,6 +10,10 @@
# Rules
--disable blankLinesAtStartOfScope
--disable hoistPatternLet
--disable nestedIf
--disable redundantType
--disable repeatedGuard
--disable swiftTestingTestCaseNames
--disable unusedArguments
--disable wrapArguments
--disable wrapPropertyBodies
16 changes: 4 additions & 12 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -11,15 +11,15 @@ let package = Package(
.iOS(.v16),
.tvOS(.v16),
.watchOS(.v9),
.visionOS(.v1), // .v2 ~ iOS 18
],
products: [
.library(
name: "GraphPoint",
targets: ["GraphPoint"]),
],
dependencies: [
.package(url: "https://github.com/richardpiazza/Swift2D", .upToNextMajor(from: "2.2.0")),
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.55.0"),
.package(url: "https://github.com/richardpiazza/Swift2D", from: "2.3.0"),
],
targets: [
.target(
Expand All @@ -29,5 +29,5 @@ let package = Package(
name: "GraphPointTests",
dependencies: ["GraphPoint"]),
],
swiftLanguageVersions: [.v5]
swiftLanguageModes: [.v5],
)
18 changes: 9 additions & 9 deletions Sources/GraphPoint/Arc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public struct Arc: Hashable, Codable, Sendable {
radius: Radius = 0.0,
startingDegree: Degree = 0.0,
endingDegree: Degree = 0.0,
clockwise: Bool = true
clockwise: Bool = true,
) {
self.radius = radius
self.startingDegree = startingDegree
Expand Down Expand Up @@ -43,20 +43,20 @@ public extension Arc {

if startingDegree < 90 {
pivot = pivot
.with(x: endingPoint.x)
.with(y: startingPoint.y)
.x(endingPoint.x)
.y(startingPoint.y)
} else if startingDegree < 180 {
pivot = pivot
.with(x: startingPoint.x)
.with(y: endingPoint.y)
.x(startingPoint.x)
.y(endingPoint.y)
} else if startingDegree < 270 {
pivot = pivot
.with(x: endingPoint.x)
.with(y: startingPoint.y)
.x(endingPoint.x)
.y(startingPoint.y)
} else {
pivot = pivot
.with(x: startingPoint.x)
.with(y: endingPoint.y)
.x(startingPoint.x)
.y(endingPoint.y)
}

return pivot
Expand Down
32 changes: 16 additions & 16 deletions Sources/GraphPoint/CartesianFrame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,28 @@ public extension CartesianFrame {

for point in points {
if point.x < minXMaxY.x || minXMaxY.x == 0 {
minXMaxY = minXMaxY.with(x: point.x)
minXMaxY = minXMaxY.x(point.x)
}

if point.y > minXMaxY.y || minXMaxY.y == 0 {
minXMaxY = minXMaxY.with(y: point.y)
minXMaxY = minXMaxY.y(point.y)
}

if point.x > maxXMinY.x || maxXMinY.x == 0 {
maxXMinY = maxXMinY.with(x: point.x)
maxXMinY = maxXMinY.x(point.x)
}

if point.y < maxXMinY.y || maxXMinY.y == 0 {
maxXMinY = maxXMinY.with(y: point.y)
maxXMinY = maxXMinY.y(point.y)
}
}

return CartesianFrame(
origin: minXMaxY,
size: Size(
width: abs(maxXMinY.x - minXMaxY.x),
height: abs(maxXMinY.y - minXMaxY.y)
)
height: abs(maxXMinY.y - minXMaxY.y),
),
)
}

Expand Down Expand Up @@ -132,33 +132,33 @@ public extension CartesianFrame {
let maxAxis = frame.origin.x + frame.width
if maxAxis < arc.radius {
let width = frame.size.width + (arc.radius - maxAxis)
let size = frame.size.with(width: width)
frame = frame.with(size: size)
let size = frame.size.width(width)
frame = frame.size(size)
}
case (.II, .I), (.I, .II):
let maxAxis = frame.origin.y
if maxAxis < arc.radius {
let y = frame.origin.y + (arc.radius - maxAxis)
let origin = frame.origin.with(y: y)
let origin = frame.origin.y(y)
let height = frame.size.height + (arc.radius - maxAxis)
let size = frame.size.with(height: height)
frame = frame.with(origin: origin).with(size: size)
let size = frame.size.height(height)
frame = frame.origin(origin).size(size)
}
case (.III, .II), (.II, .III):
let maxAxis = abs(frame.origin.x)
if maxAxis < arc.radius {
let x = frame.origin.x - (arc.radius - maxAxis)
let origin = frame.origin.with(x: x)
let origin = frame.origin.x(x)
let width = frame.size.width + (arc.radius - maxAxis)
let size = frame.size.with(width: width)
frame = frame.with(origin: origin).with(size: size)
let size = frame.size.width(width)
frame = frame.origin(origin).size(size)
}
case (.IV, .III), (.III, .IV):
let maxAxis = abs(frame.origin.y) + frame.size.height
if maxAxis < arc.radius {
let height = frame.size.height + (arc.radius - maxAxis)
let size = frame.size.with(height: height)
frame = frame.with(size: size)
let size = frame.size.height(height)
frame = frame.size(size)
}
default:
throw GraphPointError.unhandledQuadrantTransition(startQuadrant, endQuadrant)
Expand Down
20 changes: 10 additions & 10 deletions Sources/GraphPoint/CartesianPlane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public typealias CartesianPlane = Rect
public extension CartesianPlane {
init(axis: Int) {
self.init(
size: Size(width: axis * 2, height: axis * 2)
size: Size(width: axis * 2, height: axis * 2),
)
}

init(radius: Radius) {
self.init(
size: Size(width: radius * 2, height: radius * 2)
size: Size(width: radius * 2, height: radius * 2),
)
}
}
Expand Down Expand Up @@ -64,15 +64,15 @@ public extension CartesianPlane {
var cartesianPoint: CartesianPoint = .zero

if point.x < origin.x {
cartesianPoint = cartesianPoint.with(x: -(origin.x - point.x))
cartesianPoint = cartesianPoint.x(-(origin.x - point.x))
} else if point.x > origin.x {
cartesianPoint = cartesianPoint.with(x: point.x - origin.x)
cartesianPoint = cartesianPoint.x(point.x - origin.x)
}

if point.y > origin.y {
cartesianPoint = cartesianPoint.with(y: -(point.y - origin.y))
cartesianPoint = cartesianPoint.y(-(point.y - origin.y))
} else if point.y < origin.y {
cartesianPoint = cartesianPoint.with(y: origin.y - point.y)
cartesianPoint = cartesianPoint.y(origin.y - point.y)
}

return cartesianPoint
Expand All @@ -83,15 +83,15 @@ public extension CartesianPlane {
var point: Point = .zero

if cartesianPoint.x >= 0.0 {
point = point.with(x: cartesianOrigin.x + cartesianPoint.x)
point = point.x(cartesianOrigin.x + cartesianPoint.x)
} else {
point = point.with(x: cartesianOrigin.x - abs(cartesianPoint.x))
point = point.x(cartesianOrigin.x - abs(cartesianPoint.x))
}

if cartesianPoint.y <= 0.0 {
point = point.with(y: cartesianOrigin.y + abs(cartesianPoint.y))
point = point.y(cartesianOrigin.y + abs(cartesianPoint.y))
} else {
point = point.with(y: cartesianOrigin.y - cartesianPoint.y)
point = point.y(cartesianOrigin.y - cartesianPoint.y)
}

return point
Expand Down
Loading
Loading