mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-25 14:13:04 +03:00
35 lines
756 B
Swift
35 lines
756 B
Swift
/**
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
* See LICENSE
|
|
*/
|
|
|
|
import Cocoa
|
|
|
|
extension CGRect {
|
|
|
|
public var hashValue: Int {
|
|
return Int(self.origin.x) << 10 ^ Int(self.origin.y) +
|
|
Int(self.size.width) << 10 ^ Int(self.size.height);
|
|
}
|
|
}
|
|
|
|
extension CGSize {
|
|
|
|
func scaling(_ factor: CGFloat) -> CGSize {
|
|
return CGSize(width: self.width * factor, height: self.height * factor)
|
|
}
|
|
}
|
|
|
|
extension NSView {
|
|
|
|
/// - Returns: Rects currently being drawn
|
|
/// - Warning: Call only in drawRect()
|
|
func rectsBeingDrawn() -> [CGRect] {
|
|
var rectsPtr: UnsafePointer<CGRect>? = nil
|
|
var count: Int = 0
|
|
self.getRectsBeingDrawn(&rectsPtr, count: &count)
|
|
|
|
return Array(UnsafeBufferPointer(start: rectsPtr, count: count))
|
|
}
|
|
}
|