-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
1200aaa
commit 7f79d6c
Showing
9 changed files
with
259 additions
and
81 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// EventBackground.swift | ||
// Calendr | ||
// | ||
// Created by Paker on 06/01/2025. | ||
// | ||
|
||
import Cocoa | ||
|
||
enum EventBackground: Equatable { | ||
case clear | ||
case pending | ||
case color(NSColor) | ||
} | ||
|
||
extension EventBackground { | ||
|
||
var cgColor: CGColor { | ||
switch self { | ||
case .clear: .clear | ||
case .pending: pendingBackground | ||
case .color(let color): color.cgColor | ||
} | ||
} | ||
} | ||
|
||
private let pendingBackground: CGColor = { | ||
|
||
let stripes = CIFilter.stripesGenerator() | ||
stripes.color0 = CIColor(color: NSColor.gray.withAlphaComponent(0.25))! | ||
stripes.color1 = .clear | ||
stripes.width = 2.5 | ||
stripes.sharpness = 0 | ||
|
||
let rotated = CIFilter.affineClamp() | ||
rotated.inputImage = stripes.outputImage! | ||
rotated.transform = CGAffineTransform(rotationAngle: -.pi / 4) | ||
|
||
let ciImage = rotated.outputImage!.cropped(to: CGRect(x: 0, y: 0, width: 300, height: 300)) | ||
let rep = NSCIImageRep(ciImage: ciImage) | ||
let nsImage = NSImage(size: rep.size) | ||
nsImage.addRepresentation(rep) | ||
|
||
return NSColor(patternImage: nsImage).cgColor | ||
}() |
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
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
Oops, something went wrong.