Skip to content

Releases: RougeWare/Swift-Rectangle-Tools

2.4.0 - Added a few conveniences to `TwoDimensional` and `Size2D`

04 Jan 03:27
54e1e05
Compare
Choose a tag to compare

TwoDimensional now has these:

  • aspectRatio() - Returns the ratio of the X measurement to the Y measurement
  • greaterThanZero - Returns a copy where
  • minMeasurement - Simply returns the lower of the two measurements
  • maxMeasurement - Simply returns the greater of the two measurements
  • product - Returns the result of multiplying the measurements together

And Size2D has these:

  • minSideLength - Like minMeasurement, but never negative
  • maxSideLength - Like maxMeasurement, but never negative
  • area - Like product, 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

21 Dec 23:58
6361d78
Compare
Choose a tag to compare

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:

  1. Fetching a point within an integer rectangle by passing some other floating-point type percentages, which returns the rectangle's integer type
  2. 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 any BinaryInteger

This might someday find its way to a new package.

Relevant tickets

2.2.0 - Added `.zero` and `.one` to `TwoDimensional`

11 Dec 04:31
7888250
Compare
Choose a tag to compare

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

11 Dec 00:42
b3a291d
Compare
Choose a tag to compare

2.1.0 - Made `Size2DCollectionIndex` conform to `Point2D`

10 Dec 08:42
05d8d1d
Compare
Choose a tag to compare

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

09 Dec 08:38
367a3b3
Compare
Choose a tag to compare

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`

09 Dec 04:01
bfd6c70
Compare
Choose a tag to compare

This allows any point, size, rectangle, or any other TwoDimensional or object with a pair of TwoDimensionals 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 TwoDimensionals, and then automatically synthesizing some witnesses in extensions to DualTwoDimensional when its implementations declare conformance to Equatable and Hashable

1.4.0 - Added Size2DCollection

06 Dec 03:26
33adc02
Compare
Choose a tag to compare

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!

1.3.0 - Updated to `MultiplicativeArithmetic` 1.2.0

27 Oct 17:49
85062b2
Compare
Choose a tag to compare

1.2.0 - Updated to `MultiplicativeArithmetic` 1.1.0

27 Oct 16:52
76e049e
Compare
Choose a tag to compare