Swiftpack.co - heestand-xyz/AsyncGraphics as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by heestand-xyz.
heestand-xyz/AsyncGraphics 0.9.1
Edit images and video with async / await in Swift, powered by Metal.
⭐️ 37
🕓 6 days ago
iOS macOS tvOS
.package(url: "https://github.com/heestand-xyz/AsyncGraphics.git", from: "0.9.1")

AsyncGraphics

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

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.

Content

Import an image, video or live stream a camera feed.

Create color, text, rectangle, circle, polygon gradient, noise, particles and more.

Effects

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.

Metal

There is also the option to write high level metal code in AsyncGraphics. No need to setup a pipeline.

Install

.package(url: "https://github.com/heestand-xyz/AsyncGraphics", from: "0.8.0")

Example

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

Color

Colors are represented with the PixelColor type.
import PixelColor to create custom colors with hex values.

PixelColor on GitHub.

Image

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.

About

AsyncGraphics is a work in progress project, there is more features to come! Feel free to submit a PR!

GitHub

link
Stars: 37
Last commit: 2 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics