heestand-xyz / PixelCanvas

SwiftUI View to zoom down to pixel level detail.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pixel Canvas

Pan and zoom images down to pixel level.

For iOS (v16), macOS (v13) and visionOS (v1).

Note that pixel level detail with a SwiftUI shader is only available for iOS (v17), macOS (v14) and visionOS (v1).

import SwiftUI
import PixelCanvas

struct ContentView: View {
    
    @StateObject private var pixelCanvas = PixelCanvas()
    
    var body: some View {
        PixelCanvasView(
            pixelCanvas,
            background: { pixels, frame in
                ZStack {
                    pixels
                    PixelCanvasLayout(frame: frame) {
                        // Background
                    }
                }
            },
            foreground: {
                // Foreground
            }
        )
        .onAppear {
            pixelCanvas.load(
                image: Image("..."),
                resolution: CGSize(width: 3_000, height: 2_000)
            )
        }
    }
}

#Preview {
    ContentView()
}

About

SwiftUI View to zoom down to pixel level detail.


Languages

Language:Swift 77.4%Language:Metal 22.6%