Created
April 6, 2019 20:00
-
-
Save Dameck/d61602bae2bb7c715be19504613d9596 to your computer and use it in GitHub Desktop.
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 flashScreen() { | |
let inDuration : CGDisplayFadeInterval = 0.5 | |
let outDuration : CGDisplayFadeInterval = 0.5 | |
let redColor = NSColor.red | |
var token : CGDisplayFadeReservationToken = UInt32(kCGDisplayFadeReservationInvalidToken) | |
let color = redColor.usingColorSpace(NSColorSpace.sRGB)! | |
if CGAcquireDisplayFadeReservation(inDuration + outDuration, &token) == CGError.success { | |
CGDisplayFade(token, | |
inDuration, | |
0.0 as CGDisplayBlendFraction, | |
0.2 as CGDisplayBlendFraction, | |
Float(color.redComponent), | |
Float(color.greenComponent), | |
Float(color.blueComponent), | |
boolean_t(1)) | |
CGDisplayFade(token, | |
inDuration, | |
0.2 as CGDisplayBlendFraction, | |
0.0 as CGDisplayBlendFraction, | |
Float(color.redComponent), | |
Float(color.greenComponent), | |
Float(color.blueComponent), | |
boolean_t(1)) | |
CGReleaseDisplayFadeReservation(token) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment