Skip to content

Commit

Permalink
#67: Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
KyLeggiero committed Nov 20, 2023
1 parent b7ab155 commit 883f920
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

A set of Swift utilities for dealing with rectangles, including a way to generically build your own!

This package includes new types such as `IntRect` and `UIntPoint`, conveniences for doing math with various points in rectangles, centering and scaling, generic protocols to unify math across all rectangular types, conveniences for measuring and placing rectangles, and much more.
This package includes:

- new types such as `IntRect` and `UIntPoint`
- conveniences for doing math with various points in rectangles
- centering and scaling
- generic protocols to unify math across all Cartesian types
- conveniences for measuring and placing rectangles/points/sizes
- and much more...

Who knew there was so much to be done with rectangles?

Expand All @@ -12,9 +19,34 @@ Who knew there was so much to be done with rectangles?

This library aims to never get in your way. Minimal arbitrary decisions, maximum flexibility.

For example, other frameworks might say that they help you find the distance from any `CGPoint` to another, but doesn't provide that functionality to any other type.
This one doesn't care what types the two are, as long as thier `x` and `y` coordinates use the same type. That means if you want to measure the distance from some `CGPoint` to some custom 2D point-like structure which also uses `CGFlaot`s, this will happily let you do that with no fuss.
For example, other frameworks might say that they help you find the distance from any `CGPoint` to another, but don't provide that functionality to any other type.
This one doesn't care what types the two are, as long as thier `x` and `y` coordinates use the same type. That means if you want to measure the distance from some `CGPoint` to some custom 2D point-like structure which also uses `CGFloat`s, this will happily let you do that with no fuss.


For example, let's say you made this for your specific requirements:

```swift
struct AnnotatedPoint {
var x: CGFloat
var y: CGFloat
var annotation: String
}
```

You can quickly and easily find the distance between that and a `CGPoint` like this:

```swift
import RectangleTools

extension AnnotatedPoint: Point2D {
// Nothing to do! 🦆
}
```
```swift
func isCloseEnoughToSnap(cursorPosition: AnnotatedPoint, to anchor: CGPoint) -> Bool {
cursorPosition.distance(to: anchor) < snapDistnce
}
```


## Thoroughly Tested ##
Expand All @@ -32,3 +64,6 @@ This library was created for enterprise-scale applications, and is being used by
## SwiftUI ##

If you're using this with SwiftUI, you can also `import RectangleTools_SwiftUI` to gain SwiftUI-specific rectangle tools!



0 comments on commit 883f920

Please sign in to comment.