Skip to content

Instantly share code, notes, and snippets.

@iscrz
Last active July 26, 2017 19:36
Show Gist options
  • Save iscrz/24110d6008b84db3c941c835087420a7 to your computer and use it in GitHub Desktop.
Save iscrz/24110d6008b84db3c941c835087420a7 to your computer and use it in GitHub Desktop.
extension Float {
static func rand48() -> Float {
return Float(Double.rand48())
}
static var tau: Float {
return .pi * 2
}
}
extension CGFloat {
static func rand48() -> CGFloat {
return CGFloat(Double.rand48())
}
static var tau: CGFloat {
return .pi * 2
}
}
extension Double {
static func rand48() -> Double {
srand48(Int(Date().timeIntervalSince1970))
return drand48()
}
static var tau: Double {
return .pi * 2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment