-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4329841
commit 1c171b2
Showing
4 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
Sources/CodeEditTextView/Extensions/GC+ApproximateEqual.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// GC+ApproximateEqual.swift | ||
// CodeEditTextView | ||
// | ||
// Created by Khan Winter on 2/16/24. | ||
// | ||
|
||
import Foundation | ||
|
||
extension CGFloat { | ||
func approxEqual(_ other: CGFloat, tolerance: CGFloat = 0.5) -> Bool { | ||
abs(self - other) <= tolerance | ||
} | ||
} | ||
|
||
extension CGPoint { | ||
func approxEqual(_ other: CGPoint, tolerance: CGFloat = 0.5) -> Bool { | ||
return self.x.approxEqual(other.x, tolerance: tolerance) | ||
&& self.y.approxEqual(other.y, tolerance: tolerance) | ||
} | ||
} | ||
|
||
extension CGRect { | ||
func approxEqual(_ other: CGRect, tolerance: CGFloat = 0.5) -> Bool { | ||
return self.origin.approxEqual(other.origin, tolerance: tolerance) | ||
&& self.width.approxEqual(other.width, tolerance: tolerance) | ||
&& self.height.approxEqual(other.height, tolerance: tolerance) | ||
} | ||
} |
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
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
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