https://github.com/phimage/morphi
Shapes for SwiftUI ♡☾
https://github.com/phimage/morphi
heart path shape swift swiftui
Last synced: 14 days ago
JSON representation
Shapes for SwiftUI ♡☾
- Host: GitHub
- URL: https://github.com/phimage/morphi
- Owner: phimage
- License: mit
- Created: 2019-07-17T19:14:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-08T09:31:41.000Z (over 5 years ago)
- Last Synced: 2024-10-15T19:40:58.159Z (6 months ago)
- Topics: heart, path, shape, swift, swiftui
- Language: Swift
- Homepage:
- Size: 307 KB
- Stars: 71
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
- fucking-about-SwiftUI - Morphi
- awesome-swiftui-libraries - morphi - Shapes for SwiftUI (Shapes / Content)
README
# Morphi - Μορφ
[](http://mit-license.org)
[](https://developer.apple.com/resources/)
[](https://developer.apple.com/swift)
[](https://travis-ci.org/phimage/morphi)
[](https://github.com/sponsors/phimage)
![]()
![]()
Morphi provides some additional [shapes](https://developer.apple.com/documentation/swiftui/shape) for SwiftUI.
- [x] `Triangle`
- [x] `Parallelogram(topLeftAngle)`
- [x] `Polygon(sides)`
- [x] `RoundedPolygon(sides, cornerRadius)`
- [x] `Heart`
- [x] `Moon(angle)`
- [x] `PlusSign(width)`
- [x] `Star(points)`
- [x] `Wave(isUp, width, offset)`
- [x] `SuperEllipse(n)`
- [x] `Drop`
- [x] `Ring(radius)` (to use with a `FillStyle` with `eoFill` equal to `true`)
- [x] `Gear(radius, cogs)` (to use with a `FillStyle` with `eoFill` equal to `true`)## Examples
### Create a shape view
Like any other shapes just initialize it.
```swift
Heart().fill(Color.red).frame(width: 100, height: 100)
```
![]()
### Mask an existing view
```swift
aView.clipShape(Drop())
// or using static member
aView.clipShape(.drop)
```You can even do it on another shape.
```swift
Polygon(sides: 6).fill(Color.red).clipShape(.drop)
```## UIKit
For `UIKit` version with `UIBezierPath` see [IBAnimatable framework](https://github.com/IBAnimatable/IBAnimatable/)