AsyncGraphics is a Swift package for working with images and video with async / await. The core type is simply just called Graphic
and it's like an image, tho backed by a MTLTexture
and comes with a lot of content and effects.
Documentation (DocC)
The documentation contains a list of all content and effects that can be created with the Graphic type. It also contains articles about setting up a live camera feed and editing video.
Import an image, video or live stream a camera feed.
Create color, text, rectangle, circle, polygon gradient, noise, particles and more.
Effects include resize, blend with various blending modes, translate, rotate, scale, mirror, stack, brightness, contrast, invert, opacity, monochrome, saturation, hue, tint, channel mix, blur, rainbow blur, displace, edge, clamp, cross, corner pin, chroma key a green screen.
There is also the option to write high level metal code in AsyncGraphics. No need to setup a pipeline.
.package(url: "https://github.com/heestand-xyz/AsyncGraphics", from: "0.8.0")
A live camera feed.
import SwiftUI
import AsyncGraphics
struct ContentView: View {
@State private var graphic: Graphic?
var body: some View {
ZStack {
if let graphic {
GraphicView(graphic: graphic)
}
}
.task {
for await cameraGraphic in try! Graphic.camera(.front) {
graphic = cameraGraphic
}
}
}
}
Colors are represented with the PixelColor
type.
import PixelColor
to create custom colors with hex values.
PixelColor on GitHub.
Images are represented with TMImage
.
This is a multi platform type alias to UIImage
and NSImage
.
import TextureMap
for extra multi platform methods like .pngData()
for macOS.
TextureMap on GitHub.
AsyncGraphics is a work in progress project, there is more features to come! Feel free to submit a PR!