This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let imagePix = ImagePIX() | |
| imagePix.image = UIImage(named: "city")! | |
| let resPix = ResPIX(res: .fullscreen) | |
| resPix.fillMode = .aspectFill | |
| resPix.inPix = imagePix | |
| let force: LiveFloat = .touchForce | |
| let finalPix = BlendsPIX.loop(0..<3, with: .add, loop: { i, ix in | |
| let fraction = LiveFloat(i) / LiveFloat(3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let circlePix = CirclePIX(res: ._1024) | |
| circlePix.radius = 1 / 3 | |
| let noisePix = NoisePIX(res: ._1024) | |
| noisePix.zPosition = .live / 10 | |
| noisePix.octaves = 3 | |
| noisePix.colored = true | |
| let dispPix = circlePix._edge()._displace(with: noisePix, distance: 0.1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let hexagon = MetalPIX(res: particleRes, uniforms: [ | |
| MetalUniform(name: "resx", value: LiveFloat(particleRes.width)), | |
| MetalUniform(name: "resy", value: LiveFloat(particleRes.height)) | |
| ], code: | |
| """ | |
| int x = int(u * in.resx); | |
| int y = int(v * in.resy); | |
| int i = y * int(in.resx) + x; | |
| float f = float(i) / (in.resx * in.resy); | |
| int hexi = int(f * 6); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let cirlce = MetalPIX(res: ._256, uniforms: [ | |
| MetalUniform(name: "resx", value: 256), | |
| MetalUniform(name: "resy", value: 256) | |
| ], code: | |
| """ | |
| int x = int(u * in.resx); | |
| int y = int(v * in.resy); | |
| int i = y * int(in.resx) + x; | |
| float f = float(i) / (in.resx * in.resy); | |
| pix = float4(cos(f*pi*2)/2+0.5,sin(f*pi*2)/2+0.5,0,1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var filterCaches: [String: [CGFloat]] = [:] | |
| func filter(_ value: CGFloat, for seconds: CGFloat, smooth: Bool = true, bypassLow: Bool = false, bypassHigh: Bool = false, id: String) -> CGFloat { | |
| guard filterCaches[id] != nil else { | |
| filterCaches[id] = [value] | |
| return value | |
| } | |
| filterCaches[id]!.append(value) | |
| let frameCount = Int(seconds * CGFloat(60)) | |
| while filterCaches[id]!.count > frameCount { | |
| filterCaches[id]!.remove(at: 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // QLPreviewControllerDataSource | |
| var medaUrl: URL? | |
| // MARK: - Quick Look | |
| func quickLook(_ url: URL) { | |
| medaUrl = url | |
| let previewController = QLPreviewController() | |
| previewController.dataSource = self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public enum ImagePlacement { | |
| case fill | |
| case fit | |
| } | |
| public static func resize(_ image: UIImage, to size: CGSize, placement: ImagePlacement = .fill) -> UIImage { | |
| let frame: CGRect | |
| switch placement { | |
| case .fit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PixelKit.main.bits = ._16 | |
| let ply = PolygonPIX() | |
| ply.radius = 0.125 | |
| let feed = ply._feed(0.99) { feed in | |
| feed._noiseDisplace(distance: 0.01, zPosition: .live / 10, octaves: 10) | |
| } | |
| return feed._edge(100)._quantize(0.1)._edge(10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct DileView<Content: View>: View { | |
| let kColCount: Int = 3 | |
| let scale: CGFloat | |
| let defaultIndex: Int | |
| let options: () -> ([Content]) | |
| let selected: (Int) -> () | |
| @State var index: Int = 0 | |
| @State var open: Bool = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| fileprivate let badChars = CharacterSet.alphanumerics.inverted | |
| public extension String { | |
| var camelToTitleCased: String { | |
| if self.count <= 1 { | |
| return self.uppercased() | |
| } |