This file contains hidden or 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
import Foundation | |
let USING_TEST_INPUT = false | |
let commandURL = URL(fileURLWithPath: CommandLine.arguments[0]) | |
let inputFileName = USING_TEST_INPUT ? "test.txt" : "input.txt" | |
let inputFileURL = commandURL.deletingLastPathComponent().appendingPathComponent(inputFileName) | |
let inputText = try! String(contentsOf: inputFileURL, encoding: .utf8).trimmingCharacters(in: .whitespacesAndNewlines) | |
let inputLines = inputText.split(separator: "\n") |
This file contains hidden or 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
import Cocoa | |
func imageFromEmoji(emoji: String, size: CGSize) -> NSImage? { | |
let image = NSImage(size: size) | |
image.lockFocus() | |
let attributes: [NSAttributedString.Key: Any] = [ | |
.font: NSFont.systemFont(ofSize: size.height) // Adjust font size based on image size | |
] | |
let attributedString = NSAttributedString(string: emoji, attributes: attributes) |
OlderNewer