mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-20 06:30:31 +01:00
Generate a placeholder app icon by rendering the Emoji Evergreen glyph.
This commit is contained in:
parent
41ced60127
commit
a8adf60165
@ -40,10 +40,40 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {
|
||||
super.init()
|
||||
}
|
||||
|
||||
private func evergreenImage() -> NSImage? {
|
||||
var image: NSImage? = nil
|
||||
let imageWidth = 1024
|
||||
let imageHeight = 1024
|
||||
let imageSize = NSMakeSize(CGFloat(imageWidth), CGFloat(imageHeight))
|
||||
|
||||
if let drawingContext = CGContext(data: nil, width: imageWidth, height: imageHeight, bitsPerComponent: 8, bytesPerRow: 0, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedFirst.rawValue) {
|
||||
|
||||
let graphicsContext = NSGraphicsContext(cgContext: drawingContext, flipped: false)
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
NSGraphicsContext.setCurrent(graphicsContext)
|
||||
|
||||
let targetRect = NSRect(origin: NSZeroPoint, size: imageSize)
|
||||
NSString(string: "🌲").draw(in: targetRect, withAttributes: [NSFontAttributeName: NSFont.systemFont(ofSize: 1000)])
|
||||
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
|
||||
if let coreImage = drawingContext.makeImage() {
|
||||
image = NSImage(cgImage: coreImage, size: imageSize)
|
||||
}
|
||||
}
|
||||
|
||||
return image
|
||||
}
|
||||
|
||||
// MARK: NSApplicationDelegate
|
||||
|
||||
func applicationDidFinishLaunching(_ note: Notification) {
|
||||
|
||||
if let appIconImage = evergreenImage() {
|
||||
appIconImage.setName("NSApplicationIcon")
|
||||
NSApplication.shared().applicationIconImage = appIconImage
|
||||
}
|
||||
|
||||
registerDefaults()
|
||||
|
||||
currentTheme = themeLoader.defaultTheme
|
||||
|
Loading…
Reference in New Issue
Block a user