Last active
July 26, 2017 19:36
-
-
Save iscrz/24110d6008b84db3c941c835087420a7 to your computer and use it in GitHub Desktop.
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
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