Edit images and video with async / await in Swift, powered by Metal.

Overview

AsyncGraphics

The core value type in AsyncGraphics is a Graphic.
It's like an image, tho it can be used with various async methods.

Documentation

Swift Package

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

Graphic - Content

A Graphic can be created with static funcs e.g. Graphic.image(named:) or Graphic.circle(size:radius:center:).

Color

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

static func color(_ color: PixelColor, size: CGSize) async throws -> Graphic
static func color(_ color: PixelColor, size: CGSize) async throws -> Graphic

Example:

import PixelColor
let color: Graphic = try await .color(PixelColor(hex: "#FF8000"), 
                                      size: CGSize(width: 1000, height: 1000))

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.

static func image(_ image: TMImage) async throws -> Graphic
static func image(named name: String, in bundle: Bundle = .main) async throws -> Graphic

Example:

let image: Graphic = try await .image(named: "Image")

Circle

static func circle(radius: CGFloat? = nil, center: CGPoint? = nil, color: PixelColor = .white, backgroundColor: PixelColor = .black, size: CGSize) async throws -> Graphic

Example:

let circle: Graphic = try await .circle(radius: 250.0,
                                        center: CGPoint(x: 500.0, y: 500.0),
                                        color: .orange,
                                        backgroundColor: .clear,
                                        size: CGSize(width: 1000.0, height: 1000.0))

Frames

You can import a video to an array of Graphics.

static func videoFrames(url: URL) async throws -> [Graphic]

Example:

guard let url: URL = Bundle.main.url(forResource: "Video", withExtension: "mov") else { return }
let frames: [Graphic] = try await .videoFrames(url: url)

Graphic - Effects

A Graphic can be modified with effect funcs e.g. .inverted() or .blend(graphic:blendingMode:placement:).

Invert

func inverted() async throws -> Graphic

Example:

let inverted: Graphic = try await someGraphic.inverted() 

Blend

func blended(with graphic: Graphic, blendingMode: BlendingMode, placement: Placement = .fit) async throws -> Graphic

Example:

let blended: Graphic = try await someGraphic.blended(with: otherGraphic, blendingMode: .multiply) 

Displace

func displaced(with graphic: Graphic, offset: CGFloat, origin: PixelColor = .gray, placement: Placement = .fill) async throws -> Graphic

Example:

let displaced: Graphic = try await someGraphic.displaced(with: otherGraphic, offset: 100.0) 

Graphic - Export

A Graphic can be exported to a video with func .video(fps:kbps:format:).

Video

func video(fps: Int = 30, kbps: Int = 1_000, format: VideoFormat = .mov) async throws -> Data

Examples:

let frames: [Graphic] = ...
let videoData: Data = try await frames.video(fps: 60, kbps: 750, format: .mp4) 
let videoURL: URL = try await frames.video(fps: 24, kbps: 500, format: .mov) 
You might also like...
iOS 13-compatible backports of commonly used async/await-based system APIs that are only available from iOS 15 by default.

AsyncCompatibilityKit Welcome to AsyncCompatibilityKit, a lightweight Swift package that adds iOS 13-compatible backports of commonly used async/await

AsyncTaskKit - contains some additions to async/await Task

AsyncTaskKit This repo contains some additions to async/await Task. In general i

Lightweight async/await networking library with interceptor support - usable from iOS 13+.
Lightweight async/await networking library with interceptor support - usable from iOS 13+.

Lightweight async/await networking library with interceptor support. 🚀 Getting started AsyncNetwork's session acts as a wrapper to URLSession by addi

Test app for the InStat company. The project uses MVVM architecture, interface created with SwiftUI, network requests with async/await

FootStats Test app for the InStat company. The Project uses MVVM architecture, interface created with SwiftUI, network requests with async/await using

Async and concurrent versions of Swift’s forEach, map, flatMap, and compactMap APIs.

CollectionConcurrencyKit Welcome to CollectionConcurrencyKit, a lightweight Swift package that adds asynchronous and concurrent versions of the standa

⚡️ Fast async task based Swift framework with focus on type safety, concurrency and multi threading
⚡️ Fast async task based Swift framework with focus on type safety, concurrency and multi threading

Our apps constantly do work. The faster you react to user input and produce an output, the more likely is that the user will continue to use your appl

A demonstration for bridging between Combine and your new async functions

CombineAsyncually This is a DEMONSTRATION of how you can bridge the new async / await functionality in Swift 5.5 with Combine. There is NO WARRANTY. T

Swift TableView pagination with async API request.
Swift TableView pagination with async API request.

SwiftTableViewPagination Swift TableView pagination with async API request. Output UML Create puml file. $ cd SwiftTableViewPagination/scripts/swiftum

AsyncExtensions aims to mimic Swift Combine operators for async sequences.

AsyncExtensions AsyncExtensions provides a collection of operators, async sequences and async streams that mimics Combine behaviour. The purpose is to

straightforward networking and error handling with async-await and URLSession

AsyncAwaitNetworkingPlayground How To Run Just clone the project, open it and run. Some notes about AsyncAwaitNetworkingPlayground It's a straightforw

Fırat Yenidünya 17 Dec 11, 2022
A lightweight swift network layer with Combine, Async-Await, and a traditional completion block.

CombineNetwork A simple light-weight network library to make network requesting simpler. It supports newer techonology such as async/await as well as

Dushant Singh 4 Jan 3, 2022
Hydra ⚡️ Lightweight full-featured Promises, Async & Await Library in Swift

Lightweight full-featured Promises, Async & Await Library in Swift What's this? Hydra is full-featured lightweight library which allows you to write b

Daniele Margutti 2k Dec 24, 2022
⏳ Collection of Swift 5.5 async/await utility functions.

⏳ FunAsync Collection of Swift 5.5 async/await utility functions. Throw <-> Result conversion asyncThrowsToAsyncResult asyncResultToAsyncThrows More C

Yasuhiro Inami 23 Oct 14, 2022
Hydra: Lightweight full-featured Promises, Async-Await Library in Swift

Async Functions for ECMAScript The introduction of Promises and Generators in EC

Ecma TC39 1.6k Oct 17, 2022
AsyncLocationKit - Async/await CoreLocation With Swift

AsyncLocationKit Wrapper for Apple CoreLocation framework with new Concurency Mo

AsyncSwift 89 Dec 30, 2022
A Swift lib for network with async/await

SmileNetwork A Swift network utility with async/await applied UseAge enum MockEndpoint { case weather(cityId: String) } extension MockEndpoint: S

null 2 Jul 13, 2022
A simple network layer for use in small iOS projects with async/await support

SimpleNetwork Intro SimpleNetwork is simple network layer for use in small projects. Swift Package Manager Note: Instructions below are for using Swif

Alexandre Garrefa 1 Nov 30, 2021
Example project showing how to use async/await with iOS 13

ios13AsyncAwait Example project showing how to use async/await with iOS 13 Article This source code is a part of an article published at This Dev Brai

Michał Tynior 7 Oct 2, 2022
Using async / await on iOS 13: everything you need to know

Using async / await on iOS 13: everything you need to know! ?? Content This repository contains the code sample I've used during December 14th's lives

Vincent Pradeilles 11 Feb 1, 2022