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 Foundation | |
import SwiftUI | |
import Combine | |
import Observation | |
struct ContentView: View { | |
@State private var randoms: LatticeCircularDistributor = LatticeCircularDistributor(boundLower: 0.3125, boundUpper: 0.3125, threshholdLeft: 0.25, threshholdRight: 0.25) | |
var body: some View { | |
Spacer() | |
VStack { |
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
/* | |
A circular distribution or polar distribution is a probability distribution of a random variable whose values are angles, usually taken to be in the range [0, 2π). A circular distribution is often a continuous probability distribution, and hence has a probability density, but such distributions can also be discrete, in which case they are called circular lattice distributions. Circular distributions can be used even when the variables concerned are not explicitly angles: the main consideration is that there is not usually any real distinction between events occurring at the opposite ends of the range, and the division of the range could notionally be made at any point. | |
*/ | |
// https://en.wikipedia.org/wiki/Circular_distribution | |
import SwiftUI | |
func scale(oldMin: Double, oldMax: Double, value: Double, newMin: Double, newMax: Double) -> Double { | |
return ((value - oldMin) / (oldMax - oldMin)) * (newMax - newMin) + newMin |
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
let n = vDSP_Length(88200) | |
let stride = vDSP_Stride(1) | |
var a: Float32 = 0.0 | |
var b: Float32 = 1.0 | |
var c = [Float32](repeating: 0, | |
count: Int(vDSP_Length(88200))) | |
vDSP_vgen(&a, | |
&b, |
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 private var selectedFontName: String = "Times New Roman" | |
@State private var isPresented: Bool = true | |
var body: some View { | |
VStack { | |
FontSelectorView(selectedFontName: $selectedFontName) |
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 | |
func scale(oldMin: Double, oldMax: Double, value: Double, newMin: Double, newMax: Double) -> Double { | |
return ((value - oldMin) / (oldMax - oldMin)) * (newMax - newMin) + newMin | |
} | |
struct ContentView: View { | |
@State private var firstAngles: [Double] = [] | |
@State private var secondAngles: [Double] = [] | |
@State private var minusThresholdAngles: [Double] = [] |
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 MetalKit | |
class MetalSineWaveGenerator { | |
let device: MTLDevice | |
let commandQueue: MTLCommandQueue | |
let computePipelineState: MTLComputePipelineState | |
let arraySize: Int | |
let frequency: Float | |
let sampleRate: Float | |
let resultBuffer: MTLBuffer |
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 Foundation | |
public func randomizeDurationSplits(group: DispatchGroup? = nil, completion: @escaping ([[Double]]) -> Void) { | |
group?.enter() | |
DispatchQueue.global().async { | |
let dyad0harmony0: Double = Double.random(in: durationLowerBound ... durationUpperBound) | |
var dyad1harmony0: Double = dyad0harmony0 | |
repeat { |
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 CircularArrayView: View { | |
private let diameter: CGFloat = 30 | |
var numberOfCircles: Int = 12 | |
var spacing: CGFloat = 1.0 | |
// Ensures the number of circles is always even | |
private var evenNumberOfCircles: Int { | |
numberOfCircles % 2 == 0 ? numberOfCircles : numberOfCircles + 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
func hueAccentColor(angle: CGFloat) -> Color { | |
return Color(hue: CGFloat(angle / 360.0), saturation: 1.0, brightness: 1.0, opacity: 1.0) | |
} | |
func whiteColor() -> Color { | |
return Color.init(uiColor: .white) // return Color(hue: CGFloat(hueAngle / 360.0), saturation: 0.0, brightness: 1.0, opacity: 1.0) | |
} | |
func blackColor() -> Color { | |
return Color.init(uiColor: .black) // return Color(hue: CGFloat(hueAngle / 360.0), saturation: 0.0, brightness: 0.0, opacity: 1.0) |
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 { | |
var body: some View { | |
HueControlView() | |
} | |
} | |
struct HueControlView: View { | |
@State var hueAngle: CGFloat = 0.0 |