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
-11800 : unknown | |
-11801 : outOfMemory | |
-11803 : sessionNotRunning | |
-11804 : deviceAlreadyUsedByAnotherSession | |
-11805 : noDataCaptured | |
-11806 : sessionConfigurationChanged | |
-11807 : diskFull | |
-11808 : deviceWasDisconnected | |
-11809 : mediaChanged | |
-11810 : maximumDurationReached |
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 errorAndCode(code: AVError.Code) -> (Int, String) { | |
return (code.rawValue, describeAVError(code: code)) | |
} | |
func describeAVError(code: AVError.Code) -> String { | |
switch code { | |
case .unknown: return "unknown" | |
case .outOfMemory: return "outOfMemory" | |
case .sessionNotRunning: return "sessionNotRunning" | |
case .deviceAlreadyUsedByAnotherSession: return "deviceAlreadyUsedByAnotherSession" |
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
//: Playground - noun: a place where people can play | |
import Foundation | |
import GameplayKit | |
struct Game: Sequence, IteratorProtocol { | |
// Should return a random Int between 0-Param, ie 0<=x<3 | |
let random: (Int) -> Int | |
let doors: Int = 3 | |
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 CGPoint : Hashable { | |
func distance(point: CGPoint) -> Float { | |
let dx = Float(x - point.x) | |
let dy = Float(y - point.y) | |
return sqrt((dx * dx) + (dy * dy)) | |
} | |
public var hashValue: Int { | |
// iOS Swift Game Development Cookbook | |
// https://books.google.se/books?id=QQY_CQAAQBAJ&pg=PA304&lpg=PA304&dq=swift+CGpoint+hashvalue&source=bl&ots=1hp2Fph274&sig=LvT36RXAmNcr8Ethwrmpt1ynMjY&hl=sv&sa=X&ved=0CCoQ6AEwAWoVChMIu9mc4IrnxgIVxXxyCh3CSwSU#v=onepage&q=swift%20CGpoint%20hashvalue&f=false | |
return x.hashValue << 32 ^ y.hashValue |
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
// https://www.cs.rit.edu/~ncs/color/t_convert.html | |
struct RGB { | |
// Percent | |
let r: Float // [0,1] | |
let g: Float // [0,1] | |
let b: Float // [0,1] | |
static func hsv(r: Float, g: Float, b: Float) -> HSV { | |
let min = r < g ? (r < b ? r : b) : (g < b ? g : b) | |
let max = r > g ? (r > b ? r : b) : (g > b ? g : b) |