跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

Icon.swift

24 行 · 1.4 KB历史下载
1import Cocoa
2
3let source = URL(fileURLWithPath: CommandLine.arguments[1])
4let folder = CommandLine.arguments[2]
5guard let image = NSImage(contentsOf: source) else {
6 fatalError("Cannot load icon source: \(source.path)")
7}
8try FileManager.default.createDirectory(atPath: folder, withIntermediateDirectories: true)
9
10for (name, size) in [("icon_16x16", 16), ("icon_16x16@2x", 32), ("icon_32x32", 32), ("icon_32x32@2x", 64), ("icon_128x128", 128), ("icon_128x128@2x", 256), ("icon_256x256", 256), ("icon_256x256@2x", 512), ("icon_512x512", 512), ("icon_512x512@2x", 1024)] {
11 let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: size, pixelsHigh: size, bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!
12 NSGraphicsContext.saveGraphicsState()
13 NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)
14 NSGraphicsContext.current?.imageInterpolation = .high
15 let scale = CGFloat(size) / 1024
16 let transform = NSAffineTransform()
17 transform.scale(by: scale)
18 transform.concat()
19 let bounds = NSRect(x: 60, y: 60, width: 904, height: 904)
20 NSBezierPath(roundedRect: bounds, xRadius: 210, yRadius: 210).addClip()
21 image.draw(in: bounds, from: .zero, operation: .sourceOver, fraction: 1)
22 NSGraphicsContext.restoreGraphicsState()
23 try rep.representation(using: .png, properties: [:])!.write(to: URL(fileURLWithPath: folder + "/" + name + ".png"))
24}