Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fourplusone/rasterize
Create rasterized versions of SwiftUI views
https://github.com/fourplusone/rasterize
swift swiftui
Last synced: 23 days ago
JSON representation
Create rasterized versions of SwiftUI views
- Host: GitHub
- URL: https://github.com/fourplusone/rasterize
- Owner: fourplusone
- License: mit
- Created: 2020-12-09T10:14:39.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-09T10:21:51.000Z (about 4 years ago)
- Last Synced: 2024-11-29T03:37:50.059Z (25 days ago)
- Topics: swift, swiftui
- Language: Swift
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rasterize
![Swift](https://github.com/fourplusone/rasterize/workflows/Swift/badge.svg)
Create rasterized versions of SwiftUI views
## Example
```swift
import SwiftUI
import Rasterizestruct ContentView: View {
let gradient = LinearGradient(gradient: Gradient(colors: [Color.red, Color.blue]), startPoint: .top, endPoint: .bottom)var body: some View {
ZStack {
Rectangle()
.fill(gradient)
.cornerRadius(10)Text("10")
.foregroundColor(.white)
.font(.system(size: 30))
.rotationEffect(Angle(degrees: -30))
}
.frame(width: 100, height: 100)
}
}try Rasterized(view: ContentView())
.bitmapRepresentation().representation(using: .png,
properties: [:])?
.write(to: URL(fileURLWithPath: "/tmp/demo.png"))
```## Usage
This package is available via SwiftPM
```swift
dependencies: [
.package(url: "https://github.com/fourplusone/rasterize.git", from: "0.1.0")
]
```## License
This project is licensed under the MIT License.