From 11c32b31a5e83cea94afb7bbdc649e2edbab6a7c Mon Sep 17 00:00:00 2001 From: Kaiyin Zhong Date: Sat, 17 Dec 2016 14:52:11 +0100 Subject: [PATCH] support ios icons --- genicon.xcodeproj/project.pbxproj | 8 ++ .../UserInterfaceState.xcuserstate | Bin 23155 -> 23489 bytes .../MyPlayground.playground/Contents.swift | 136 +++++++++++++++++- genicon/extension.swift | 23 +++ genicon/generateJson.swift | 25 ++++ genicon/main.swift | 44 ++---- readme.md | 19 ++- 7 files changed, 218 insertions(+), 37 deletions(-) create mode 100644 genicon/extension.swift create mode 100644 genicon/generateJson.swift diff --git a/genicon.xcodeproj/project.pbxproj b/genicon.xcodeproj/project.pbxproj index f0274d2..357c952 100644 --- a/genicon.xcodeproj/project.pbxproj +++ b/genicon.xcodeproj/project.pbxproj @@ -7,10 +7,12 @@ objects = { /* Begin PBXBuildFile section */ + BC3A58B41E057543009174F9 /* extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC3A58B31E057543009174F9 /* extension.swift */; }; BC3B068F1E033E7C00A89BE9 /* dataModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC9B8D891E01DFBF0096E77F /* dataModels.swift */; }; BC9B8D7E1E01AE220096E77F /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC9B8D7D1E01AE220096E77F /* main.swift */; }; BC9B8D851E01B2860096E77F /* execCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC9B8D841E01B2860096E77F /* execCommand.swift */; }; BC9B8D8A1E01DFBF0096E77F /* dataModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC9B8D891E01DFBF0096E77F /* dataModels.swift */; }; + BCA85D0F1E0567E000F7B41E /* generateJson.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCA85D0E1E0567E000F7B41E /* generateJson.swift */; }; BCD78DE81E03126F009A3BD3 /* testgenicon.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCD78DE71E03126F009A3BD3 /* testgenicon.swift */; }; /* End PBXBuildFile section */ @@ -27,6 +29,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + BC3A58B31E057543009174F9 /* extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = extension.swift; sourceTree = ""; }; BC9B8D7A1E01AE220096E77F /* genicon */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = genicon; sourceTree = BUILT_PRODUCTS_DIR; }; BC9B8D7D1E01AE220096E77F /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; BC9B8D841E01B2860096E77F /* execCommand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = execCommand.swift; sourceTree = ""; }; @@ -34,6 +37,7 @@ BC9B8D891E01DFBF0096E77F /* dataModels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dataModels.swift; sourceTree = ""; }; BCA410DF1E02B20E003F10A7 /* genicodeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = genicodeTests.swift; sourceTree = ""; }; BCA410E11E02B20E003F10A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + BCA85D0E1E0567E000F7B41E /* generateJson.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = generateJson.swift; sourceTree = ""; }; BCD78DE51E03126F009A3BD3 /* testgenicon.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = testgenicon.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; BCD78DE71E03126F009A3BD3 /* testgenicon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = testgenicon.swift; sourceTree = ""; }; BCD78DE91E03126F009A3BD3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -83,6 +87,8 @@ BC9B8D841E01B2860096E77F /* execCommand.swift */, BC9B8D881E01D4C20096E77F /* MyPlayground.playground */, BC9B8D891E01DFBF0096E77F /* dataModels.swift */, + BCA85D0E1E0567E000F7B41E /* generateJson.swift */, + BC3A58B31E057543009174F9 /* extension.swift */, ); path = genicon; sourceTree = ""; @@ -199,6 +205,8 @@ files = ( BC9B8D851E01B2860096E77F /* execCommand.swift in Sources */, BC9B8D8A1E01DFBF0096E77F /* dataModels.swift in Sources */, + BCA85D0F1E0567E000F7B41E /* generateJson.swift in Sources */, + BC3A58B41E057543009174F9 /* extension.swift in Sources */, BC9B8D7E1E01AE220096E77F /* main.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/genicon.xcodeproj/project.xcworkspace/xcuserdata/kaiyin.xcuserdatad/UserInterfaceState.xcuserstate b/genicon.xcodeproj/project.xcworkspace/xcuserdata/kaiyin.xcuserdatad/UserInterfaceState.xcuserstate index a51123779b2afb9a11078e98842cce1739804ab3..be176a112b9c22f654632588798769744cdb1c05 100644 GIT binary patch delta 13281 zcma)i2S8KT_y4>1Eg&HYD-Z%nfJ`6+ke!4umEk~fDJ;@Ab%FYpx<*~6Zculr2h>CA5%nAO0zlvf+(8&n z0}apu9nb><2nP`$5*R@ghyn3-kOY!}1=v6aXbakb0?;0G09`>hPz-v5exN@X0xCcy z7zz-;U>q0^CV+`x5|{_(g9TtASOgY>C15331?s>W@FCa&c7gri6L0_=2A_j3zzOg* zI1SE#^WXyb7Tf?g!7Xqb+yM{3L+}JV1@`CQZ^%I&xex!EfMq@FKhfe}p&S9rzP` z0)MC7X%AXT`_lomj8@VrT1$u15p*OSO~=tmbTXYnr_vd8CY?*Sqr1`F=^k`Xx;I@# zSJO3gEj^qbL64+I(G%%O^kjMpJ(ZqDPp4-=Ke@AJf0kPv}4C7xZ5Y%`l8R){n6b>ejGaLYX5M3FGP9W3 zc4iK0}ntbi4=o~(!!vl7;e^=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=8W+?>p<9tDGC0o17mzw>q~u_c{+ak2%jeuQ-2pJAZZl=Dg?p!}-wp#QC%x+pbl+ zz;+>7le4B}&COboRiCvkYg^XAtixGHvyNqbmvu7hbku%QltUt2l z*=gBBvKMAA&#uqjki98;d-k5}gW2b^FJ)iPzL|Y1`%d+wH=iB11E|II7-KduzbX#fBK diff --git a/genicon/MyPlayground.playground/Contents.swift b/genicon/MyPlayground.playground/Contents.swift index 655f6c4..ab5eaf7 100644 --- a/genicon/MyPlayground.playground/Contents.swift +++ b/genicon/MyPlayground.playground/Contents.swift @@ -4,4 +4,138 @@ import Foundation let s = jsonify(pair: ("name", "Julia"), quoteValue: true) -print(s) \ No newline at end of file +print(s) + + +enum Fruit { + case apple, pear, banana +} + +enum Drink { + case beer, whisky, vodka +} + +enum FruitPlusDrink { + case fruit(Fruit) + case drink(Drink) +} + +enum FruitTimesDrink1 { + case value(fruit: Fruit, drink: Drink) +} + +struct FruitTimesDrink { + let fruit: Fruit + let drink: Drink +} + +// composition +let content = "10,20,40,30,80,60" +func extractElements(_ content: String) -> [String] { + return content.characters.split(separator: ",").map {String($0)} +} +func formatWithCurrency(content: [String]) -> [String] { + return content.map {"€" + $0} +} +let composedFunciton = { data in + formatWithCurrency(content: extractElements(data)) +} +print(composedFunciton(content)) + +infix operator |> : MultiplicationPrecedence +func |> (f: @escaping (T) -> V, g: @escaping (V) -> V) -> (T) -> V { + return { + x in + g(f(x)) + } +} + +var res = (extractElements |> formatWithCurrency)(content) +print(res) + +res = extractElements(content).sorted(by: { + (a, b) in + a > b +}) +print(res) +// if the only param is a closure, then the syntax can be simplified as: +res = extractElements(content).sorted { + (a, b) in + a > b +} +print(res) +// this can be simplified further +res = extractElements(content).sorted { + $0 > $1 +} +print(res) + +func opOnNumber(number: Int, op: (Int) -> Bool) -> Bool { + return op(number) +} +// if the last param is a closure, you can write it this way (similar to scala): +// looks like functions are automatically curried. +var boolRes = opOnNumber(number: 3) { + $0 > 5 +} +print(boolRes) + +// tail recursion +func factorial(n: Int, accumulator: Int) -> Int { + return n == 0 ? accumulator : factorial(n: n-1, accumulator: n * accumulator) +} +print(factorial(n: 4, accumulator: 1)) + + +class MemoizedPower2 { + var memo: [Int: Int] = [:] + func power2(n: Int) -> Int { + assert(n >= 0, "Negative power not supported!") + if let result = memo[n] { + return result + } else { + var result = 1 + for _ in 1...n { + result *= 2 + } + memo[n] = result + return result + } + } + init(memo: [Int:Int]) { + self.memo = memo + } + static let sharedInstance: MemoizedPower2 = { + let obj = MemoizedPower2(memo: [0:1, 1:2]) + return obj + }() +} + +func printTimeElapsedWhenRunningCode(title:String, operation:()->()) { + let startTime = CFAbsoluteTimeGetCurrent() + operation() + let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime + print("Time elapsed for \(title): \(timeElapsed) s") +} + +printTimeElapsedWhenRunningCode(title: "power2") { + for _ in 1...200 { + let _ = MemoizedPower2.sharedInstance.power2(n: 55) + } +} +printTimeElapsedWhenRunningCode(title: "power2") { + for _ in 1...200 { + var x = 1 + for i in 1...55 { + x *= 2 + } + } +} + +//func memoize(fn: ((T) -> U, T) -> U) -> (T) -> U { +// +//} + + + + diff --git a/genicon/extension.swift b/genicon/extension.swift new file mode 100644 index 0000000..5bdbeb2 --- /dev/null +++ b/genicon/extension.swift @@ -0,0 +1,23 @@ +// +// extension.swift +// genicon +// +// Created by Kaiyin Zhong on 12/17/16. +// Copyright © 2016 vu.co.kaiyin. All rights reserved. +// + +import Foundation +extension String { + var absolutePath: String { + if self == "." { + return cwd + } + if self.hasPrefix("/") { + return self + } + return cwd + "/" + self + } + func fileURL(isDirectory: Bool) -> URL? { + return URL(fileURLWithPath: absolutePath, isDirectory: isDirectory) + } +} diff --git a/genicon/generateJson.swift b/genicon/generateJson.swift new file mode 100644 index 0000000..69fbec8 --- /dev/null +++ b/genicon/generateJson.swift @@ -0,0 +1,25 @@ +// +// generateJson.swift +// genicon +// +// Created by Kaiyin Zhong on 12/17/16. +// Copyright © 2016 vu.co.kaiyin. All rights reserved. +// + +import Foundation + +public func generateContents(sizes: [Int], scales: [Int]) -> Contents { + var contents = Contents() + for sz in sizes { + for sc in scales { + let img = ImageInfo(size: sz, scale: sc) + contents.images.append(img) + } + } + return contents +} + +public let macSizes = [16, 32, 128, 512] +public let macScales = [1, 2] +public let iosSizes = [20, 29, 40, 60] +public let iosScales = [2, 3] diff --git a/genicon/main.swift b/genicon/main.swift index f9ea89c..ba4f5de 100644 --- a/genicon/main.swift +++ b/genicon/main.swift @@ -8,38 +8,24 @@ import Foundation -if CommandLine.arguments.contains("--help") || CommandLine.arguments.contains("-h") || CommandLine.arguments.dropFirst().isEmpty { - print("\n genicon: A command line tool for generating icons for Cocoa apps.\n", "© Kaiyin Zhong 2016\n\n", "Usage: \n", "genicon INPUT OUTPUT_FOLDER") +let args = CommandLine.arguments +if args.contains("--help") || args.contains("-h") || args.dropFirst().isEmpty { + print("\n genicon: A command line tool for generating icons for Cocoa apps.\n", "© Kaiyin Zhong 2016\n\n", "Usage: \n", "genicon [options] INPUT OUTPUT_FOLDER\n\n", "--help, -h Print this message.\n", "--mac Generate icons for macOS.\n", "--ios Generate icons for iOS. When neither --mac nor --ios is given, mac icons are generated by default.\n") exit(0) } + + let fm = FileManager.default let cwd = fm.currentDirectoryPath -extension String { - var absolutePath: String { - if self == "." { - return cwd - } - if self.hasPrefix("/") { - return self - } - return cwd + "/" + self - } - func fileURL(isDirectory: Bool) -> URL? { - return URL(fileURLWithPath: absolutePath, isDirectory: isDirectory) - } -} + // set up folders -let inputFile: URL = CommandLine.arguments[1].fileURL(isDirectory: false)! -let outputFolder: URL = CommandLine.arguments[2].fileURL(isDirectory: true)! +let inputFile: URL = args[1].fileURL(isDirectory: false)! +let outputFolder: URL = args[2].fileURL(isDirectory: true)! //let inputFile = URL(string: "file:///Users/kaiyin/Desktop/dr89/Dr89.svg")! //let outputFolder = URL(string: "file:///tmp")! let iconFolder = outputFolder.appendingPathComponent("AppIcon.appiconset", isDirectory: true) - - - - do { if !fm.fileExists(atPath: iconFolder.path) { try fm.createDirectory(at: iconFolder, withIntermediateDirectories: true, attributes: [:]) @@ -52,14 +38,14 @@ do { } // generate Contents.json -var contents = Contents() -let size = [16, 32, 128, 512] -for sz in size { - for sc in 1...2 { - let img = ImageInfo(size: sz, scale: sc) - contents.images.append(img) - } +var contents: Contents = Contents() +// when neither --mac nor --ios is given, mac icons are generated by default. +if args.contains("--mac") || !args.contains("--ios"){ + contents = generateContents(sizes: macSizes, scales: macScales) +} else if args.contains("--ios") { + contents = generateContents(sizes: iosSizes, scales: iosScales) } + let jsonFilename = "Contents.json" let jsonUrl = iconFolder.appendingPathComponent(jsonFilename) do { diff --git a/readme.md b/readme.md index a78ac2c..0228858 100644 --- a/readme.md +++ b/readme.md @@ -1,18 +1,23 @@ -# genicon: A command line tool for generating icons for Cocoa apps. +# genicon: A command line tool for generating icons for macOS/iOS apps. -This tool wraps imagemagick to provide a convenient utility for generating cocoa app icons that conform to Apple's standard. You should feed a large square image (>= 1024x1024), or (preferrably) an svg file, and get all appropriate sizes plus a proper json index in a `AppIcon.appiconset` folder, which can be directly copied into the `Assets.xcassets` folder in your cocoa project. +This tool wraps imagemagick to provide a convenient utility for generating macOS/iOS app icons that conform to Apple's standard. You should feed it a large square image (>= 1024x1024), or (preferrably) an svg file, and get all appropriate sizes plus a proper json index in a `AppIcon.appiconset` folder, which can be directly copied into the `Assets.xcassets` folder in your Xcode project. # Usage Type `genicon` or `genicon -h` in terminal: - $genicon - genicon: A command line tool for generating icons for Cocoa apps. - © Kaiyin Zhong 2016 + $ genicon - Usage: - genicon INPUT OUTPUT_FOLDER + genicon: A command line tool for generating icons for Cocoa apps. + © Kaiyin Zhong 2016 + + Usage: + genicon [options] INPUT OUTPUT_FOLDER + + --help, -h Print this message. + --mac Generate icons for macOS. + --ios Generate icons for iOS. When neither --mac nor --ios is given, mac icons are generated by default. # Requirements