Swiftpack.co - gadirom/MetalSnapshotTaker as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by gadirom.
gadirom/MetalSnapshotTaker 0.1.0
Take snapshots of arbitrary size from MTKView subclasses
⭐️ 1
🕓 1 week ago
iOS macOS
.package(url: "https://github.com/gadirom/MetalSnapshotTaker.git", from: "0.1.0")


iOS Swift 5.6 Metal 2.4 Swift Playgrounds 4.1 License: MIT

This package contains MetalSnapshotTaker class that allows taking snapshots of arbitrary sizes from an MTKView subclass with minimal alterations in it's code. Usable in SwiftUI context and outputs an image in one of these formats: UIImage, CGImage, Image.

How to Use

Create an instance of MetalSnapshotTaker either in your MTKView or in UIViewRepresentable that holds it. Call the update method (this can be done from Coordinator's init) passing an instance of MTLDevice, and references to draw, and mtkView methods of you MTKView subclass. The last one only needed if you use it to modify rendering, in which case the setCurrentSize shoud be called from it.


An example Swift Playgrounds app: MetalSnapshotTaker example



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

Release Notes

First Release
1 week ago

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