Skip to content

Instantly share code, notes, and snippets.

View b3ll's full-sized avatar
💭
no u

Adam Bell b3ll

💭
no u
View GitHub Profile
//
// WaveformView.swift
// WaveformSwiftUI
//
// Created by Adam Bell on 9/4/19.
// Copyright © 2019 Adam Bell. All rights reserved.
//
import SwiftUI
struct ADSRSliderView: View {
fileprivate struct DragGestureState {
var previousTranslationY: CGFloat?
var deltaPercentY: CGFloat = 0.0
}
let color: Color
@State var percent: CGFloat = 1.0
@b3ll
b3ll / BlurryVibrantView.swift
Created November 10, 2019 07:15
iOS SwiftUI Blurry Vibrant Container View
//
// BlurryVibrantView.swift
//
//
// Created by Adam Bell on 11/9/19.
// Copyright © 2019 Adam Bell. All rights reserved.
//
import SwiftUI
import UIKit
@b3ll
b3ll / benchmarks.txt
Created November 11, 2019 04:22
Layout Benchmarks - iPhone 11 Pro Max
seconds/ops for each iterations (10, 20, ..., 100)
-------------------------------------
Auto Layout 0.011051890614268544 0.016263917569191225 0.021760782469873844 0.02719013433198671 0.032661064978568785 0.03816674815283881 0.04359974031863005 0.04912022749582926 0.05463409423828125 0.060078123036552876
FlexLayout 1.3 0.003242011594926655 0.004680090418485838 0.006086660876418605 0.0075119084386683225 0.00897496725831713 0.010386990517685093 0.011813020706176758 0.013280785397479409 0.014661566070888353 0.016095952382163395
LayoutKit 10.0 0.0035990386558093614 0.004994573877818549 0.0064350542349693104 0.007844003848731518 0.009258856467150767 0.010668569422782735 0.01216747530971665 0.013521265339207006 0.014950280758871962 0.016407939254260453
Manual Layout 0.0029670758360236353 0.004297056934864225 0.005602365099517993 0.006929166563625994 0.008248548038670273 0.009564927646092005 0.010879647472630377 0.012188566736428135 0.013496214548746745 0.014810740947723389
//: A UIKit based Playground for presenting user interface
import SwiftUI
import UIKit
import PlaygroundSupport
class Model: ObservableObject {
@Published var on: Bool = false
}
@b3ll
b3ll / ModelBoundViewWrapper.swift
Created November 15, 2019 01:35
ModelBoundViewWrapper.swift
//: A UIKit based Playground for presenting user interface
import SwiftUI
import UIKit
import PlaygroundSupport
public struct ObservedObjectWrapperView<Content: View, Model: ObservableObject>: View {
@ObservedObject public var model: Model
@b3ll
b3ll / GestureSwitch.swift
Created March 6, 2020 04:51
Quick test to verify SwiftUI Gestures + Velocity
import SwiftUI
import UIKit
import PlaygroundSupport
struct GestureSwitch: View {
@GestureState var offsetY: CGFloat? = nil
var body: some View {
ZStack {
@b3ll
b3ll / AcceleratePerfTests.swift
Created April 18, 2020 18:44
Accelerate is p fast
import Accelerate
import XCTest
@testable import accelerateperftest
class AcceleratePerfTests: XCTestCase {
let values = Array<Float>(repeating: 0.25, count: 5000000)
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
//: A Cocoa based Playground to present user interface
import AppKit
import PlaygroundSupport
let nibFile = NSNib.Name("MyView")
var topLevelObjects : NSArray?
Bundle.main.loadNibNamed(nibFile, owner:nil, topLevelObjects: &topLevelObjects)
let views = (topLevelObjects as! Array<Any>).filter { $0 is NSView }
import Foundation
protocol UnpackedProtocol {
associatedtype ObjectType
associatedtype PointType
var points: [PointType] { get set }
}