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
⭐️ 2
🕓 1 year 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.

RoundedTrapezoid

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. 
RoundedTrapezoid()

// 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

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

GitHub

link
Stars: 2
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

v1.3.0
1 year 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