-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
20 changed files
with
263 additions
and
297 deletions.
There are no files selected for viewing
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,5 @@ | ||
line_length: 115 | ||
cyclomatic_complexity: 12 | ||
|
||
excluded: | ||
- Carthage |
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
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
Binary file modified
BIN
-497 Bytes
(98%)
Icns Composer/Assets.xcassets/Icns Composer.appiconset/mac_appicon-128@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-444 Bytes
(99%)
Icns Composer/Assets.xcassets/Icns Composer.appiconset/mac_appicon-128@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-19 Bytes
(100%)
Icns Composer/Assets.xcassets/Icns Composer.appiconset/mac_appicon-16@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-57 Bytes
(99%)
Icns Composer/Assets.xcassets/Icns Composer.appiconset/mac_appicon-16@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-444 Bytes
(99%)
Icns Composer/Assets.xcassets/Icns Composer.appiconset/mac_appicon-256@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-34 Bytes
(100%)
Icns Composer/Assets.xcassets/Icns Composer.appiconset/mac_appicon-256@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-57 Bytes
(99%)
Icns Composer/Assets.xcassets/Icns Composer.appiconset/mac_appicon-32@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-171 Bytes
(99%)
Icns Composer/Assets.xcassets/Icns Composer.appiconset/mac_appicon-32@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-34 Bytes
(100%)
Icns Composer/Assets.xcassets/Icns Composer.appiconset/mac_appicon-512@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+27.7 KB
(100%)
Icns Composer/Assets.xcassets/Icns Composer.appiconset/mac_appicon-512@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,81 @@ | ||
// | ||
// IconImage.swift | ||
// Icns Composer | ||
// https://github.com/raphaelhanneken/icnscomposer | ||
// | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2015 Raphael Hanneken | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import Cocoa | ||
|
||
/// Defines the scale of an image. | ||
/// | ||
/// - at1x: A Scale of @1x | ||
/// - at2x: A Scale of @2x | ||
/// - at3x: A Scale of @3x | ||
enum ImageScale: String { | ||
case x1 = "@1x" | ||
case x2 = "@2x" | ||
} | ||
|
||
/// Represents a single image of an iconset. | ||
struct IconImage { | ||
/// Holds the image it represents. | ||
let image: NSImage? | ||
/// The image scale. | ||
let scale: ImageScale | ||
/// The images size. | ||
let size: NSSize | ||
|
||
var filename: String { | ||
switch scale { | ||
case .x1: | ||
return "icon_\(Int(size.width))x\(Int(size.height))\(scale.rawValue).png" | ||
case .x2: | ||
return "icon_\(Int(size.width / 2))x\(Int(size.height / 2))\(scale.rawValue).png" | ||
} | ||
} | ||
|
||
/// Initialize a new iconset image. | ||
init?(_ image: NSImage?, withSize size: NSSize, andScale scale: ImageScale) { | ||
guard let image = image else { | ||
return nil | ||
} | ||
// Resize the supplied image. | ||
self.image = image.copyWithSize(size) | ||
self.scale = scale | ||
self.size = size | ||
} | ||
|
||
/// Write the iconset image to the supplied url. | ||
/// | ||
/// - parameter url: The url where to save the image. | ||
func writeToURL(_ url: URL) throws { | ||
// Define the image name. | ||
let imgURL = try url.appendingPathComponent(filename, isDirectory: false) | ||
|
||
// Get the png representation of the image and write it to the supplied url. | ||
if let png = image?.PNGRepresentation() { | ||
try png.write(to: imgURL, options: .atomic) | ||
} | ||
} | ||
} |
Oops, something went wrong.