fix: paint window-aligned gradients within popup bounds
This commit is contained in:
@@ -13,6 +13,7 @@ enum SunsetPalette {
|
||||
|
||||
@MainActor
|
||||
final class LauncherBackground: NSView {
|
||||
weak var canvas: NSView?
|
||||
private let amber = NSGradient(colors: [
|
||||
SunsetPalette.accent.withAlphaComponent(0.18),
|
||||
SunsetPalette.accent.withAlphaComponent(0.065),
|
||||
@@ -29,17 +30,21 @@ final class LauncherBackground: NSView {
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
SunsetPalette.background.setFill()
|
||||
dirtyRect.fill()
|
||||
let upperGlow = NSPoint(x: bounds.width * 0.58, y: bounds.height * 0.94)
|
||||
let canvasBounds = canvas.map { convert($0.bounds, from: $0) } ?? bounds
|
||||
let upperGlow = NSPoint(x: canvasBounds.minX + canvasBounds.width * 0.58,
|
||||
y: canvasBounds.minY + canvasBounds.height * 0.94)
|
||||
ember.draw(fromCenter: upperGlow, radius: 0, toCenter: upperGlow,
|
||||
radius: bounds.width * 0.40, options: [])
|
||||
let lowerGlow = NSPoint(x: bounds.width * 0.88, y: bounds.height * 0.10)
|
||||
radius: canvasBounds.width * 0.40, options: [])
|
||||
let lowerGlow = NSPoint(x: canvasBounds.minX + canvasBounds.width * 0.88,
|
||||
y: canvasBounds.minY + canvasBounds.height * 0.10)
|
||||
amber.draw(fromCenter: lowerGlow, radius: 0, toCenter: lowerGlow,
|
||||
radius: bounds.width * 0.55, options: [])
|
||||
let leftGlow = NSPoint(x: bounds.width * 0.08, y: bounds.height * 0.65)
|
||||
radius: canvasBounds.width * 0.55, options: [])
|
||||
let leftGlow = NSPoint(x: canvasBounds.minX + canvasBounds.width * 0.08,
|
||||
y: canvasBounds.minY + canvasBounds.height * 0.65)
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
NSGraphicsContext.current?.cgContext.setAlpha(0.45)
|
||||
amber.draw(fromCenter: leftGlow, radius: 0, toCenter: leftGlow,
|
||||
radius: bounds.width * 0.32, options: [])
|
||||
radius: canvasBounds.width * 0.32, options: [])
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user