Merge branch 'feature/helper_functions' into 'develop'

Feature/helper functions

See merge request BPHV_MIPS/mvm_core!11
This commit is contained in:
Pfeil, Scott Robert 2019-04-24 15:18:58 -04:00
commit 00058468c1
2 changed files with 17 additions and 2 deletions

View File

@ -134,6 +134,13 @@ public extension Dictionary {
return floatValue
}
func optionalCGFloatForKey(_ key: String) -> CGFloat? {
guard let key = key as? Key else {
return nil
}
return self[key] as? CGFloat
}
func floatFromStringForKey(_ key:String) -> Float {
let stringValue = stringForkey(key)

View File

@ -10,10 +10,18 @@ import Foundation
public extension MVMCoreGetterUtility {
class func fequal(a: Float ,b: Float) -> Bool {
return (abs((a) - (b)) < Float.ulpOfOne)
return fequalwiththreshold(a, b, Float.ulpOfOne)
}
class func cgfequal(_ a: CGFloat ,_ b: CGFloat) -> Bool {
return (abs((a) - (b)) < CGFloat.ulpOfOne)
return cgfequalwiththreshold(a, b, CGFloat.ulpOfOne)
}
class func fequalwiththreshold(_ a: Float,_ b: Float,_ threshold: Float) -> Bool {
return (abs((a) - (b)) < threshold)
}
class func cgfequalwiththreshold(_ a: CGFloat ,_ b: CGFloat,_ threshold: CGFloat) -> Bool {
return (abs((a) - (b)) < threshold)
}
}