This file contains 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 Combine | |
import PublishedObject // https://github.com/Amzd/PublishedObject | |
import SwiftUI | |
/// A property wrapper type that instantiates an observable object. | |
@propertyWrapper | |
public struct StateObject<ObjectType: ObservableObject>: DynamicProperty | |
where ObjectType.ObjectWillChangePublisher == ObservableObjectPublisher { | |
/// Wrapper that helps with initialising without actually having an ObservableObject yet |
This file contains 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 | |
@available(iOS 14.0, *) | |
public struct ColorPickerWithoutLabel: UIViewRepresentable { | |
@Binding var selection: Color | |
var supportsAlpha: Bool = true | |
public init(selection: Binding<Color>, supportsAlpha: Bool = true) { | |
self._selection = selection | |
self.supportsAlpha = supportsAlpha |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 ContentView: View { | |
@State var now = Date() | |
@State var showWindow = false | |
@State var text: String = "" | |
let timer = Timer.publish(every: 1, on: .current, in: .common).autoconnect() |
This file contains 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
// See: https://forums.developer.apple.com/thread/65997 | |
MIDIInputPortCreateWithBlock(midiClient, "Instrument" as CFString, &inPort, { | |
(unsafePacketList: UnsafePointer<MIDIPacketList>, pointer: UnsafeMutableRawPointer?) in | |
let packetList = unsafePacketList.pointee | |
if packetList.numPackets == 1 { | |
let packet = packetList.packet | |
if packet.length == 3 && packet.data.0 == 144 { | |
/* Note-On */ | |
let note = packet.data.1 |
This file contains 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
CVPixelBufferRef createCroppedPixelBufferBiPlanar(CVPixelBufferRef srcPixelBuffer, CGRect croppingRect, CGSize scaleSize) { | |
OSType inputPixelFormat = CVPixelBufferGetPixelFormatType(srcPixelBuffer); | |
assert(inputPixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange | |
|| inputPixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange); | |
size_t inputWidth = CVPixelBufferGetWidth(srcPixelBuffer); | |
size_t inputHeight = CVPixelBufferGetHeight(srcPixelBuffer); | |
assert(CGRectGetMinX(croppingRect) >= 0); |