Releases: RougeWare/Swift-Rectangle-Tools
2.4.0 - Added a few conveniences to `TwoDimensional` and `Size2D`
TwoDimensional
now has these:
aspectRatio()
- Returns the ratio of the X measurement to the Y measurementgreaterThanZero
- Returns a copy whereminMeasurement
- Simply returns the lower of the two measurementsmaxMeasurement
- Simply returns the greater of the two measurementsproduct
- Returns the result of multiplying the measurements together
And Size2D
has these:
minSideLength
- LikeminMeasurement
, but never negativemaxSideLength
- LikemaxMeasurement
, but never negativearea
- Likeproduct
, but never negative
Some of these are duplicated for different types of Length
since each has its own requirements. The goal is to provide consistent functionality regardless.
2.3.1 - Added `min`/`mid`/`max` `x`/`y` lines/points to all sizes and rects
Now, all sizes and rectangles have the following computed properties on them!
minX
midX
maxX
minY
midY
maxY
minXminY
minXmidY
minXmaxY
midXminY
midXmidY
/center
midXmaxY
maxXminY
maxXmaxY
maxXmidY
And these rectangle-only functions:
percent(alongX:)
percent(alongY:)
relativePoint(xPercent:yPercent:)
minX(yPercent:)
maxX(yPercent:)
minY(xPercent:)
maxY(xPercent:)
These are split into two separate sets of APIs, which I hope will work harmoniously:
- Fetching a point within an integer rectangle by passing some other floating-point type percentages, which returns the rectangle's integer type
- Fetching a point within a floating-point rectangle by passing the rectangle's floating-point type percentages, which returns the rectangle's floating-point type
And this incidental new protocol:
InitializableFromInteger
init(_:)
which takes anyBinaryInteger
This might someday find its way to a new package.
Relevant tickets
2.2.0 - Added `.zero` and `.one` to `TwoDimensional`
This lets you create any TwoDimensional
as a 0
-by-0
or 1
-by-1
with one easy static property:
UIntSize.one
Int64Point.zero
// etc....
2.1.1 - Fixed infinite loop bug with Size2D collections
2.1.0 - Made `Size2DCollectionIndex` conform to `Point2D`
This allows you to take advantage of a lot of work done to make Point2D
easy to work with, while performing collection operations on a Size2D
2.0.1 - Better initializers
In order to implement #19, new non-optional requirements had to be placed on TwoDimensional
and DualTwoDimensional
to guarantee that their implementers are initializable (#20).
Although it is not very likely that this package is in such wide usage that this will actually be a problem in existing codebases, nonetheless it is a backwards-incompatible change which will require new code to be written to support it. Thus, this ushers in version 2.0.0
! 🥳
And for forgetting to make initializers which cross-convert floats to ints, this package is bumped to 2.0.1
. 🎉
1.5.1 - Default conformance to `Hashable`
This allows any point, size, rectangle, or any other TwoDimensional
or object with a pair of TwoDimensional
s to automatically synthesize its conformance to Equatable
and Hashable
through some reasonable default witnesses.
This is done by introducing DualTwoDimensional
to genericize Rectangle
's nature of being made up of a pair of TwoDimensional
s, and then automatically synthesizing some witnesses in extensions to DualTwoDimensional
when its implementations declare conformance to Equatable
and Hashable
1.4.0 - Added Size2DCollection
Imagine if you are making an image and size is a BinaryIntegerSize
. Wouldn't it be nice to just map that size to a set of pixels? Well now you can, with the Size2DCollection
protocol and the map2D
function it provides! What's more, it also acts as a standard collection so it gets all the benefits and existing extensions of one, such as filter
and reduce
!