Multiplatform image renderer for MacOS and iOS.
Inspired by EricaSadun and UIGraphicsImageRenderer
For the best experience use it with Pallete
import iMage
import Palette
let redCirlce = IMage.render(in: someview.bounds) { let ctx = $0.cgContext
let ctx = $0.cgContext!
ctx.setFillColor(.init(.white))
ctx.fill(rect)
ctx.addEllipse(in: rect.insetBy(dx: 10, dy: 10))
ctx.setFillColor(.init(Color<RGB>.red.with(alpha: 0.7)))
ctx.fillPath()
}
Add the package to Your SwiftPM package dependencies:
.package(url: "https://github.com/makeupstudio/iMage.git", from: "1.0.0")
then add iMage
dependency to your target.