From 9be42573fe9a9ed013d03c2ff1a15f4c2dc10cd7 Mon Sep 17 00:00:00 2001 From: Anton Heestand Date: Sun, 20 Jun 2021 19:53:54 +0200 Subject: [PATCH] Update README.md --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index fdf10fc7..5e540ecb 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,41 @@ struct ContentView: View { } ~~~~ +### SwiftUI with View Model + +~~~~swift +import SwiftUI +import PixelKit + +class ViewModel: ObservableObject { + + let circlePix: CirclePIX + let blurPix: BlurPIX + + let finalPix: PIX + + init() { + + circlePix = CirclePIX() + + blurPix = BlurPIX() + blurPix.input = circlePix + blurPix.radius = 0.25 + + finalPix = blurPix + } +} + +struct ContentView: View { + + @StateObject var viewModel = ViewModel() + + var body: some View { + NODERepView(node: viewModel.finalPix) + } +} +~~~~ + ### UIKit ~~~~swift