I wanted a place other than the UI to reference tokens for configuring complex sequences. Please comment with any discrepancies or updates.
Pulled from the source at nina on branch release/2.0
and commit f19a006
.
Token | Description |
---|
I wanted a place other than the UI to reference tokens for configuring complex sequences. Please comment with any discrepancies or updates.
Pulled from the source at nina on branch release/2.0
and commit f19a006
.
Token | Description |
---|
import SwiftUI | |
public struct FormattedTextField<Formatter: TextFieldFormatter>: View { | |
public init(_ title: String, | |
value: Binding<Formatter.Value>, | |
formatter: Formatter) { | |
self.title = title | |
self.value = value | |
self.formatter = formatter | |
} |
struct Random { | |
static func within<B: protocol<Comparable, ForwardIndexType>>(range: ClosedInterval<B>) -> B { | |
let inclusiveDistance = range.start.distanceTo(range.end).successor() | |
let randomAdvance = B.Distance(arc4random_uniform(UInt32(inclusiveDistance.toIntMax())).toIntMax()) | |
return range.start.advancedBy(randomAdvance) | |
} | |
static func within(range: ClosedInterval<Float>) -> Float { | |
return (range.end - range.start) * Float(Float(arc4random()) / Float(UInt32.max)) + range.start | |
} |
// Easter calculation in swift after Anonymous Gregorian algorithm | |
// Also known as Meeus/Jones/Butcher algorithm | |
import Foundation | |
func easter(Y : Int) -> NSDate { | |
let a = Y % 19 | |
let b = Int(floor(Double(Y) / 100)) | |
let c = Y % 100 | |
let d = Int(floor(Double(b) / 4)) |