// Code Custodian File ID: 70D0DA44-C34E-4D8F-AF4C-78AAD2F3B690 import Foundation import AppKit func createCircularBadge( characterPath: String, outputPath: String, badgeText: String = "THE GROOVY PANDA", canvasSize: CGFloat = 2048.0, borderWidth: CGFloat = 32.0 ) { print("🛠️ Compositing Pre-Press Badge for: \(URL(fileURLWithPath: characterPath).lastPathComponent)") let size = NSSize(width: canvasSize, height: canvasSize) let image = NSImage(size: size) image.lockFocus() let centerX = canvasSize / 2.0 let centerY = canvasSize / 2.0 let radius = (canvasSize / 2.0) - borderWidth - 16.0 // 1. Radial Gradient Background (Sky Blue Center -> Lavender Edge) let circlePath = NSBezierPath(ovalIn: NSRect(x: centerX - radius, y: centerY - radius, width: radius * 2.0, height: radius * 2.0)) circlePath.addClip() let startColor = NSColor(calibratedRed: 0.35, green: 0.65, blue: 1.0, alpha: 1.0) let endColor = NSColor(calibratedRed: 0.72, green: 0.28, blue: 0.95, alpha: 1.0) if let gradient = NSGradient(starting: startColor, ending: endColor) { gradient.draw( fromCenter: NSPoint(x: centerX, y: centerY), radius: 0.0, toCenter: NSPoint(x: centerX, y: centerY), radius: radius, options: [] ) } // 2. Composite 3D Character if let charImage = NSImage(contentsOfFile: characterPath) { let charWidth = radius * 1.32 let charHeight = radius * 1.32 let charX = centerX - (charWidth / 2.0) let charY = centerY - (charHeight / 2.0) + (radius * 0.08) let targetRect = NSRect(x: charX, y: charY, width: charWidth, height: charHeight) let sourceRect = NSRect(origin: .zero, size: charImage.size) charImage.draw(in: targetRect, from: sourceRect, operation: .sourceOver, fraction: 1.0) } image.unlockFocus() image.lockFocus() // 3. Draw Outer Circular Border Ring (Royal Blue) let borderColor = NSColor(calibratedRed: 0.0, green: 0.18, blue: 0.92, alpha: 1.0) let borderPath = NSBezierPath(ovalIn: NSRect(x: centerX - radius, y: centerY - radius, width: radius * 2.0, height: radius * 2.0)) borderPath.lineWidth = borderWidth borderColor.setStroke() borderPath.stroke() // 4. Render Retro Typography let fontSize = radius * 0.20 let font = NSFont(name: "Impact", size: fontSize) ?? NSFont.boldSystemFont(ofSize: fontSize) let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = .center let textAttrs: [NSAttributedString.Key: Any] = [ .font: font, .foregroundColor: borderColor, .paragraphStyle: paragraphStyle ] let shadowAttrs: [NSAttributedString.Key: Any] = [ .font: font, .foregroundColor: NSColor(calibratedWhite: 0.0, alpha: 0.4), .paragraphStyle: paragraphStyle ] let textWidth = radius * 1.7 let textHeight = fontSize * 1.5 let textX = centerX - (textWidth / 2.0) let textY = centerY - radius + (radius * 0.16) let textRect = NSRect(x: textX, y: textY, width: textWidth, height: textHeight) let shadowRect = NSRect(x: textX + 4.0, y: textY - 4.0, width: textWidth, height: textHeight) let str = NSString(string: badgeText) str.draw(in: shadowRect, withAttributes: shadowAttrs) str.draw(in: textRect, withAttributes: textAttrs) image.unlockFocus() // 5. Save 300 DPI Master PNG if let tiffData = image.tiffRepresentation, let bitmap = NSBitmapImageRep(data: tiffData), let pngData = bitmap.representation(using: .png, properties: [:]) { let url = URL(fileURLWithPath: outputPath) try? FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true) try? pngData.write(to: url) let sizeKB = (try? FileManager.default.attributesOfItem(atPath: outputPath)[.size] as? Int64) ?? 0 print("🎉 [Master Pre-Press] Saved: \(outputPath) (\(Double(sizeKB) / 1024.0) KB)") } } let basePath = "/Volumes/FACTORY_SSD/warezfactory/Art_Cannon" // 1. Willow Official Badge let willowSrc = "\(basePath)/Characters/Willow/willow_dna_anchor.png" let willowDst = "\(basePath)/PrePress/DTF_Apparel/willow_official_badge_300dpi.png" createCircularBadge(characterPath: willowSrc, outputPath: willowDst, badgeText: "THE GROOVY PANDA") // 2. Arlo Official Badge let arloSrc = "\(basePath)/Characters/Arlo/arlo_dna_anchor.png" let arloDst = "\(basePath)/PrePress/DTF_Apparel/arlo_official_badge_300dpi.png" createCircularBadge(characterPath: arloSrc, outputPath: arloDst, badgeText: "THE GROOVY PANDA") // 3. Copy to UV Stickers try? FileManager.default.copyItem(atPath: willowDst, toPath: "\(basePath)/PrePress/Stickers_UV/willow_official_badge_300dpi.png") try? FileManager.default.copyItem(atPath: arloDst, toPath: "\(basePath)/PrePress/Stickers_UV/arlo_official_badge_300dpi.png") print("✅ Official 300 DPI Pre-Press Badges Published to DTF_Apparel and Stickers_UV.")