Merge branch 'feature/helper_functions' into 'develop'
Feature/helper functions See merge request BPHV_MIPS/mvm_core!11
This commit is contained in:
commit
00058468c1
@ -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)
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user