-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit aeac0f0
Showing
17 changed files
with
1,351 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
AppIconGenerator.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
AppIconGenerator.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
14 changes: 14 additions & 0 deletions
14
AppIconGenerator.xcodeproj/xcuserdata/prieber.xcuserdatad/xcschemes/xcschememanagement.plist
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>AppIconGenerator.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<key>com.apple.security.assets.pictures.read-write</key> | ||
<true/> | ||
<key>com.apple.security.files.user-selected.read-only</key> | ||
<true/> | ||
<key>com.apple.security.personal-information.photos-library</key> | ||
<true/> | ||
</dict> | ||
</plist> |
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,148 @@ | ||
// | ||
// AppIconGeneratorApp.swift | ||
// AppIconGenerator | ||
// | ||
// Created by Ryan Priebe on 2023-07-15. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
public enum ShapeFillType { | ||
case gradient, solid | ||
} | ||
|
||
@main | ||
struct AppIconGeneratorApp: App { | ||
@State public var colours: [Color] = [ | ||
Color.random(), | ||
Color.random(), | ||
Color.random() | ||
] | ||
@State public var numberOfLayers: Float = 1.0 | ||
@State public var startPoint: UnitPoint = .top | ||
@State public var endPoint: UnitPoint = .bottom | ||
@State public var layers: [any IconLayer] = [] | ||
@State public var maskCornerRoundness: Float = 300.0 | ||
@State public var constrained: Bool = true | ||
@State public var backgroundColour: Int = 0 | ||
@State public var shapeFillType: Int = 0 | ||
@State public var uiVisible: Bool = true | ||
|
||
var body: some Scene { | ||
let preview = ContentView( | ||
colours: $colours, | ||
gradientLayers: $layers, | ||
startPoint: $startPoint, | ||
endPoint: $endPoint, | ||
numberOfLayers: $numberOfLayers, | ||
maskCornerRoundness: $maskCornerRoundness, | ||
constrained: $constrained, | ||
backgroundColour: $backgroundColour, | ||
shapeFillType: $shapeFillType | ||
) | ||
|
||
let interface = Interface( | ||
colours: $colours, | ||
layers: $layers, | ||
startPoint: $startPoint, | ||
endPoint: $endPoint, | ||
numberOfLayers: $numberOfLayers, | ||
maskCornerRoundness: $maskCornerRoundness, | ||
constrained: $constrained, | ||
backgroundColour: $backgroundColour, | ||
shapeFillType: $shapeFillType, | ||
uiVisible: $uiVisible | ||
) | ||
|
||
WindowGroup { | ||
VStack(alignment: .leading) { | ||
// HStack(alignment: .top) { | ||
// preview | ||
// .frame(width: 100, height: 100) | ||
// .scaledToFill() | ||
// .background(.clear) | ||
// interface | ||
// } | ||
ZStack(alignment: .top) { | ||
ScrollView { | ||
preview | ||
.frame(width: 1100, height: 1100) | ||
.background(.clear) | ||
} | ||
|
||
if uiVisible { | ||
interface | ||
} else { | ||
HStack { | ||
Spacer() | ||
Button { | ||
withAnimation { | ||
uiVisible.toggle() | ||
} | ||
} label: { | ||
ZStack { | ||
Color.accentColor | ||
Image(systemName: "arrow.down.backward.square") | ||
.font(.largeTitle) | ||
} | ||
.frame(width: 50, height: 50) | ||
} | ||
.buttonStyle(.plain) | ||
.onHover { inside in | ||
if inside { | ||
NSCursor.pointingHand.push() | ||
} else { | ||
NSCursor.pop() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
.commands { | ||
CommandGroup(after: .newItem) { | ||
Button("Save") { | ||
let screenshot = preview.snapshot() | ||
let timestamp = Date.now.timeIntervalSince1970 | ||
let exportFolder = "/AIG-Export-\(timestamp)/" | ||
let picturesDir = FileManager.default.urls(for: .picturesDirectory, in: .userDomainMask).first! | ||
let imageURL = picturesDir | ||
.appending(component: exportFolder) | ||
|
||
do { | ||
try FileManager.default.createDirectory(atPath: picturesDir.path + exportFolder, withIntermediateDirectories: false) | ||
} catch { | ||
print("Couldn't create folder") | ||
} | ||
|
||
saveAtSize(screenshot: screenshot!, h: 1024, w: 1024, path: imageURL) | ||
saveAtSize(screenshot: screenshot!, h: 512, w: 512, path: imageURL) | ||
saveAtSize(screenshot: screenshot!, h: 256, w: 256, path: imageURL) | ||
saveAtSize(screenshot: screenshot!, h: 128, w: 128, path: imageURL) | ||
saveAtSize(screenshot: screenshot!, h: 64, w: 64, path: imageURL) | ||
saveAtSize(screenshot: screenshot!, h: 32, w: 32, path: imageURL) | ||
saveAtSize(screenshot: screenshot!, h: 16, w: 16, path: imageURL) | ||
} | ||
.keyboardShortcut("s", modifiers: .command) | ||
} | ||
} | ||
} | ||
|
||
private func saveAtSize(screenshot: NSImage, h: Int, w: Int, path: URL) -> Void { | ||
let image = screenshot.resize(w: w, h: h) | ||
let fileName = "\(h)x\(w).png" | ||
|
||
if let png = image.png { | ||
do { | ||
try png.write(to: path.appending(component: fileName)) | ||
print("\(fileName) saved") | ||
} catch { | ||
print(error) | ||
} | ||
} else { | ||
print("No PNG data?") | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
AppIconGenerator/Assets.xcassets/AccentColor.colorset/Contents.json
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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions
60
AppIconGenerator/Assets.xcassets/AppIcon.appiconset/Contents.json
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,60 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "1024x1024-16.png", | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"filename" : "1024x1024-32.png", | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "512x512" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "512x512" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.