Swiftpack.co - hellojoelhuber/swift-trapezoid-shapes as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by hellojoelhuber.
hellojoelhuber/swift-trapezoid-shapes 1.3.0
RoundedTrapezoid and Trapezoid shapes for SwiftUI
⭐️ 0
🕓 4 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/hellojoelhuber/swift-trapezoid-shapes.git", from: "1.3.0")

Trapezoid Shapes

This package adds RoundedTrapezoid and Trapezoid shapes to SwiftUI.


RoundedTrapezoids have the following properties:

cornerRadius:   Determines the roundness of the corners.
edgeRatio:      Determines the width of the top or right edge compared to the bottom or left edge (respectively) of the trapezoid. 
                Cannot be less than 0. 
                < 1 results in top or right edge shorter than bottom or left edge. 
                > 1 results in top or right edge longer than bottom or left edge.
flexibleEdge:   Determines which base is "flexible." 
                Options are .top (default), .right, .bottom, .left
                The flexible edge is the edge which will grow or shrink based on the edgeRatio; and be offset by the edgeOffset.
edgeOffset:     Determines how acute the trapezoid is. 
                Defaults to 0 for isosceles trapezoid.

RoundedTrapezoids can be initialized in the following ways:

// Defaults cornerRadius to 10, edgeRatio to 0.65, flexibleEdge to .top, edgeOffset to 0. 

// Provide the cornerRadius. Defaults edgeRatio to 0.65, flexibleEdge to .top, edgeOffset to 0.
RoundedTrapezoid(cornerRadius: Double)

// Provide the cornerRadius and edgeRatio. Defaults flexibleEdge to .top, edgeOffset is set to 0.
RoundedTrapezoid(cornerRadius: Double, edgeRatio: Double)
// Provide cornerRadius and any of the other 3 properties in any combination. The defaults are as above. You can provide settings for all or some.
RoundedTrapezoid(cornerRadius: Double, edgeRatio: Double, flexibleEdge: FlexibleEdge, edgeOffset: Double)

The RoundedTrapezoid cannot be obtuse, unless the cornerRadius = 0.


Trapezoid is like the RoundedTrapezoid, except that the cornerRadius is always set to 0 and can be obtuse in shape.


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

Release Notes

4 weeks ago

Changed cornerOffset to cornerRadius to parallel the standard library implementation of RoundedRectangle.

Moved enum FlexibleEdge to its own file so that the Path extension could share it.

Changed FlexibleEdge to a type Int to remove the case -> Int conversion function and call .rawValue in the Path, which improves code readability.

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