-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from RougeWare/feature/Rectangle+Collection2D
Changed `Size2DCollection` to `Collection2D`
- Loading branch information
Showing
13 changed files
with
409 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
Sources/RectangleTools/Basic Protocols/CartesianMeasurable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// | ||
// CartesianMeasurable.swift | ||
// | ||
// | ||
// Created by The Northstar✨ System on 2023-11-06. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
|
||
/// Represents something that can be measured on a Cartesian coordinate plane | ||
public protocol CartesianMeasurable { | ||
|
||
/// The type to use for measurements of length (x/y, width/height, etc.). | ||
/// | ||
/// This is typically a numeric type like `Int`, `Float64`, or `Decimal`. | ||
associatedtype Length | ||
|
||
|
||
|
||
/// The lowest x value when measuring this | ||
/// | ||
/// This will always be less than or equal to ``maxX`` | ||
/// | ||
/// ``` | ||
/// 6 │ | ||
/// 5.0 maxY → 5 │ ╭─╮ | ||
/// 4 │ ╰╮╰───┬╮ | ||
/// 3 │ │ ╭╮ │╵ | ||
/// 2.0 minY → 2 │ ╰─╯╰─╯ | ||
/// 1 │ | ||
/// 0 ┼──────────── | ||
/// 0 1 2 3 4 5 6 | ||
/// ↑ ↑ | ||
/// minX maxX | ||
/// 1.5 5.0 | ||
/// ``` | ||
var minX: Length { get } | ||
|
||
/// The lowest y value when measuring this | ||
/// | ||
/// This will always be less than or equal to ``maxY`` | ||
/// | ||
/// ``` | ||
/// 6 │ | ||
/// 5.0 maxY → 5 │ ╭─╮ | ||
/// 4 │ ╰╮╰───┬╮ | ||
/// 3 │ │ ╭╮ │╵ | ||
/// 2.0 minY → 2 │ ╰─╯╰─╯ | ||
/// 1 │ | ||
/// 0 ┼──────────── | ||
/// 0 1 2 3 4 5 6 | ||
/// ↑ ↑ | ||
/// minX maxX | ||
/// 1.5 5.0 | ||
/// ``` | ||
var minY: Length { get } | ||
|
||
|
||
|
||
/// The highest x value when measuring this | ||
/// | ||
/// This will always be greater than or equal to ``minX`` | ||
/// | ||
/// ``` | ||
/// 6 │ | ||
/// 5.0 maxY → 5 │ ╭─╮ | ||
/// 4 │ ╰╮╰───┬╮ | ||
/// 3 │ │ ╭╮ │╵ | ||
/// 2.0 minY → 2 │ ╰─╯╰─╯ | ||
/// 1 │ | ||
/// 0 ┼──────────── | ||
/// 0 1 2 3 4 5 6 | ||
/// ↑ ↑ | ||
/// minX maxX | ||
/// 1.5 5.0 | ||
/// ``` | ||
var maxX: Length { get } | ||
|
||
/// The highest y value when measuring this | ||
/// | ||
/// This will always be greater than or equal to ``minY`` | ||
/// | ||
/// ``` | ||
/// 6 │ | ||
/// 5.0 maxY → 5 │ ╭─╮ | ||
/// 4 │ ╰╮╰───┬╮ | ||
/// 3 │ │ ╭╮ │╵ | ||
/// 2.0 minY → 2 │ ╰─╯╰─╯ | ||
/// 1 │ | ||
/// 0 ┼──────────── | ||
/// 0 1 2 3 4 5 6 | ||
/// ↑ ↑ | ||
/// minX maxX | ||
/// 1.5 5.0 | ||
/// ``` | ||
var maxY: Length { get } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.