Swiftpack.co - juliand665/CGeometry as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by juliand665.
juliand665/CGeometry v0.4.0
Simple Operators for CoreGraphics Geometric Constructs
⭐️ 0
🕓 3 days ago
.package(url: "https://github.com/juliand665/CGeometry.git", from: "v0.4.0")



Swift Package Manager compatible MIT licensed

CGeometry

Simple operators (plus convenient initializers and constants) for CoreGraphics geometric constructs: CGPoint, CGVector, and CGSize.

Example

let a = CGPoint(x: 4, y: 7)
print(CGVector(a).length) // 8.06
print(CGVector(a).angle) // 1.05… (~60.3°)

let b = CGPoint(x: 10, y: 3)
print(b - a) // CGVector(dx: 6, dy: -4)
print(a + 0.5 * (b - a)) // CGPoint(x: 7, y: 5)

let offset = CGVector(dx: 10, dy: -5)
print(a + offset) // CGPoint(x: 14, y: 2)
print(a + offset / 2) // CGPoint(x: 9, y: 4.5)

let angled = CGVector(angle: 1/3 * .pi, length: 2)
print(angled) // CGVector(dx: 1, dy: 1.73…)

GitHub

link
Stars: 0
Last commit: 3 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Rectangles and Documentation
2 years ago
  • Added ways to scale rectangles up or down by floats or sizes.
  • Added documentation to the less trivial functions.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics