repo_name
stringlengths 6
91
| path
stringlengths 8
968
| copies
stringclasses 210
values | size
stringlengths 2
7
| content
stringlengths 61
1.01M
| license
stringclasses 15
values | hash
stringlengths 32
32
| line_mean
float64 6
99.8
| line_max
int64 12
1k
| alpha_frac
float64 0.3
0.91
| ratio
float64 2
9.89
| autogenerated
bool 1
class | config_or_test
bool 2
classes | has_no_keywords
bool 2
classes | has_few_assignments
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TelerikAcademy/Mobile-Applications-with-iOS
|
demos/CustomViewsDemos/CustomViewsDemos/View/ImageAndTextTableViewCell.swift
|
1
|
987
|
//
// ImageAndTextTableCellTableViewCell.swift
// CustomViewsDemos
//
// Created by Doncho Minkov on 3/24/17.
// Copyright © 2017 Doncho Minkov. All rights reserved.
//
import UIKit
class ImageAndTextTableViewCell: UITableViewCell {
@IBOutlet weak var theImage: ImageWithLoading!
@IBOutlet weak var theLabel: UILabel!
override var textLabel: UILabel? {
get {
return self.theLabel
}
set(textLabel) {
self.theLabel = textLabel
}
}
override func awakeFromNib() {
super.awakeFromNib()
self.theLabel.baselineAdjustment = .none
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
if selected {
self.backgroundColor = .black
self.theLabel.textColor = .white
} else {
self.backgroundColor = .white
self.theLabel.textColor = .black
}
}
}
|
mit
|
2ca7b251afb35f51eab58acc6ba58bc8
| 24.282051 | 65 | 0.615619 | 4.481818 | false | false | false | false |
KyleLeneau/swift-mvvm-examples
|
swift-mvvm-examples/View/ClickCounterView.swift
|
1
|
3390
|
//
// ClickCounterswift
// swift-mvvm-examples
//
// Created by Kyle LeNeau on 11/3/17.
// Copyright © 2017 Kyle LeNeau. All rights reserved.
//
import Foundation
class ClickCounterView: UIView {
let clickCountLabel = UILabel()
let clickButton = UIButton()
let clickAlertLabel = UILabel()
let resetButton = UIButton()
override func layoutSubviews() {
super.layoutSubviews()
setupUI()
}
fileprivate func setupUI() {
backgroundColor = UIColor.white
clickCountLabel.translatesAutoresizingMaskIntoConstraints = false
clickCountLabel.textAlignment = .center
clickCountLabel.backgroundColor = UIColor.green
clickCountLabel.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.headline)
addSubview(clickCountLabel)
NSLayoutConstraint.activate([
clickCountLabel.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor, constant: 20.0),
clickCountLabel.heightAnchor.constraint(equalToConstant: 60.0),
clickCountLabel.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
clickCountLabel.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor)
])
clickButton.translatesAutoresizingMaskIntoConstraints = false
clickButton.setTitle("Click Me", for: UIControl.State())
clickButton.setTitleColor(UIColor.blue, for: UIControl.State())
clickButton.setTitleColor(UIColor.orange, for: .disabled)
addSubview(clickButton)
NSLayoutConstraint.activate([
clickButton.topAnchor.constraint(equalTo: clickCountLabel.bottomAnchor, constant: 20.0),
clickButton.heightAnchor.constraint(equalToConstant: 40.0),
clickButton.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
clickButton.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor)
])
clickAlertLabel.translatesAutoresizingMaskIntoConstraints = false
clickAlertLabel.numberOfLines = 2
clickAlertLabel.text = "That's too many clicks! Please stop before you wear out your fingers."
clickAlertLabel.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
addSubview(clickAlertLabel)
NSLayoutConstraint.activate([
clickAlertLabel.topAnchor.constraint(equalTo: clickButton.bottomAnchor, constant: 20.0),
clickAlertLabel.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
clickAlertLabel.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor)
])
resetButton.translatesAutoresizingMaskIntoConstraints = false
resetButton.setTitle("Reset Clicks", for: UIControl.State())
resetButton.setTitleColor(UIColor.blue, for: UIControl.State())
resetButton.setTitleColor(UIColor.orange, for: .disabled)
addSubview(resetButton)
NSLayoutConstraint.activate([
resetButton.topAnchor.constraint(equalTo: clickAlertLabel.bottomAnchor, constant: 20.0),
resetButton.heightAnchor.constraint(equalToConstant: 40.0),
resetButton.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
resetButton.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor)
])
}
}
|
apache-2.0
|
408c4a9924fdc4ebe263b2db2d01a017
| 45.424658 | 104 | 0.720567 | 5.610927 | false | false | false | false |
gabmarfer/CucumberPicker
|
CucumberPicker/CucumberPicker/Managers/ImageCache.swift
|
1
|
6318
|
//
// ImageCache.swift
// CucumberPicker
//
// Created by gabmarfer on 31/01/2017.
// Copyright © 2017 Kenoca Software. All rights reserved.
//
// Cache images in a temporary folder. Load them using its URLs.
import Foundation
import UIKit
import Photos
class ImageCache: NSObject {
var maximumImageSize = CGSize(width: 1024.0, height: 1024.0)
var mininumImageSize = CGSize(width: 400.0, height: 400.0)
/// Ordered list of selected image URLs
private(set) var imageURLs = Array<URL>()
/// Set of selected assets to allow deselect them
private(set) var selectedAssets = Set<PHAsset>()
var images: [UIImage] {
var images = [UIImage]()
do {
for fileURL in imageURLs {
let data = try Data(contentsOf: fileURL)
if let image = UIImage(data: data) {
images.append(image)
}
}
} catch { print("Error \(error)") }
return images
}
var numberOfTakenPhotos: Int {
return imageURLs.count - selectedAssets.count
}
fileprivate var cachedURLs = Dictionary<String, URL>() // <imageKey, fileURL>
fileprivate let imageExtension = ".jpg"
fileprivate var assetIdentifierKeys = Dictionary<String, String>() // <assetLocalIdentifier, imageKey>
// MARK: Utils
func thumbnailImageFromAsset(_ asset: PHAsset, of width: Int) -> UIImage? {
guard let imageKey = assetIdentifierKeys[asset.localIdentifier], let fileURL = cachedURLs[imageKey] else {
return nil
}
guard let image = UIImage(contentsOfFile: fileURL.path) else {
return nil
}
return thumbnailImageFromImage(image, of: width)
}
func thumbnailImageFromImage(_ image: UIImage, of width: Int) -> UIImage {
return image.thumbnailImage(width, transparentBorder: 0, cornerRadius: 0, interpolationQuality: .high)
}
// MARK: Cache assets
func saveImageFromAsset(_ asset: PHAsset, resultHandler: ((URL?) -> Void)?) {
let requestOptions = PHImageRequestOptions()
requestOptions.resizeMode = .exact
requestOptions.deliveryMode = .highQualityFormat
requestOptions.isSynchronous = false
PHImageManager.default().requestImage(for: asset, targetSize: maximumImageSize, contentMode: .aspectFill, options: requestOptions, resultHandler: {
[weak self] (image, info) in
guard let strongSelf = self else { return }
if let imageToSave = image, let url = strongSelf.saveImage(imageToSave, named: strongSelf.keyForAsset(asset)) {
guard let strongSelf = self else { return }
strongSelf.selectedAssets.insert(asset)
resultHandler?(url)
} else {
resultHandler?(nil)
}
})
}
func urlsForAssets(_ assets: [PHAsset]) -> [URL] {
var urls = Array<URL>()
for asset in assets {
if let imageKey = assetIdentifierKeys[asset.localIdentifier], let fileURL = cachedURLs[imageKey] {
urls.append(fileURL)
}
}
return urls
}
@discardableResult func removeImageFromAsset(_ asset: PHAsset) -> Bool {
let key = keyForAsset(asset)
selectedAssets.remove(asset)
return removeImage(named: key)
}
// MARK: Cache images
@discardableResult func saveImage(_ image: UIImage) -> URL? {
return saveImage(image, named: randomImageKey())
}
@discardableResult func removeImage(named filename: String) -> Bool {
do {
let fileURL = getURL(for: filename)
try FileManager.default.removeItem(at: fileURL)
cachedURLs.removeValue(forKey: filename)
if let urlIdx = imageURLs.index(of: fileURL) {
imageURLs.remove(at: urlIdx)
}
// print("Removed image in path: \(fileURL)")
return true
} catch { return false }
}
@discardableResult func removeAllImages() -> Bool {
var result = true
for (filename, _) in cachedURLs {
result = removeImage(named: filename)
}
selectedAssets.removeAll()
return result
}
// MARK: Private methods
@discardableResult fileprivate func saveImage(_ image: UIImage, named filename: String) -> URL? {
// Scale the image before saving
let newSize = (image.size.width > maximumImageSize.width || image.size.height > maximumImageSize.height) ? maximumImageSize : image.size
var compressedImage = image.resizedImageWithContentMode(.scaleAspectFill, bounds: newSize, interpolationQuality: .medium)
if (compressedImage.size.width < mininumImageSize.width || compressedImage.size.height < mininumImageSize.height) {
compressedImage = compressedImage.resizedImageWithContentMode(.scaleAspectFill, bounds: mininumImageSize, interpolationQuality: .high)
}
guard let data = UIImageJPEGRepresentation(compressedImage, 1.0) else { return nil }
do {
let fileURL = getURL(for: filename)
try data.write(to: fileURL)
// Save the path
cachedURLs[filename] = fileURL
imageURLs.append(fileURL)
// print("Saved image in path: \(fileURL)")
return fileURL
} catch {
print("error saving file: \(error)")
return nil
}
}
fileprivate func randomImageKey() -> String {
return NSUUID().uuidString + imageExtension
}
fileprivate func keyForAsset(_ asset: PHAsset) -> String {
// If asset is already saved, just return its imageKey
if let imageKey = assetIdentifierKeys[asset.localIdentifier] {
return imageKey
}
// Save imageKey
let newImageKey = randomImageKey()
assetIdentifierKeys[asset.localIdentifier] = newImageKey
return newImageKey
}
fileprivate func getURL(for filename: String) -> URL {
return URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(filename)
}
}
|
mit
|
5278def793e87acec5e603c4030082e4
| 35.097143 | 155 | 0.611366 | 5.065758 | false | false | false | false |
pekoto/fightydot
|
FightyDot/FightyDotTests/GameSnapshotTests.swift
|
1
|
29236
|
//
// GameSnapshotTests.swift
// FightyDot
//
// Created by Graham McRobbie on 22/07/2017.
// Copyright © 2017 Graham McRobbie. All rights reserved.
//
// The board looks like this:
//
// 0) 0---------1---------2
// | | |
// 2) | 3------4------5 |
// | | | | |
// 3) | | 6--7--8 | |
// | | | | | |
// 4) 9--10--11 12--13-14
// | | | | | |
// 5) | | 15-16-17 | |
// | | | | |
// 6) | 18-----19-----20 |
// | | |
// 7) 21--------22-------23
//
import XCTest
@testable import FightyDot
class GameSnapshotTests: XCTestCase {
private var _gameSnapshot: GameSnapshot!
private var _board: Board!
private var _p1: Player!
private var _p2: Player!
override func setUp() {
super.setUp()
_board = Board(view: nil)
_p1 = try! Player(name: Constants.PlayerData.defaultPvpP1Name, colour: .green, type: .humanLocal, isStartingPlayer: true, playerNum: .p1, view: nil)
_p2 = try! Player(name: Constants.PlayerData.defaultPvpP2Name, colour: .red, type: .humanLocal, isStartingPlayer: false, playerNum: .p2, view: nil)
_gameSnapshot = GameSnapshot(board: _board, currentPlayer: _p1, opponent: _p2)
}
override func tearDown() {
super.tearDown()
_p1 = nil
_p2 = nil
_board = nil
_gameSnapshot = nil
}
// MARK: - Get moves tests
// Place some pieces and then check we get a
// list of valid moves back depending on state
func testGetPlacementMoves() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 9)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
_ = _p2.playPiece(node: _board.getNode(withID: 12)!)
_ = _p2.playPiece(node: _board.getNode(withID: 2)!)
let moves = _gameSnapshot.getPossibleMoves()
XCTAssertEqual(moves.count, 20) // all empty nodes returned
XCTAssertEqual(moves.filter { move in move.type == .PlacePiece }.count, 20) // all move types are for placing a piece
XCTAssertEqual(moves.filter { move in move.targetNode.id == 3 }.count, 1) // empty node is included
XCTAssertEqual(moves.filter { move in move.targetNode.id == 0 }.count, 0) // filled node not included
}
func testGetPlacementMoves_MillFormed() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
let moves = _gameSnapshot.getPossibleMoves()
XCTAssertEqual(moves.count, 21)
XCTAssertEqual(moves.filter { move in move.formsMill }.count, 2)
}
func testGetMovementMoves() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 8)!)
let moves = _gameSnapshot.getPossibleMoves()
XCTAssertEqual(moves.count, 6)
XCTAssertEqual(moves.filter { move in move.type == .MovePiece }.count, 6)
XCTAssertEqual(moves.filter { move in move.targetNode.id == 0 }.count, 1)
XCTAssertEqual(moves.filter { move in move.destinationNode!.id == 9 }.count, 1)
XCTAssertEqual(moves.filter { move in move.targetNode.id == 1 }.count, 0) // Node is blocked
}
func testgetMovementMoves_MillFormed() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 12)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
let moves = _gameSnapshot.getPossibleMoves()
XCTAssertEqual(moves.count, 9)
XCTAssertEqual(moves.filter { move in move.type == .MovePiece }.count, 9)
XCTAssertEqual(moves.filter { move in move.formsMill }.count, 1)
}
func testGetFlyingMoves() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 8)!)
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
_ = _p2.playPiece(node: _board.getNode(withID: 17)!)
_ = _p2.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 19)!)
_ = _p2.playPiece(node: _board.getNode(withID: 20)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 22)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
_p1.losePiece(node: _board.getNode(withID: 0)!)
_p1.losePiece(node: _board.getNode(withID: 1)!)
_p1.losePiece(node: _board.getNode(withID: 2)!)
_p1.losePiece(node: _board.getNode(withID: 3)!)
_p1.losePiece(node: _board.getNode(withID: 4)!)
_p1.losePiece(node: _board.getNode(withID: 5)!)
let moves = _gameSnapshot.getPossibleMoves()
// 3 nodes left * 12 empty spaces = 36 possible moves
XCTAssertEqual(moves.count, 36)
XCTAssertEqual(moves.filter { move in move.type == .MovePiece }.count, 36)
XCTAssertEqual(moves.filter { move in move.targetNode.id == 6 }.count, 12)
XCTAssertEqual(moves.filter { move in move.destinationNode!.id == 0 }.count, 3)
XCTAssertEqual(moves.filter { move in move.destinationNode!.id == 6 }.count, 0)
}
func testGetFlyingMoves_MillFormed() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 12)!)
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
_ = _p2.playPiece(node: _board.getNode(withID: 17)!)
_ = _p2.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 19)!)
_ = _p2.playPiece(node: _board.getNode(withID: 20)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 22)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
_p1.losePiece(node: _board.getNode(withID: 0)!)
_p1.losePiece(node: _board.getNode(withID: 1)!)
_p1.losePiece(node: _board.getNode(withID: 2)!)
_p1.losePiece(node: _board.getNode(withID: 3)!)
_p1.losePiece(node: _board.getNode(withID: 4)!)
_p1.losePiece(node: _board.getNode(withID: 5)!)
let moves = _gameSnapshot.getPossibleMoves()
// 3 nodes left * 12 empty spaces = 36 possible moves + moves to take p2's pieces
XCTAssertEqual(moves.count, 44)
XCTAssertEqual(moves.filter { move in move.type == .MovePiece }.count, 44)
XCTAssertEqual(moves.filter { move in move.formsMill }.count, 9)
}
// MARK: - Make move tests
// Feed in some move and check the resulting game snapshot is correct
func testPlacePiece() {
let move = Move(type: .PlacePiece, targetNode: _board.getNode(withID: 1)!)
let nextGameSnapshot = _gameSnapshot.getNewSnapshotFrom(move: move)
let moves = nextGameSnapshot.getPossibleMoves()
XCTAssertEqual(moves.count, 23)
XCTAssertEqual(moves.filter { move in move.targetNode.id == 1 }.count, 0)
}
func testPlaceMultiplePieces() {
let greenMoveOne = Move(type: .PlacePiece, targetNode: _board.getNode(withID: 1)!)
let greenTurnOne = _gameSnapshot.getNewSnapshotFrom(move: greenMoveOne)
let redMoveOne = Move(type: .PlacePiece, targetNode: _board.getNode(withID: 0)!)
let redTurnOne = greenTurnOne.getNewSnapshotFrom(move: redMoveOne)
let moves = redTurnOne.getPossibleMoves()
XCTAssertEqual(moves.count, 22)
XCTAssertEqual(moves.filter { move in move.targetNode.id == 0 }.count, 0)
XCTAssertEqual(moves.filter { move in move.targetNode.id == 1 }.count, 0)
}
func testPlacePiece_MillFormed() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p2.playPiece(node: _board.getNode(withID: 9)!)
let move = Move(type: .PlacePiece, targetNode: _board.getNode(withID: 2)!, destinationNode: nil, nodeToTake: _board.getNode(withID: 9)!)
let nextGameSnapshot = _gameSnapshot.getNewSnapshotFrom(move: move)
let moves = nextGameSnapshot.getPossibleMoves()
XCTAssertEqual(moves.count, 21)
XCTAssertEqual(moves.filter { move in move.targetNode.id == 2 }.count, 0)
XCTAssertEqual(moves.filter { move in move.targetNode.id == 9 }.count, 1)
}
func testMovePiece() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 8)!)
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
_ = _p2.playPiece(node: _board.getNode(withID: 17)!)
_ = _p2.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 19)!)
_ = _p2.playPiece(node: _board.getNode(withID: 20)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 22)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
let move = Move(type: .MovePiece, targetNode: _board.getNode(withID: 0)!, destinationNode: _board.getNode(withID: 9)!)
let nextGameSnapshot = _gameSnapshot.getNewSnapshotFrom(move: move)
let moves = nextGameSnapshot.getPossibleMoves()
XCTAssertEqual(moves.count, 5)
XCTAssertEqual(moves.filter { move in move.type == .MovePiece }.count, 5)
}
func testMovePiece_MillFormed() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 12)!)
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
_ = _p2.playPiece(node: _board.getNode(withID: 17)!)
_ = _p2.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 19)!)
_ = _p2.playPiece(node: _board.getNode(withID: 20)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 22)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
let move = Move(type: .MovePiece, targetNode: _board.getNode(withID: 12)!, destinationNode: _board.getNode(withID: 8)!, nodeToTake: _board.getNode(withID: 15)!)
let nextGameSnapshot = _gameSnapshot.getNewSnapshotFrom(move: move)
let moves = nextGameSnapshot.getPossibleMoves()
XCTAssertEqual(moves.count, 6)
XCTAssertEqual(moves.filter { move in move.type == .MovePiece }.count, 6)
}
func testFlyPiece() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 8)!)
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
_ = _p2.playPiece(node: _board.getNode(withID: 17)!)
_ = _p2.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 19)!)
_ = _p2.playPiece(node: _board.getNode(withID: 20)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 22)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
_p1.losePiece(node: _board.getNode(withID: 0)!)
_p1.losePiece(node: _board.getNode(withID: 1)!)
_p1.losePiece(node: _board.getNode(withID: 2)!)
_p1.losePiece(node: _board.getNode(withID: 3)!)
_p1.losePiece(node: _board.getNode(withID: 4)!)
_p1.losePiece(node: _board.getNode(withID: 5)!)
let move = Move(type: .MovePiece, targetNode: _board.getNode(withID: 6)!, destinationNode: _board.getNode(withID: 0)!)
let nextGameSnapshot = _gameSnapshot.getNewSnapshotFrom(move: move)
let moves = nextGameSnapshot.getPossibleMoves()
XCTAssertEqual(moves.count, 6)
XCTAssertEqual(moves.filter { move in move.type == .MovePiece }.count, 6)
}
func testFlyPiece_MillFormed() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 12)!)
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
_ = _p2.playPiece(node: _board.getNode(withID: 17)!)
_ = _p2.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 19)!)
_ = _p2.playPiece(node: _board.getNode(withID: 20)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 22)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
_p1.losePiece(node: _board.getNode(withID: 0)!)
_p1.losePiece(node: _board.getNode(withID: 1)!)
_p1.losePiece(node: _board.getNode(withID: 2)!)
_p1.losePiece(node: _board.getNode(withID: 3)!)
_p1.losePiece(node: _board.getNode(withID: 4)!)
_p1.losePiece(node: _board.getNode(withID: 5)!)
let move = Move(type: .MovePiece, targetNode: _board.getNode(withID: 12)!, destinationNode: _board.getNode(withID: 8)!, nodeToTake: _board.getNode(withID: 15)!)
let nextGameSnapshot = _gameSnapshot.getNewSnapshotFrom(move: move)
let moves = nextGameSnapshot.getPossibleMoves()
XCTAssertEqual(moves.count, 6)
XCTAssertEqual(moves.filter { move in move.type == .MovePiece }.count, 6)
}
// MARK: - Heuristic evaluation score tests
func testHeuristic_ScoreEven() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
_ = _p2.playPiece(node: _board.getNode(withID: 17)!)
XCTAssertEqual(_gameSnapshot.heuristicScore, 0)
}
func testHeuristic_GreenWinState() {
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
_ = _p2.playPiece(node: _board.getNode(withID: 17)!)
_ = _p2.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 19)!)
_ = _p2.playPiece(node: _board.getNode(withID: 20)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 22)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
_p2.losePiece(node: _board.getNode(withID: 15)!)
_p2.losePiece(node: _board.getNode(withID: 16)!)
_p2.losePiece(node: _board.getNode(withID: 17)!)
_p2.losePiece(node: _board.getNode(withID: 18)!)
_p2.losePiece(node: _board.getNode(withID: 19)!)
_p2.losePiece(node: _board.getNode(withID: 20)!)
_p2.losePiece(node: _board.getNode(withID: 21)!)
XCTAssertEqual(_gameSnapshot.heuristicScore, Constants.WinScores.greenWin)
}
func testHeuristic_RedWinState() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 8)!)
_p1.losePiece(node: _board.getNode(withID: 0)!)
_p1.losePiece(node: _board.getNode(withID: 1)!)
_p1.losePiece(node: _board.getNode(withID: 2)!)
_p1.losePiece(node: _board.getNode(withID: 3)!)
_p1.losePiece(node: _board.getNode(withID: 4)!)
_p1.losePiece(node: _board.getNode(withID: 5)!)
_p1.losePiece(node: _board.getNode(withID: 6)!)
XCTAssertEqual(_gameSnapshot.heuristicScore, Constants.WinScores.redWin)
}
func testHeuristic_PlacingGreenWinning() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p2.playPiece(node: _board.getNode(withID: 10)!)
_ = _p2.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 19)!)
XCTAssertGreaterThan(_gameSnapshot.heuristicScore, 0)
}
func testHeuristic_PlacingRedWinning() {
_ = _p1.playPiece(node: _board.getNode(withID: 23)!)
_ = _p1.playPiece(node: _board.getNode(withID: 22)!)
_ = _p1.playPiece(node: _board.getNode(withID: 12)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 0)!)
_ = _p2.playPiece(node: _board.getNode(withID: 1)!)
_ = _p2.playPiece(node: _board.getNode(withID: 9)!)
_ = _p2.playPiece(node: _board.getNode(withID: 4)!)
_ = _p2.playPiece(node: _board.getNode(withID: 10)!)
XCTAssertLessThan(_gameSnapshot.heuristicScore, 0)
}
func testHeuristic_MovementGreenWinning() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 19)!)
_ = _p1.playPiece(node: _board.getNode(withID: 22)!)
_ = _p1.playPiece(node: _board.getNode(withID: 8)!)
_ = _p1.playPiece(node: _board.getNode(withID: 12)!)
_ = _p1.playPiece(node: _board.getNode(withID: 17)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_p1.losePiece(node: _board.getNode(withID: 0)!)
_p1.losePiece(node: _board.getNode(withID: 1)!)
_p1.losePiece(node: _board.getNode(withID: 2)!)
_p1.losePiece(node: _board.getNode(withID: 3)!)
_ = _p2.playPiece(node: _board.getNode(withID: 0)!)
_ = _p2.playPiece(node: _board.getNode(withID: 1)!)
_ = _p2.playPiece(node: _board.getNode(withID: 2)!)
_ = _p2.playPiece(node: _board.getNode(withID: 3)!)
_ = _p2.playPiece(node: _board.getNode(withID: 9)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
_ = _p2.playPiece(node: _board.getNode(withID: 13)!)
_ = _p2.playPiece(node: _board.getNode(withID: 14)!)
_p2.losePiece(node: _board.getNode(withID: 0)!)
_p2.losePiece(node: _board.getNode(withID: 1)!)
_p2.losePiece(node: _board.getNode(withID: 2)!)
_p2.losePiece(node: _board.getNode(withID: 9)!)
_p2.losePiece(node: _board.getNode(withID: 23)!)
XCTAssertGreaterThan(_gameSnapshot.heuristicScore, 0)
}
func testHeuristic_MovementRedWinning() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 19)!)
_ = _p1.playPiece(node: _board.getNode(withID: 22)!)
_ = _p1.playPiece(node: _board.getNode(withID: 8)!)
_ = _p1.playPiece(node: _board.getNode(withID: 12)!)
_ = _p1.playPiece(node: _board.getNode(withID: 17)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_p1.losePiece(node: _board.getNode(withID: 0)!)
_p1.losePiece(node: _board.getNode(withID: 1)!)
_p1.losePiece(node: _board.getNode(withID: 2)!)
_p1.losePiece(node: _board.getNode(withID: 3)!)
_p1.losePiece(node: _board.getNode(withID: 22)!)
_p1.losePiece(node: _board.getNode(withID: 8)!)
_ = _p2.playPiece(node: _board.getNode(withID: 0)!)
_ = _p2.playPiece(node: _board.getNode(withID: 1)!)
_ = _p2.playPiece(node: _board.getNode(withID: 2)!)
_ = _p2.playPiece(node: _board.getNode(withID: 3)!)
_ = _p2.playPiece(node: _board.getNode(withID: 9)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 22)!)
_ = _p2.playPiece(node: _board.getNode(withID: 13)!)
_ = _p2.playPiece(node: _board.getNode(withID: 14)!)
_p2.losePiece(node: _board.getNode(withID: 23)!)
_p2.losePiece(node: _board.getNode(withID: 14)!)
_p2.losePiece(node: _board.getNode(withID: 21)!)
_p2.losePiece(node: _board.getNode(withID: 13)!)
_p2.losePiece(node: _board.getNode(withID: 14)!)
XCTAssertLessThan(_gameSnapshot.heuristicScore, 0)
}
func testHeuristic_FlyingGreenWinning() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 8)!)
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
_ = _p2.playPiece(node: _board.getNode(withID: 17)!)
_ = _p2.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 19)!)
_ = _p2.playPiece(node: _board.getNode(withID: 20)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 22)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
_p1.losePiece(node: _board.getNode(withID: 0)!)
_p1.losePiece(node: _board.getNode(withID: 2)!)
_p1.losePiece(node: _board.getNode(withID: 3)!)
_p1.losePiece(node: _board.getNode(withID: 5)!)
_p1.losePiece(node: _board.getNode(withID: 6)!)
_p1.losePiece(node: _board.getNode(withID: 7)!)
_p2.losePiece(node: _board.getNode(withID: 15)!)
_p2.losePiece(node: _board.getNode(withID: 16)!)
_p2.losePiece(node: _board.getNode(withID: 17)!)
_p2.losePiece(node: _board.getNode(withID: 18)!)
_p2.losePiece(node: _board.getNode(withID: 19)!)
_p2.losePiece(node: _board.getNode(withID: 20)!)
XCTAssertGreaterThan(_gameSnapshot.heuristicScore, 0)
}
func testHeuristic_FlyingRedWinning() {
_ = _p1.playPiece(node: _board.getNode(withID: 0)!)
_ = _p1.playPiece(node: _board.getNode(withID: 1)!)
_ = _p1.playPiece(node: _board.getNode(withID: 2)!)
_ = _p1.playPiece(node: _board.getNode(withID: 3)!)
_ = _p1.playPiece(node: _board.getNode(withID: 4)!)
_ = _p1.playPiece(node: _board.getNode(withID: 5)!)
_ = _p1.playPiece(node: _board.getNode(withID: 6)!)
_ = _p1.playPiece(node: _board.getNode(withID: 7)!)
_ = _p1.playPiece(node: _board.getNode(withID: 8)!)
_ = _p2.playPiece(node: _board.getNode(withID: 15)!)
_ = _p2.playPiece(node: _board.getNode(withID: 16)!)
_ = _p2.playPiece(node: _board.getNode(withID: 17)!)
_ = _p2.playPiece(node: _board.getNode(withID: 18)!)
_ = _p2.playPiece(node: _board.getNode(withID: 19)!)
_ = _p2.playPiece(node: _board.getNode(withID: 20)!)
_ = _p2.playPiece(node: _board.getNode(withID: 21)!)
_ = _p2.playPiece(node: _board.getNode(withID: 22)!)
_ = _p2.playPiece(node: _board.getNode(withID: 23)!)
_p1.losePiece(node: _board.getNode(withID: 0)!)
_p1.losePiece(node: _board.getNode(withID: 1)!)
_p1.losePiece(node: _board.getNode(withID: 2)!)
_p1.losePiece(node: _board.getNode(withID: 3)!)
_p1.losePiece(node: _board.getNode(withID: 4)!)
_p1.losePiece(node: _board.getNode(withID: 5)!)
_p2.losePiece(node: _board.getNode(withID: 15)!)
_p2.losePiece(node: _board.getNode(withID: 16)!)
_p2.losePiece(node: _board.getNode(withID: 17)!)
_p2.losePiece(node: _board.getNode(withID: 18)!)
_p2.losePiece(node: _board.getNode(withID: 21)!)
_p2.losePiece(node: _board.getNode(withID: 23)!)
XCTAssertLessThan(_gameSnapshot.heuristicScore, 0)
}
}
|
mit
|
7c9528fd84a5d680b013b2e7a6ce77da
| 46.847791 | 168 | 0.584231 | 3.105811 | false | false | false | false |
haijianhuo/TopStore
|
TopStore/UIKit+TopStore.swift
|
1
|
1521
|
//
// UIKit+TopStore.swift
// TopStore
//
// Created by Haijian Huo on 7/14/17.
// Copyright © 2017 Haijian Huo. All rights reserved.
//
import UIKit
public extension UIView {
@IBInspectable public var cornerRadius: CGFloat {
get {
return layer.cornerRadius
}
set {
layer.cornerRadius = newValue
}
}
@IBInspectable public var shadowRadius: CGFloat {
get {
return layer.shadowRadius
}
set {
layer.shadowRadius = newValue
}
}
@IBInspectable public var shadowOpacity: Float {
get {
return layer.shadowOpacity
}
set {
layer.shadowOpacity = newValue
}
}
@IBInspectable public var shadowColor: UIColor? {
get {
return layer.shadowColor != nil ? UIColor(cgColor: layer.shadowColor!) : nil
}
set {
layer.shadowColor = newValue?.cgColor
}
}
@IBInspectable public var shadowOffset: CGSize {
get {
return layer.shadowOffset
}
set {
layer.shadowOffset = newValue
}
}
@IBInspectable public var zPosition: CGFloat {
get {
return layer.zPosition
}
set {
layer.zPosition = newValue
}
}
}
func viewController(forStoryboardName: String) -> UIViewController {
return UIStoryboard(name: forStoryboardName, bundle: nil).instantiateInitialViewController()!
}
class TemplateImageView: UIImageView {
@IBInspectable var templateImage: UIImage? {
didSet {
image = templateImage?.withRenderingMode(.alwaysTemplate)
}
}
}
|
mit
|
e238a740a4d7f5d657ac6e03877447b8
| 18.487179 | 95 | 0.648684 | 4.52381 | false | false | false | false |
justindarc/firefox-ios
|
Shared/DeferredUtils.swift
|
8
|
6061
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Monadic bind/flatMap operator for Deferred.
precedencegroup MonadicBindPrecedence {
associativity: left
higherThan: MonadicDoPrecedence
lowerThan: BitwiseShiftPrecedence
}
precedencegroup MonadicDoPrecedence {
associativity: left
higherThan: MultiplicationPrecedence
}
infix operator >>== : MonadicBindPrecedence
infix operator >>> : MonadicDoPrecedence
@discardableResult public func >>== <T, U>(x: Deferred<Maybe<T>>, f: @escaping (T) -> Deferred<Maybe<U>>) -> Deferred<Maybe<U>> {
return chainDeferred(x, f: f)
}
// A termination case.
public func >>== <T>(x: Deferred<Maybe<T>>, f: @escaping (T) -> Void) {
return x.upon { result in
if let v = result.successValue {
f(v)
}
}
}
// Monadic `do` for Deferred.
@discardableResult public func >>> <T, U>(x: Deferred<Maybe<T>>, f: @escaping () -> Deferred<Maybe<U>>) -> Deferred<Maybe<U>> {
return x.bind { res in
if res.isSuccess {
return f()
}
return deferMaybe(res.failureValue!)
}
}
// Another termination case.
public func >>> <T>(x: Deferred<Maybe<T>>, f: @escaping () -> Void) {
return x.upon { res in
if res.isSuccess {
f()
}
}
}
/**
* Returns a thunk that return a Deferred that resolves to the provided value.
*/
public func always<T>(_ t: T) -> () -> Deferred<Maybe<T>> {
return { deferMaybe(t) }
}
public func deferMaybe<T>(_ s: T) -> Deferred<Maybe<T>> {
return Deferred(value: Maybe(success: s))
}
public func deferMaybe<T>(_ e: MaybeErrorType) -> Deferred<Maybe<T>> {
return Deferred(value: Maybe(failure: e))
}
public typealias Success = Deferred<Maybe<Void>>
@discardableResult public func succeed() -> Success {
return deferMaybe(())
}
/**
* Return a single Deferred that represents the sequential chaining
* of f over the provided items.
*/
public func walk<T>(_ items: [T], f: @escaping (T) -> Success) -> Success {
return items.reduce(succeed()) { success, item -> Success in
success >>> { f(item) }
}
}
/**
* Like `all`, but thanks to its taking thunks as input, each result is
* generated in strict sequence. Fails immediately if any result is failure.
*/
public func accumulate<T>(_ thunks: [() -> Deferred<Maybe<T>>]) -> Deferred<Maybe<[T]>> {
if thunks.isEmpty {
return deferMaybe([])
}
let combined = Deferred<Maybe<[T]>>()
var results: [T] = []
results.reserveCapacity(thunks.count)
var onValue: ((T) -> Void)!
var onResult: ((Maybe<T>) -> Void)!
// onValue and onResult both hold references to each other niling them out before exiting breaks a reference cycle
// We also cannot use unowned here because the thunks are not class types.
onValue = { t in
results.append(t)
if results.count == thunks.count {
onResult = nil
combined.fill(Maybe(success: results))
} else {
thunks[results.count]().upon(onResult)
}
}
onResult = { r in
if r.isFailure {
onValue = nil
combined.fill(Maybe(failure: r.failureValue!))
return
}
onValue(r.successValue!)
}
thunks[0]().upon(onResult)
return combined
}
/**
* Take a function and turn it into a side-effect that can appear
* in a chain of async operations without producing its own value.
*/
public func effect<T, U>(_ f: @escaping (T) -> U) -> (T) -> Deferred<Maybe<T>> {
return { t in
_ = f(t)
return deferMaybe(t)
}
}
// Prevents "Cannot convert call result type '(_) -> Deferred<Maybe<_>>' to expected type '() -> Deferred<Maybe<Void>>"
// SE-0029 introduced this behavour
// https://github.com/apple/swift-evolution/blob/master/proposals/0029-remove-implicit-tuple-splat.md
public func effect(_ f: @escaping (Swift.Void) -> Void) -> (() -> Success) {
return {
f(())
return succeed()
}
}
/**
* Return a single Deferred that represents the sequential chaining of
* f over the provided items, with the return value chained through.
*/
public func walk<T, U, S: Sequence>(_ items: S, start: Deferred<Maybe<U>>, f: @escaping (T, U) -> Deferred<Maybe<U>>) -> Deferred<Maybe<U>> where S.Iterator.Element == T {
let fs = items.map { item in
return { val in
f(item, val)
}
}
return fs.reduce(start, >>==)
}
/**
* Like `all`, but doesn't accrue individual values.
*/
extension Array where Element: Success {
public func allSucceed() -> Success {
return all(self).bind { results -> Success in
if let failure = results.find({ $0.isFailure }) {
return deferMaybe(failure.failureValue!)
}
return succeed()
}
}
}
public func chainDeferred<T, U>(_ a: Deferred<Maybe<T>>, f: @escaping (T) -> Deferred<Maybe<U>>) -> Deferred<Maybe<U>> {
return a.bind { res in
if let v = res.successValue {
return f(v)
}
return Deferred(value: Maybe<U>(failure: res.failureValue!))
}
}
public func chainResult<T, U>(_ a: Deferred<Maybe<T>>, f: @escaping (T) -> Maybe<U>) -> Deferred<Maybe<U>> {
return a.map { res in
if let v = res.successValue {
return f(v)
}
return Maybe<U>(failure: res.failureValue!)
}
}
public func chain<T, U>(_ a: Deferred<Maybe<T>>, f: @escaping (T) -> U) -> Deferred<Maybe<U>> {
return chainResult(a, f: { Maybe<U>(success: f($0)) })
}
/// Defer-ifies a block to an async dispatch queue.
public func deferDispatchAsync<T>(_ queue: DispatchQueue, f: @escaping () -> Deferred<Maybe<T>>) -> Deferred<Maybe<T>> {
let deferred = Deferred<Maybe<T>>()
queue.async(execute: {
f().upon { result in
deferred.fill(result)
}
})
return deferred
}
|
mpl-2.0
|
3718784347e9eb68077bd6fa26618bcd
| 28.565854 | 171 | 0.6098 | 3.785759 | false | false | false | false |
Athlee/ATHKit
|
Examples/ATHImagePickerController/Storyboard/TestPicker/Pods/Material/Sources/iOS/MotionBasic.swift
|
2
|
15579
|
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
public enum AnimationKeyPath: String {
case backgroundColor
case cornerRadius
case transform
case rotation = "transform.rotation"
case rotationX = "transform.rotation.x"
case rotationY = "transform.rotation.y"
case rotationZ = "transform.rotation.z"
case scale = "transform.scale"
case scaleX = "transform.scale.x"
case scaleY = "transform.scale.y"
case scaleZ = "transform.scale.z"
case translation = "transform.translation"
case translationX = "transform.translation.x"
case translationY = "transform.translation.y"
case translationZ = "transform.translation.z"
case position
case shadowPath
}
extension CABasicAnimation {
/**
A convenience initializer that takes a given AnimationKeyPath.
- Parameter keyPath: An AnimationKeyPath.
*/
public convenience init(keyPath: AnimationKeyPath) {
self.init(keyPath: keyPath.rawValue)
}
}
extension Motion {
/**
Creates a CABasicAnimation for the backgroundColor key path.
- Parameter color: A UIColor.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func backgroundColor(color: UIColor, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .backgroundColor)
animation.toValue = color.cgColor
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the cornerRadius key path.
- Parameter radius: A CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func cornerRadius(radius: CGFloat, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .cornerRadius)
animation.toValue = radius
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform key path.
- Parameter transform: A CATransform3D object.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func transform(transform: CATransform3D, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .transform)
animation.toValue = NSValue(caTransform3D: transform)
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.rotation key path.
- Parameter angle: An optional CGFloat.
- Parameter rotation: An optional CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func rotate(angle: CGFloat? = nil, rotation: CGFloat? = nil, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotation)
if let v = angle {
animation.toValue = (CGFloat(M_PI) * v / 180) as NSNumber
} else if let v = rotation {
animation.toValue = (CGFloat(M_PI * 2) * v) as NSNumber
}
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.rotation.x key path.
- Parameter angle: An optional CGFloat.
- Parameter rotation: An optional CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func rotateX(angle: CGFloat? = nil, rotation: CGFloat? = nil, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationX)
if let v: CGFloat = angle {
animation.toValue = (CGFloat(M_PI) * v / 180) as NSNumber
} else if let v: CGFloat = rotation {
animation.toValue = (CGFloat(M_PI * 2) * v) as NSNumber
}
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.rotation.y key path.
- Parameter angle: An optional CGFloat.
- Parameter rotation: An optional CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func rotateY(angle: CGFloat? = nil, rotation: CGFloat? = nil, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationY)
if let v = angle {
animation.toValue = (CGFloat(M_PI) * v / 180) as NSNumber
} else if let v = rotation {
animation.toValue = (CGFloat(M_PI * 2) * v) as NSNumber
}
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.rotation.z key path.
- Parameter angle: An optional CGFloat.
- Parameter rotation: An optional CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func rotateZ(angle: CGFloat? = nil, rotation: CGFloat? = nil, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationZ)
if let v = angle {
animation.toValue = (CGFloat(M_PI) * v / 180) as NSNumber
} else if let v = rotation {
animation.toValue = (CGFloat(M_PI * 2) * v) as NSNumber
}
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.scale key path.
- Parameter by scale: A CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func scale(by scale: CGFloat, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .scale)
animation.toValue = scale as NSNumber
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.scale.x key path.
- Parameter by scale: A CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func scaleX(by scale: CGFloat, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .scaleX)
animation.toValue = scale as NSNumber
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.scale.y key path.
- Parameter by scale: A CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func scaleY(by scale: CGFloat, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .scaleY)
animation.toValue = scale as NSNumber
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.scale.z key path.
- Parameter by scale: A CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func scaleZ(by scale: CGFloat, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .scaleZ)
animation.toValue = scale as NSNumber
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.translation key path.
- Parameter size: A CGSize.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func translate(size: CGSize, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .translation)
animation.toValue = NSValue(cgSize: size)
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.translation.x key path.
- Parameter by translation: A CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func translateX(by translation: CGFloat, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .translationX)
animation.toValue = translation as NSNumber
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.translation.y key path.
- Parameter by translation: A CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func translateY(by translation: CGFloat, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .translationY)
animation.toValue = translation as NSNumber
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the transform.translation.z key path.
- Parameter by translation: A CGFloat.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func translateZ(by translation: CGFloat, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .translationZ)
animation.toValue = translation as NSNumber
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the position key path.
- Parameter to point: A CGPoint.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func position(to point: CGPoint, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .position)
animation.toValue = NSValue(cgPoint: point)
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .easeInEaseOut)
if let v = duration {
animation.duration = v
}
return animation
}
/**
Creates a CABasicAnimation for the shadowPath key path.
- Parameter to path: A CGPath.
- Parameter duration: An animation time duration.
- Returns: A CABasicAnimation.
*/
public static func shadowPath(to path: CGPath, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .shadowPath)
animation.toValue = path
animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false
animation.timingFunction = AnimationTimingFunctionToValue(function: .linear)
if let v = duration {
animation.duration = v
}
return animation
}
}
|
mit
|
3a54fce274d6e0a1de9a691e47421b48
| 35.829787 | 134 | 0.712819 | 4.695298 | false | false | false | false |
Praveer-Rai/SwiftValidator
|
ValidatorTests/ValidatorTests.swift
|
12
|
9839
|
//
// ValidatorTests.swift
// ValidatorTests
//
// Created by Jeff Potter on 11/20/14.
// Copyright (c) 2014 jpotts18. All rights reserved.
//
import UIKit
import XCTest
import Validator
class ValidatorTests: XCTestCase {
let USERNAME_REGEX = "^[a-z0-9_-]{3,16}$"
let VALID_ZIP = "12345"
let INVALID_ZIP = "1234"
let VALID_EMAIL = "[email protected]"
let INVALID_EMAIL = "This is not a valid email"
let CONFIRM_TXT_FIELD = UITextField()
let CONFIRM_TEXT = "Confirm this!"
let CONFIRM_TEXT_DIFF = "I am not the same as the string above"
let VALID_PASSWORD = "Super$ecret"
let INVALID_PASSWORD = "abc"
let VALID_FLOAT = "1234.444"
let INVALID_FLOAT = "1234.44.44"
let LEN_3 = "hey"
let LEN_5 = "Howdy"
let LEN_20 = "Paint the cat orange"
let REGISTER_TXT_FIELD = UITextField()
let REGISTER_VALIDATOR = Validator()
let REGISTER_RULES = [Rule]()
let UNREGISTER_TXT_FIELD = UITextField()
let UNREGISTER_VALIDATOR = Validator()
let UNREGISTER_RULES = [Rule]()
let UNREGISTER_ERRORS_TXT_FIELD = UITextField()
let UNREGISTER_ERRORS_VALIDATOR = Validator()
let ERROR_LABEL = UILabel()
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
// MARK: Required
func testRequired() {
XCTAssertTrue(RequiredRule().validate("Something"), "Required should be valid")
}
func testRequiredInvalid() {
XCTAssertFalse(RequiredRule().validate(""), "Required should be invalid")
}
// MARK: Regex
func testRegex(){
XCTAssertTrue(RegexRule(regex: USERNAME_REGEX).validate("darth_vader8"), "RegexRule should be valid")
}
func testRegexInvalid(){
XCTAssertFalse(RegexRule(regex: USERNAME_REGEX).validate("DarthVader"), "RegexRule should be invalid")
}
// MARK: Zipcode
func testZipCode() {
XCTAssertTrue(ZipCodeRule().validate(VALID_ZIP), "Zipcode should be valid")
}
func testZipCodeInvalid() {
XCTAssertFalse(ZipCodeRule().validate(INVALID_ZIP), "Zipcode should be invalid")
}
// MARK: Email
func testEmail() {
XCTAssertTrue(EmailRule().validate(VALID_EMAIL), "Email should be valid")
}
func testEmailInvalid() {
XCTAssertFalse(EmailRule().validate(INVALID_EMAIL), "Email should be invalid")
}
// MARK: Float
func testFloat() {
XCTAssert(FloatRule().validate(VALID_FLOAT), "Float should be valid")
}
func testFloatInvalid() {
XCTAssert(!FloatRule().validate(INVALID_FLOAT), "Float should be invalid")
XCTAssert(!FloatRule().validate(VALID_EMAIL), "Float should be invalid")
}
// MARK: Confirm against field
func testConfirmSame(){
CONFIRM_TXT_FIELD.text = CONFIRM_TEXT
XCTAssertTrue(ConfirmationRule(confirmField: CONFIRM_TXT_FIELD).validate(CONFIRM_TEXT), "Should confirm successfully")
}
func testConfirmDifferent() {
CONFIRM_TXT_FIELD.text = CONFIRM_TEXT
XCTAssertFalse(ConfirmationRule(confirmField: CONFIRM_TXT_FIELD).validate(CONFIRM_TEXT_DIFF), "Should fail confirm")
}
// MARK: Password
func testPassword() {
XCTAssertTrue(PasswordRule().validate(VALID_PASSWORD), "Password should be valid")
}
func testPasswordInvalid(){
XCTAssertFalse(EmailRule().validate(INVALID_PASSWORD), "Password is invalid")
}
// MARK: Max Length
func testMaxLength(){
XCTAssertTrue(MaxLengthRule().validate(LEN_3),"Max Length should be valid")
}
func testMaxLengthInvalid(){
XCTAssertFalse(MaxLengthRule().validate(LEN_20),"Max Length should be invalid")
}
func testMaxLengthParameterAndGreaterThan(){
XCTAssertTrue(MaxLengthRule(length: 20).validate(LEN_20), "Max Length should be 20 and <= length")
}
// MARK: Min Length
func testMinLength(){
XCTAssertTrue(MinLengthRule().validate(LEN_3),"Min Length should be valid")
}
func testMinLengthInvalid(){
XCTAssertFalse(MinLengthRule().validate("no"),"Min Length should be Invalid")
}
func testMinLengthWithParameter(){
XCTAssertTrue(MinLengthRule(length: 5).validate(LEN_5), "Min Len should be set to 5 and >= length")
}
// MARK: Full Name
func testFullName(){
XCTAssertTrue(FullNameRule().validate("Jeff Potter"), "Full Name should be valid")
}
func testFullNameWith3Names(){
XCTAssertTrue(FullNameRule().validate("Jeff Van Buren"), "Full Name should be valid")
}
func testFullNameInvalid(){
XCTAssertFalse(FullNameRule().validate("Carl"), "Full Name should be invalid")
}
// MARK: Register Field
func testRegisterField(){
REGISTER_VALIDATOR.registerField(REGISTER_TXT_FIELD, rules: REGISTER_RULES)
XCTAssert(REGISTER_VALIDATOR.validations[REGISTER_TXT_FIELD] != nil, "Textfield should register")
}
func testUnregisterField(){
UNREGISTER_VALIDATOR.registerField(UNREGISTER_TXT_FIELD, rules: UNREGISTER_RULES)
UNREGISTER_VALIDATOR.unregisterField(UNREGISTER_TXT_FIELD)
XCTAssert(UNREGISTER_VALIDATOR.validations[UNREGISTER_TXT_FIELD] == nil, "Textfield should unregister")
}
func testUnregisterError(){
UNREGISTER_ERRORS_VALIDATOR.registerField(UNREGISTER_ERRORS_TXT_FIELD, rules: [EmailRule()])
UNREGISTER_ERRORS_TXT_FIELD.text = INVALID_EMAIL
UNREGISTER_ERRORS_VALIDATOR.validate { (errors) -> Void in
XCTAssert(errors.count == 1, "Should come back with errors")
}
UNREGISTER_ERRORS_VALIDATOR.unregisterField(UNREGISTER_ERRORS_TXT_FIELD)
UNREGISTER_ERRORS_VALIDATOR.validate { (errors) -> Void in
XCTAssert(errors.count == 0, "Should not come back with errors")
}
}
// MARK: Validate Functions
func testValidateWithCallback() {
REGISTER_VALIDATOR.registerField(REGISTER_TXT_FIELD, rules: [EmailRule()])
REGISTER_TXT_FIELD.text = VALID_EMAIL
REGISTER_VALIDATOR.validate { (errors) -> Void in
XCTAssert(errors.count == 0, "Should not come back with errors")
}
REGISTER_TXT_FIELD.text = INVALID_EMAIL
REGISTER_VALIDATOR.validate { (errors) -> Void in
XCTAssert(errors.count == 1, "Should come back with 1 error")
}
}
// MARK: Validate error field gets it's text set to the error, if supplied
func testNoErrorMessageSet() {
REGISTER_VALIDATOR.registerField(REGISTER_TXT_FIELD, errorLabel: ERROR_LABEL, rules: [EmailRule()])
REGISTER_TXT_FIELD.text = VALID_EMAIL
REGISTER_VALIDATOR.validate { (errors) -> Void in
XCTAssert(errors.count == 0, "Should not come back with errors")
}
}
func testErrorMessageSet() {
REGISTER_VALIDATOR.registerField(REGISTER_TXT_FIELD, errorLabel: ERROR_LABEL, rules: [EmailRule()])
var successCount = 0
var errorCount = 0
REGISTER_VALIDATOR.styleTransformers(success: { (validationRule) -> Void in
successCount++
}) { (validationError) -> Void in
errorCount++
}
REGISTER_TXT_FIELD.text = INVALID_EMAIL
REGISTER_VALIDATOR.validate { (errors) -> Void in
XCTAssert(errors.count == 1, "Should come back with errors")
XCTAssert(errorCount == 1, "Should have called the error style transform once")
XCTAssert(successCount == 0, "Should not have called the success style transform as there are no successful fields")
}
}
func testErrorMessageSetAndThenUnset() {
REGISTER_VALIDATOR.registerField(REGISTER_TXT_FIELD, errorLabel: ERROR_LABEL, rules: [EmailRule()])
var successCount = 0
var errorCount = 0
REGISTER_VALIDATOR.styleTransformers(success: { (validationRule) -> Void in
successCount++
}) { (validationError) -> Void in
errorCount++
}
REGISTER_TXT_FIELD.text = INVALID_EMAIL
REGISTER_VALIDATOR.validate { (errors) -> Void in
XCTAssert(errors.count == 1, "Should come back with errors")
XCTAssert(errorCount == 1, "Should have called the error style transform once")
XCTAssert(successCount == 0, "Should not have called the success style transform as there are no successful fields")
self.REGISTER_TXT_FIELD.text = self.VALID_EMAIL
self.REGISTER_VALIDATOR.validate { (errors) -> Void in
XCTAssert(errors.count == 0, "Should not come back with errors: \(errors)")
XCTAssert(successCount == 1, "Should have called the success style transform once")
XCTAssert(errorCount == 1, "Should not have called the error style transform again")
}
}
}
func testTextFieldBorderColorNotSet() {
REGISTER_VALIDATOR.registerField(REGISTER_TXT_FIELD, errorLabel: ERROR_LABEL, rules: [EmailRule()])
REGISTER_TXT_FIELD.text = INVALID_EMAIL
REGISTER_VALIDATOR.validate { (errors) -> Void in
XCTAssert(errors.count == 1, "Should come back with errors")
XCTAssert(!CGColorEqualToColor(self.REGISTER_TXT_FIELD.layer.borderColor, UIColor.redColor().CGColor), "Color shouldn't get set at all")
}
}
}
|
mit
|
c21b26eb523fbb3a429e8a3182f9fc25
| 35.040293 | 148 | 0.640817 | 4.311569 | false | true | false | false |
apple/swift-format
|
Sources/SwiftFormatRules/TokenSyntax+Convenience.swift
|
1
|
1394
|
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import SwiftSyntax
extension TokenSyntax {
/// Returns this token with only one space at the end of its trailing trivia.
func withOneTrailingSpace() -> TokenSyntax {
return withTrailingTrivia(trailingTrivia.withOneTrailingSpace())
}
/// Returns this token with only one space at the beginning of its leading
/// trivia.
func withOneLeadingSpace() -> TokenSyntax {
return withLeadingTrivia(leadingTrivia.withOneLeadingSpace())
}
/// Returns this token with only one newline at the end of its leading trivia.
func withOneTrailingNewline() -> TokenSyntax {
return withTrailingTrivia(trailingTrivia.withOneTrailingNewline())
}
/// Returns this token with only one newline at the beginning of its leading
/// trivia.
func withOneLeadingNewline() -> TokenSyntax {
return withLeadingTrivia(leadingTrivia.withOneLeadingNewline())
}
}
|
apache-2.0
|
50cc25e7718951fcd809b4ab6a4dd538
| 36.675676 | 80 | 0.662841 | 5.143911 | false | false | false | false |
WhisperSystems/Signal-iOS
|
Signal/src/ViewControllers/ContactViewController.swift
|
1
|
29865
|
//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
import Foundation
import SignalServiceKit
import SignalMessaging
import Reachability
import ContactsUI
import MessageUI
class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
enum ContactViewMode {
case systemContactWithSignal,
systemContactWithoutSignal,
nonSystemContact,
noPhoneNumber,
unknown
}
private var hasLoadedView = false
private var viewMode = ContactViewMode.unknown {
didSet {
AssertIsOnMainThread()
if oldValue != viewMode && hasLoadedView {
updateContent()
}
}
}
private let contactsManager: OWSContactsManager
private var reachability: Reachability?
private let contactShare: ContactShareViewModel
private var contactShareViewHelper: ContactShareViewHelper
private weak var postDismissNavigationController: UINavigationController?
// MARK: - Initializers
@available(*, unavailable, message: "use init(call:) constructor instead.")
required init?(coder aDecoder: NSCoder) {
notImplemented()
}
@objc
required init(contactShare: ContactShareViewModel) {
contactsManager = Environment.shared.contactsManager
self.contactShare = contactShare
self.contactShareViewHelper = ContactShareViewHelper(contactsManager: contactsManager)
super.init(nibName: nil, bundle: nil)
contactShareViewHelper.delegate = self
updateMode()
NotificationCenter.default.addObserver(forName: .OWSContactsManagerSignalAccountsDidChange, object: nil, queue: nil) { [weak self] _ in
guard let strongSelf = self else { return }
strongSelf.updateMode()
}
reachability = Reachability.forInternetConnection()
NotificationCenter.default.addObserver(forName: .reachabilityChanged, object: nil, queue: nil) { [weak self] _ in
guard let strongSelf = self else { return }
strongSelf.updateMode()
}
}
// MARK: - View Lifecycle
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
guard let navigationController = self.navigationController else {
owsFailDebug("navigationController was unexpectedly nil")
return
}
// self.navigationController is nil in viewWillDisappear when transition via message/call buttons
// so we maintain our own reference to restore the navigation bars.
postDismissNavigationController = navigationController
navigationController.isNavigationBarHidden = true
contactsManager.requestSystemContactsOnce(completion: { [weak self] _ in
guard let strongSelf = self else { return }
strongSelf.updateMode()
})
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
if self.presentedViewController == nil {
// No need to do this when we're disappearing due to a modal presentation.
// We'll eventually return to to this view and need to hide again. But also, there is a visible
// animation glitch where the navigation bar for this view controller starts to appear while
// the whole nav stack is about to be obscured by the modal we are presenting.
guard let postDismissNavigationController = self.postDismissNavigationController else {
owsFailDebug("postDismissNavigationController was unexpectedly nil")
return
}
postDismissNavigationController.setNavigationBarHidden(false, animated: animated)
}
}
override func loadView() {
super.loadView()
self.view.preservesSuperviewLayoutMargins = false
self.view.backgroundColor = heroBackgroundColor()
updateContent()
hasLoadedView = true
}
override public var canBecomeFirstResponder: Bool {
return true
}
private func updateMode() {
AssertIsOnMainThread()
guard contactShare.e164PhoneNumbers().count > 0 else {
viewMode = .noPhoneNumber
return
}
if systemContactsWithSignalAccountsForContact().count > 0 {
viewMode = .systemContactWithSignal
return
}
if systemContactsForContact().count > 0 {
viewMode = .systemContactWithoutSignal
return
}
viewMode = .nonSystemContact
}
private func systemContactsWithSignalAccountsForContact() -> [String] {
AssertIsOnMainThread()
return contactShare.systemContactsWithSignalAccountPhoneNumbers(contactsManager)
}
private func systemContactsForContact() -> [String] {
AssertIsOnMainThread()
return contactShare.systemContactPhoneNumbers(contactsManager)
}
private func updateContent() {
AssertIsOnMainThread()
guard let rootView = self.view else {
owsFailDebug("missing root view.")
return
}
for subview in rootView.subviews {
subview.removeFromSuperview()
}
let topView = createTopView()
rootView.addSubview(topView)
topView.autoPin(toTopLayoutGuideOf: self, withInset: 0)
topView.autoPinWidthToSuperview()
// This view provides a background "below the fold".
let bottomView = UIView.container()
bottomView.backgroundColor = Theme.backgroundColor
self.view.addSubview(bottomView)
bottomView.layoutMargins = .zero
bottomView.autoPinWidthToSuperview()
bottomView.autoPinEdge(.top, to: .bottom, of: topView)
bottomView.autoPinEdge(toSuperviewEdge: .bottom)
let scrollView = UIScrollView()
scrollView.preservesSuperviewLayoutMargins = false
self.view.addSubview(scrollView)
scrollView.layoutMargins = .zero
scrollView.autoPinWidthToSuperview()
scrollView.autoPinEdge(.top, to: .bottom, of: topView)
scrollView.autoPinEdge(toSuperviewEdge: .bottom)
let fieldsView = createFieldsView()
scrollView.addSubview(fieldsView)
fieldsView.autoPinLeadingToSuperviewMargin()
fieldsView.autoPinTrailingToSuperviewMargin()
fieldsView.autoPinEdge(toSuperviewEdge: .top)
fieldsView.autoPinEdge(toSuperviewEdge: .bottom)
}
private func heroBackgroundColor() -> UIColor {
return (Theme.isDarkThemeEnabled
? UIColor(rgbHex: 0x272727)
: UIColor(rgbHex: 0xefeff4))
}
private func createTopView() -> UIView {
AssertIsOnMainThread()
let topView = UIView.container()
topView.backgroundColor = heroBackgroundColor()
topView.preservesSuperviewLayoutMargins = false
// Back Button
let backButtonSize = CGFloat(50)
let backButton = TappableView(actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didPressDismiss()
})
backButton.autoSetDimension(.width, toSize: backButtonSize)
backButton.autoSetDimension(.height, toSize: backButtonSize)
topView.addSubview(backButton)
backButton.autoPinEdge(toSuperviewEdge: .top)
backButton.autoPinLeadingToSuperviewMargin()
let backIconName = (CurrentAppContext().isRTL ? "system_disclosure_indicator" : "system_disclosure_indicator_rtl")
guard let backIconImage = UIImage(named: backIconName) else {
owsFailDebug("missing icon.")
return topView
}
let backIconView = UIImageView(image: backIconImage.withRenderingMode(.alwaysTemplate))
backIconView.contentMode = .scaleAspectFit
backIconView.tintColor = Theme.primaryColor.withAlphaComponent(0.6)
backButton.addSubview(backIconView)
backIconView.autoCenterInSuperview()
let avatarSize: CGFloat = 100
let avatarView = AvatarImageView()
avatarView.image = contactShare.getAvatarImage(diameter: avatarSize, contactsManager: contactsManager)
topView.addSubview(avatarView)
avatarView.autoPinEdge(toSuperviewEdge: .top, withInset: 20)
avatarView.autoHCenterInSuperview()
avatarView.autoSetDimension(.width, toSize: avatarSize)
avatarView.autoSetDimension(.height, toSize: avatarSize)
let nameLabel = UILabel()
nameLabel.text = contactShare.displayName
nameLabel.font = UIFont.ows_dynamicTypeTitle1
nameLabel.textColor = Theme.primaryColor
nameLabel.lineBreakMode = .byTruncatingTail
nameLabel.textAlignment = .center
topView.addSubview(nameLabel)
nameLabel.autoPinEdge(.top, to: .bottom, of: avatarView, withOffset: 10)
nameLabel.autoPinLeadingToSuperviewMargin(withInset: hMargin)
nameLabel.autoPinTrailingToSuperviewMargin(withInset: hMargin)
var lastView: UIView = nameLabel
for phoneNumber in systemContactsWithSignalAccountsForContact() {
let phoneNumberLabel = UILabel()
phoneNumberLabel.text = PhoneNumber.bestEffortLocalizedPhoneNumber(withE164: phoneNumber)
phoneNumberLabel.font = UIFont.ows_dynamicTypeFootnote
phoneNumberLabel.textColor = Theme.primaryColor
phoneNumberLabel.lineBreakMode = .byTruncatingTail
phoneNumberLabel.textAlignment = .center
topView.addSubview(phoneNumberLabel)
phoneNumberLabel.autoPinEdge(.top, to: .bottom, of: lastView, withOffset: 5)
phoneNumberLabel.autoPinLeadingToSuperviewMargin(withInset: hMargin)
phoneNumberLabel.autoPinTrailingToSuperviewMargin(withInset: hMargin)
lastView = phoneNumberLabel
}
switch viewMode {
case .systemContactWithSignal:
// Show actions buttons for system contacts with a Signal account.
let stackView = UIStackView()
stackView.axis = .horizontal
stackView.distribution = .fillEqually
stackView.addArrangedSubview(createCircleActionButton(text: NSLocalizedString("ACTION_SEND_MESSAGE",
comment: "Label for 'send message' button in contact view."),
imageName: "contact_view_message",
actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didPressSendMessage()
}))
stackView.addArrangedSubview(createCircleActionButton(text: NSLocalizedString("ACTION_AUDIO_CALL",
comment: "Label for 'audio call' button in contact view."),
imageName: "contact_view_audio_call",
actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didPressAudioCall()
}))
stackView.addArrangedSubview(createCircleActionButton(text: NSLocalizedString("ACTION_VIDEO_CALL",
comment: "Label for 'video call' button in contact view."),
imageName: "contact_view_video_call",
actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didPressVideoCall()
}))
topView.addSubview(stackView)
stackView.autoPinEdge(.top, to: .bottom, of: lastView, withOffset: 20)
stackView.autoPinLeadingToSuperviewMargin(withInset: hMargin)
stackView.autoPinTrailingToSuperviewMargin(withInset: hMargin)
lastView = stackView
case .systemContactWithoutSignal:
// Show invite button for system contacts without a Signal account.
let inviteButton = createLargePillButton(text: NSLocalizedString("ACTION_INVITE",
comment: "Label for 'invite' button in contact view."),
actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didPressInvite()
})
topView.addSubview(inviteButton)
inviteButton.autoPinEdge(.top, to: .bottom, of: lastView, withOffset: 20)
inviteButton.autoPinLeadingToSuperviewMargin(withInset: 55)
inviteButton.autoPinTrailingToSuperviewMargin(withInset: 55)
lastView = inviteButton
case .nonSystemContact:
// Show no action buttons for non-system contacts.
break
case .noPhoneNumber:
// Show no action buttons for contacts without a phone number.
break
case .unknown:
let activityIndicator = UIActivityIndicatorView(style: .whiteLarge)
topView.addSubview(activityIndicator)
activityIndicator.autoPinEdge(.top, to: .bottom, of: lastView, withOffset: 10)
activityIndicator.autoHCenterInSuperview()
lastView = activityIndicator
break
}
// Always show "add to contacts" button.
let addToContactsButton = createLargePillButton(text: NSLocalizedString("CONVERSATION_VIEW_ADD_TO_CONTACTS_OFFER",
comment: "Message shown in conversation view that offers to add an unknown user to your phone's contacts."),
actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didPressAddToContacts()
})
topView.addSubview(addToContactsButton)
addToContactsButton.autoPinEdge(.top, to: .bottom, of: lastView, withOffset: 20)
addToContactsButton.autoPinLeadingToSuperviewMargin(withInset: 55)
addToContactsButton.autoPinTrailingToSuperviewMargin(withInset: 55)
lastView = addToContactsButton
lastView.autoPinEdge(toSuperviewEdge: .bottom, withInset: 15)
return topView
}
private func createFieldsView() -> UIView {
AssertIsOnMainThread()
var rows = [UIView]()
// TODO: Not designed yet.
// if viewMode == .systemContactWithSignal ||
// viewMode == .systemContactWithoutSignal {
// addRow(createActionRow(labelText:NSLocalizedString("ACTION_SHARE_CONTACT",
// comment:"Label for 'share contact' button."),
// action:#selector(didPressShareContact)))
// }
if let organizationName = contactShare.name.organizationName?.ows_stripped() {
if (contactShare.name.hasAnyNamePart() &&
organizationName.count > 0) {
rows.append(ContactFieldView.contactFieldView(forOrganizationName: organizationName,
layoutMargins: UIEdgeInsets(top: 5, left: hMargin, bottom: 5, right: hMargin)))
}
}
for phoneNumber in contactShare.phoneNumbers {
rows.append(ContactFieldView.contactFieldView(forPhoneNumber: phoneNumber,
layoutMargins: UIEdgeInsets(top: 5, left: hMargin, bottom: 5, right: hMargin),
actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didPressPhoneNumber(phoneNumber: phoneNumber)
}))
}
for email in contactShare.emails {
rows.append(ContactFieldView.contactFieldView(forEmail: email,
layoutMargins: UIEdgeInsets(top: 5, left: hMargin, bottom: 5, right: hMargin),
actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didPressEmail(email: email)
}))
}
for address in contactShare.addresses {
rows.append(ContactFieldView.contactFieldView(forAddress: address,
layoutMargins: UIEdgeInsets(top: 5, left: hMargin, bottom: 5, right: hMargin),
actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didPressAddress(address: address)
}))
}
return ContactFieldView(rows: rows, hMargin: hMargin)
}
private let hMargin = CGFloat(16)
private func createActionRow(labelText: String, action: Selector) -> UIView {
let row = UIView()
row.layoutMargins.left = 0
row.layoutMargins.right = 0
row.isUserInteractionEnabled = true
row.addGestureRecognizer(UITapGestureRecognizer(target: self, action: action))
let label = UILabel()
label.text = labelText
label.font = UIFont.ows_dynamicTypeBody
label.textColor = UIColor.ows_materialBlue
label.lineBreakMode = .byTruncatingTail
row.addSubview(label)
label.autoPinTopToSuperviewMargin()
label.autoPinBottomToSuperviewMargin()
label.autoPinLeadingToSuperviewMargin(withInset: hMargin)
label.autoPinTrailingToSuperviewMargin(withInset: hMargin)
return row
}
// TODO: Use real assets.
private func createCircleActionButton(text: String, imageName: String, actionBlock : @escaping () -> Void) -> UIView {
let buttonSize = CGFloat(50)
let button = TappableView(actionBlock: actionBlock)
button.layoutMargins = .zero
button.autoSetDimension(.width, toSize: buttonSize, relation: .greaterThanOrEqual)
let circleView = CircleView(diameter: buttonSize)
circleView.backgroundColor = Theme.backgroundColor
button.addSubview(circleView)
circleView.autoPinEdge(toSuperviewEdge: .top)
circleView.autoHCenterInSuperview()
guard let image = UIImage(named: imageName) else {
owsFailDebug("missing image.")
return button
}
let imageView = UIImageView(image: image.withRenderingMode(.alwaysTemplate))
imageView.tintColor = Theme.primaryColor.withAlphaComponent(0.6)
circleView.addSubview(imageView)
imageView.autoCenterInSuperview()
let label = UILabel()
label.text = text
label.font = UIFont.ows_dynamicTypeCaption2
label.textColor = Theme.primaryColor
label.lineBreakMode = .byTruncatingTail
label.textAlignment = .center
button.addSubview(label)
label.autoPinEdge(.top, to: .bottom, of: circleView, withOffset: 3)
label.autoPinEdge(toSuperviewEdge: .bottom)
label.autoPinLeadingToSuperviewMargin()
label.autoPinTrailingToSuperviewMargin()
return button
}
private func createLargePillButton(text: String, actionBlock : @escaping () -> Void) -> UIView {
let button = TappableView(actionBlock: actionBlock)
button.backgroundColor = Theme.backgroundColor
button.layoutMargins = .zero
button.autoSetDimension(.height, toSize: 45)
button.layer.cornerRadius = 5
let label = UILabel()
label.text = text
label.font = UIFont.ows_dynamicTypeBody
label.textColor = UIColor.ows_materialBlue
label.lineBreakMode = .byTruncatingTail
label.textAlignment = .center
button.addSubview(label)
label.autoPinLeadingToSuperviewMargin(withInset: 20)
label.autoPinTrailingToSuperviewMargin(withInset: 20)
label.autoVCenterInSuperview()
label.autoPinEdge(toSuperviewEdge: .top, withInset: 0, relation: .greaterThanOrEqual)
label.autoPinEdge(toSuperviewEdge: .bottom, withInset: 0, relation: .greaterThanOrEqual)
return button
}
func didPressShareContact(sender: UIGestureRecognizer) {
Logger.info("")
guard sender.state == .recognized else {
return
}
// TODO:
}
func didPressSendMessage() {
Logger.info("")
self.contactShareViewHelper.sendMessage(contactShare: self.contactShare, fromViewController: self)
}
func didPressAudioCall() {
Logger.info("")
self.contactShareViewHelper.audioCall(contactShare: self.contactShare, fromViewController: self)
}
func didPressVideoCall() {
Logger.info("")
self.contactShareViewHelper.videoCall(contactShare: self.contactShare, fromViewController: self)
}
func didPressInvite() {
Logger.info("")
self.contactShareViewHelper.showInviteContact(contactShare: self.contactShare, fromViewController: self)
}
func didPressAddToContacts() {
Logger.info("")
self.contactShareViewHelper.showAddToContacts(contactShare: self.contactShare, fromViewController: self)
}
func didPressDismiss() {
Logger.info("")
guard let navigationController = self.navigationController else {
owsFailDebug("navigationController was unexpectedly nil")
return
}
navigationController.popViewController(animated: true)
}
func didPressPhoneNumber(phoneNumber: OWSContactPhoneNumber) {
Logger.info("")
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
if let e164 = phoneNumber.tryToConvertToE164() {
let address = SignalServiceAddress(phoneNumber: e164)
if contactShare.systemContactsWithSignalAccountPhoneNumbers(contactsManager).contains(e164) {
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("ACTION_SEND_MESSAGE",
comment: "Label for 'send message' button in contact view."),
style: .default) { _ in
SignalApp.shared().presentConversation(for: address, action: .compose, animated: true)
})
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("ACTION_AUDIO_CALL",
comment: "Label for 'audio call' button in contact view."),
style: .default) { _ in
SignalApp.shared().presentConversation(for: address, action: .audioCall, animated: true)
})
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("ACTION_VIDEO_CALL",
comment: "Label for 'video call' button in contact view."),
style: .default) { _ in
SignalApp.shared().presentConversation(for: address, action: .videoCall, animated: true)
})
} else {
// TODO: We could offer callPhoneNumberWithSystemCall.
}
}
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("EDIT_ITEM_COPY_ACTION",
comment: "Short name for edit menu item to copy contents of media message."),
style: .default) { _ in
UIPasteboard.general.string = phoneNumber.phoneNumber
})
actionSheet.addAction(OWSAlerts.cancelAction)
presentAlert(actionSheet)
}
func callPhoneNumberWithSystemCall(phoneNumber: OWSContactPhoneNumber) {
Logger.info("")
guard let url = NSURL(string: "tel:\(phoneNumber.phoneNumber)") else {
owsFailDebug("could not open phone number.")
return
}
UIApplication.shared.openURL(url as URL)
}
func didPressEmail(email: OWSContactEmail) {
Logger.info("")
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("CONTACT_VIEW_OPEN_EMAIL_IN_EMAIL_APP",
comment: "Label for 'open email in email app' button in contact view."),
style: .default) { [weak self] _ in
self?.openEmailInEmailApp(email: email)
})
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("EDIT_ITEM_COPY_ACTION",
comment: "Short name for edit menu item to copy contents of media message."),
style: .default) { _ in
UIPasteboard.general.string = email.email
})
actionSheet.addAction(OWSAlerts.cancelAction)
presentAlert(actionSheet)
}
func openEmailInEmailApp(email: OWSContactEmail) {
Logger.info("")
guard let url = NSURL(string: "mailto:\(email.email)") else {
owsFailDebug("could not open email.")
return
}
UIApplication.shared.openURL(url as URL)
}
func didPressAddress(address: OWSContactAddress) {
Logger.info("")
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("CONTACT_VIEW_OPEN_ADDRESS_IN_MAPS_APP",
comment: "Label for 'open address in maps app' button in contact view."),
style: .default) { [weak self] _ in
self?.openAddressInMaps(address: address)
})
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("EDIT_ITEM_COPY_ACTION",
comment: "Short name for edit menu item to copy contents of media message."),
style: .default) { [weak self] _ in
guard let strongSelf = self else { return }
UIPasteboard.general.string = strongSelf.formatAddressForQuery(address: address)
})
actionSheet.addAction(OWSAlerts.cancelAction)
presentAlert(actionSheet)
}
func openAddressInMaps(address: OWSContactAddress) {
Logger.info("")
let mapAddress = formatAddressForQuery(address: address)
guard let escapedMapAddress = mapAddress.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
owsFailDebug("could not open address.")
return
}
// Note that we use "q" (i.e. query) rather than "address" since we can't assume
// this is a well-formed address.
guard let url = URL(string: "http://maps.apple.com/?q=\(escapedMapAddress)") else {
owsFailDebug("could not open address.")
return
}
UIApplication.shared.openURL(url as URL)
}
func formatAddressForQuery(address: OWSContactAddress) -> String {
Logger.info("")
// Open address in Apple Maps app.
var addressParts = [String]()
let addAddressPart: ((String?) -> Void) = { (part) in
guard let part = part else {
return
}
guard part.count > 0 else {
return
}
addressParts.append(part)
}
addAddressPart(address.street)
addAddressPart(address.neighborhood)
addAddressPart(address.city)
addAddressPart(address.region)
addAddressPart(address.postcode)
addAddressPart(address.country)
return addressParts.joined(separator: ", ")
}
// MARK: - ContactShareViewHelperDelegate
public func didCreateOrEditContact() {
Logger.info("")
updateContent()
self.dismiss(animated: true)
}
}
|
gpl-3.0
|
1f16929b47485fb23562a122ebf8befa
| 42.854626 | 188 | 0.588783 | 5.912691 | false | false | false | false |
nataliq/TripCheckins
|
TripCheckins/Trip list/TripViewModel.swift
|
1
|
940
|
//
// TripViewModel.swift
// TripCheckins
//
// Created by Nataliya on 8/27/17.
// Copyright © 2017 Nataliya Patsovska. All rights reserved.
//
import Foundation
struct TripViewModel {
let title: String
let durationString: String
init(trip: Trip) {
self.title = trip.name
var durationString = "All checkins"
if let startDate = trip.startDate, let endDate = trip.endDate {
durationString = "\(DateFormatter.tripDateFormatter.string(from: startDate)) - \(DateFormatter.tripDateFormatter.string(from: endDate))"
} else if let startDate = trip.startDate {
durationString = "After \(DateFormatter.tripDateFormatter.string(from: startDate))"
} else if let endDate = trip.endDate {
durationString = "Before \(DateFormatter.tripDateFormatter.string(from: endDate))"
}
self.durationString = durationString
}
}
|
mit
|
4c9153b25287c17db7b80a85dddaaaee
| 31.37931 | 148 | 0.652822 | 4.536232 | false | false | false | false |
FTChinese/iPhoneApp
|
FT Academy/SpeechDefaultVoice.swift
|
1
|
1207
|
//
// SpeechDefaultVoice.swift
// FT中文网
//
// Created by Oliver Zhang on 2017/4/7.
// Copyright © 2017年 Financial Times Ltd. All rights reserved.
//
import Foundation
struct SpeechDefaultVoice {
public let englishVoiceKey = "English Voice"
public let chineseVoiceKey = "Chinese Voice"
public func getVoiceByLanguage(_ language: String) -> String {
var englishDefaultVoice = "en-GB"
var chineseDefaultChoice = "zh-CN"
if let region = Locale.current.regionCode {
switch region {
case "US": englishDefaultVoice = "en-US"
case "AU": englishDefaultVoice = "en-AU"
case "ZA": englishDefaultVoice = "en-ZA"
case "IE": englishDefaultVoice = "en-IE"
case "TW": chineseDefaultChoice = "zh-TW"
case "HK": chineseDefaultChoice = "zh-HK"
default:
break
}
}
switch language {
case "en":
return UserDefaults.standard.string(forKey: englishVoiceKey) ?? englishDefaultVoice
default:
return UserDefaults.standard.string(forKey: chineseVoiceKey) ?? chineseDefaultChoice
}
}
}
|
mit
|
5e07668c58e64f53cc8090c8416db253
| 29.717949 | 96 | 0.603506 | 4.21831 | false | false | false | false |
admkopec/BetaOS
|
Kernel/Modules/Filesystems/FAT.swift
|
1
|
16400
|
//
// FAT.swift
// Kernel
//
// Created by Adam Kopeć on 12/31/17.
// Copyright © 2017-2018 Adam Kopeć. All rights reserved.
//
import CustomArrays
class FATHeader {
let BootJMP: (UInt8, UInt8, UInt8)
var OemName = ""
let BytesPerSector: UInt16
let SectorsPerCluster: UInt8
let ReservedSectorCount: UInt16
var NumberOfAllocationTables: UInt8
let RootEntryCount: UInt16
let MediaType: UInt8
fileprivate let TableSize16: UInt16
let SectorsPerTrack: UInt16
let HeadOrSideCount: UInt16
let HiddenSectorCount: UInt32
let TotalSectors: Int
init(data: MutableData) {
BootJMP = (data[0], data[1], data[2])
var i = 3
while i < 11 {
OemName.append(String(UnicodeScalar(data[i])))
i += 1
}
BytesPerSector = ByteArray(withBytes: data[11], data[12]).asUInt16
SectorsPerCluster = data[13]
ReservedSectorCount = ByteArray(withBytes: data[14], data[15]).asUInt16
NumberOfAllocationTables = data[16]
RootEntryCount = ByteArray(withBytes: data[17], data[18]).asUInt16
let TotalSectors16 = ByteArray(withBytes: data[19], data[20]).asInt
MediaType = data[21]
TableSize16 = ByteArray(withBytes: data[22], data[23]).asUInt16
SectorsPerTrack = ByteArray(withBytes: data[24], data[25]).asUInt16
HeadOrSideCount = ByteArray(withBytes: data[26], data[27]).asUInt16
HiddenSectorCount = ByteArray(withBytes: data[28], data[29], data[30], data[31]).asUInt32
let TotalSectors32 = ByteArray(withBytes: data[32], data[33], data[34], data[35]).asInt
if TotalSectors16 == 0 {
TotalSectors = TotalSectors32
} else {
TotalSectors = TotalSectors16
}
}
}
final class FAT16Header: FATHeader { // and also FAT12
fileprivate(set) var TableSize = 0
let BiosDriveNumber: UInt8
let BootSignature: UInt8
let VolumeID: UInt32
var VolumeLabel = ""
var FATTypeLabel = ""
override init(data: MutableData) {
BiosDriveNumber = data[36]
BootSignature = data[38]
VolumeID = ByteArray(withBytes: data[39], data[40], data[41], data[42]).asUInt32
var i = 43
while i < 54 {
VolumeLabel.append(String(UnicodeScalar(data[i])))
i += 1
}
VolumeLabel = VolumeLabel.trim()
i = 54
while i < 62 {
FATTypeLabel.append(String(UnicodeScalar(data[i])))
i += 1
}
FATTypeLabel = FATTypeLabel.trim()
super.init(data: data)
TableSize = Int(TableSize16)
}
}
final class FAT32Header: FATHeader {
fileprivate(set) var TableSize = 0
let ExtendedFlags: UInt16
let FATVersion: (Major: UInt8, Minor: UInt8)
let RootCluster: UInt32
let FATInfoLcation: UInt16
let BackupBootSector: UInt16
let DriveNumber: UInt8
let BootSignature: UInt8
let VolumeID: UInt32
var VolumeLabel = ""
var FATTypeLabel = ""
override init(data: MutableData) {
let TableSize32 = ByteArray(withBytes: data[36], data[37], data[38], data[39]).asInt
ExtendedFlags = ByteArray(withBytes: data[40], data[41]).asUInt16
FATVersion = (Major: data[42], Minor: data[43])
RootCluster = ByteArray(withBytes: data[44], data[45], data[46], data[47]).asUInt32
FATInfoLcation = ByteArray(withBytes: data[48], data[49]).asUInt16
BackupBootSector = ByteArray(withBytes: data[50], data[51]).asUInt16
DriveNumber = data[64]
BootSignature = data[66]
VolumeID = ByteArray(withBytes: data[67], data[68], data[69], data[70]).asUInt32
var i = 71
while i < 82 {
VolumeLabel.append(String(UnicodeScalar(data[i])))
i += 1
}
VolumeLabel = VolumeLabel.trim()
i = 82
while i < 90 {
FATTypeLabel.append(String(UnicodeScalar(data[i])))
i += 1
}
FATTypeLabel = FATTypeLabel.trim()
super.init(data: data)
if TableSize16 == 0 {
TableSize = TableSize32
} else {
TableSize = Int(TableSize16)
}
}
}
struct DirectoryEntry {
let Offset: Int
var Name: String
var Extension: String
var Flags: UInt8
var CreationTime: UInt8
var TimeOfCreation: UInt16//Date
var TimeOfModification: UInt16//Date
var Size: Int
var FirstCluster: UInt32
init?(data: MutableData, offset: Int) {
Offset = offset
Name = ""
Extension = ""
if data[11] == 0xF {
// Long File Name
return nil
}
var i = 0
while i < 8 {
guard data[i] <= 170 && data[i] >= 0x20 else {
return nil
}
Name.append(String(UnicodeScalar(data[i])))
i += 1
}
Name = Name.trim()
if Name == " " {
Name = ""
}
i = 8
while i < 11 {
Extension.append(String(UnicodeScalar(data[i])))
i += 1
}
Extension = Extension.trim()
if Extension == " " {
Extension = ""
}
Flags = data[11]
CreationTime = data[13]
var timeBits = BitArray(ByteArray(withBytes: data[14], data[15]).asUInt16)
TimeOfCreation = timeBits.asUInt16
timeBits = BitArray(ByteArray(withBytes: data[16], data[17]).asUInt16)
TimeOfModification = timeBits.asUInt16
Size = ByteArray([data[28], data[29], data[30], data[31]]).asInt
FirstCluster = ByteArray([data[20], data[21]]).asUInt32 << 32 + ByteArray([data[26], data[27]]).asUInt32
}
var computed: [UInt8] {
var buffer = [UInt8](repeating: 0, count: 32)
var bytes = ByteArray([UInt8](Name.utf8))
var i = 0
for byte in bytes {
buffer[i] = byte
i += 1
}
if i < 8 {
for j in i ... 7 {
buffer[j] = 0x20
}
}
i = 8
bytes = ByteArray([UInt8](Extension.utf8))
for byte in bytes {
buffer[i] = byte
i += 1
}
if i < 11 {
for j in i ... 10 {
buffer[j] = 0x20
}
}
buffer[11] = Flags
buffer[13] = CreationTime
i = 28
bytes = ByteArray(UInt32(Size))
for byte in bytes {
buffer[i] = byte
i += 1
}
bytes = ByteArray(FirstCluster)
buffer[20] = bytes[2]
buffer[21] = bytes[3]
buffer[26] = bytes[0]
buffer[27] = bytes[1]
return buffer
}
}
class FAT12: Partition {
let Header: FAT16Header
let VolumeName: String
let AlternateName: String
var CaseSensitive: Bool { return false }
fileprivate let DiskDevice: Disk
fileprivate let FirstLBA: UInt64
fileprivate let FirstUsableCluster: Int
fileprivate let SectorsPerCluster: Int
fileprivate let RootCluster: UInt32
init?(partitionEntry: GPTPartitionEntry, onDisk disk: Disk) {
DiskDevice = disk
RootCluster = 2
FirstLBA = UInt64(partitionEntry.FirstLBA)
Header = FAT16Header(data: disk.read(lba: FirstLBA))
guard Header.FATTypeLabel == "FAT12" else {
return nil
}
if partitionEntry.Name.count < 1 {
VolumeName = Header.VolumeLabel
} else {
VolumeName = partitionEntry.Name
}
AlternateName = Header.VolumeLabel
FirstUsableCluster = partitionEntry.FirstLBA + Int(Header.ReservedSectorCount) + (Int(Header.NumberOfAllocationTables) * Int(Header.TableSize))
SectorsPerCluster = Int(Header.SectorsPerCluster)
guard Header.BytesPerSector == 512 else {
kprint("Sector sizes do not match! Can't support it yet")
return nil
}
}
func ReadDirectory(fromCluster: UInt32) -> [DirectoryEntry] {
return [DirectoryEntry]()
}
func WriteDirectory(fromCluster: UInt32, entries: [DirectoryEntry]) {
//
}
func ReadFile(fromCluster: UInt32) -> MutableData? {
return nil
}
func WriteFile(fromCluster: UInt32, file: MutableData) {
//
}
}
class FAT16: Partition {
let Header: FAT16Header
let VolumeName: String
let AlternateName: String
var CaseSensitive: Bool { return false }
fileprivate let DiskDevice: Disk
fileprivate let FirstLBA: UInt64
fileprivate let FirstUsableCluster: Int
fileprivate let SectorsPerCluster: Int
fileprivate let RootCluster: UInt32
init?(partitionEntry: GPTPartitionEntry, onDisk disk: Disk) {
DiskDevice = disk
RootCluster = 2
FirstLBA = UInt64(partitionEntry.FirstLBA)
Header = FAT16Header(data: disk.read(lba: FirstLBA))
guard Header.FATTypeLabel == "FAT16" else {
return nil
}
if partitionEntry.Name.count < 1 {
VolumeName = Header.VolumeLabel
} else {
VolumeName = partitionEntry.Name
}
AlternateName = Header.VolumeLabel
FirstUsableCluster = partitionEntry.FirstLBA + Int(Header.ReservedSectorCount) + (Int(Header.NumberOfAllocationTables) * Int(Header.TableSize))
SectorsPerCluster = Int(Header.SectorsPerCluster)
guard Header.BytesPerSector == 512 else {
kprint("Sector sizes do not match! Can't support it yet")
return nil
}
}
func ReadDirectory(fromCluster: UInt32) -> [DirectoryEntry] {
return [DirectoryEntry]()
}
func WriteDirectory(fromCluster: UInt32, entries: [DirectoryEntry]) {
//
}
func ReadFile(fromCluster: UInt32) -> MutableData? {
return nil
}
func WriteFile(fromCluster: UInt32, file: MutableData) {
//
}
}
class FAT32: Partition {
let Header: FAT32Header
let VolumeName: String
let AlternateName: String
var CaseSensitive: Bool { return false }
fileprivate let DiskDevice: Disk
fileprivate let FirstLBA: UInt64
fileprivate let LastLBA: UInt64
fileprivate let FirstUsableCluster: Int
fileprivate let SectorsPerCluster: Int
init?(partitionEntry: GPTPartitionEntry, onDisk disk: Disk) {
DiskDevice = disk
FirstLBA = UInt64(partitionEntry.FirstLBA)
LastLBA = UInt64(partitionEntry.LastLBA)
Header = FAT32Header(data: disk.read(lba: FirstLBA))
guard Header.FATTypeLabel == "FAT32" else {
return nil
}
if partitionEntry.Name.count < 1 {
VolumeName = Header.VolumeLabel
} else {
VolumeName = partitionEntry.Name
}
AlternateName = Header.VolumeLabel
FirstUsableCluster = partitionEntry.FirstLBA + Int(Header.ReservedSectorCount) + (Int(Header.NumberOfAllocationTables) * (Header.TableSize))
SectorsPerCluster = Int(Header.SectorsPerCluster)
guard Header.BytesPerSector == 512 else {
kprint("Sector sizes do not match! Can't support that yet")
return nil
}
}
func ReadDirectory(fromCluster: UInt32) -> [DirectoryEntry] {
var Cluster = fromCluster
if Cluster == 0 {
Cluster = Header.RootCluster
}
let clusters = GetClusterChain(firstCluster: Cluster)
var directoryEntries = [DirectoryEntry]()
var j = 0
for cluster in clusters {
var i = 0
let buf = DiskDevice.read(lba: GetLBA(fromCluster: cluster), count: SectorsPerCluster)
while i < 512 {
let buffer = UnsafeMutableBufferPointer<UInt8>(start: buf.baseAddress!.advanced(by: i), count: 32)
if let dirEntry = DirectoryEntry(data: buffer, offset: i + j) {
directoryEntries.append(dirEntry)
}
i += 32
}
j += 512
}
return directoryEntries
}
func WriteDirectory(fromCluster: UInt32, entries: [DirectoryEntry]) {
var Cluster = fromCluster
if Cluster == 0 {
Cluster = Header.RootCluster
}
let clusters = GetClusterChain(firstCluster: Cluster)
var j = 0
for cluster in clusters {
var i = 0
let buf = DiskDevice.read(lba: GetLBA(fromCluster: cluster), count: SectorsPerCluster)
while i < 512 {
for entry in entries {
if entry.Offset == i + j {
let entryComputed = entry.computed
for k in 0 ... 31 {
buf[i + k] = entryComputed[k]
}
}
}
i += 32
}
DiskDevice.write(lba: GetLBA(fromCluster: cluster), count: SectorsPerCluster, buffer: buf.baseAddress!)
j += 512
}
}
func ReadFile(fromCluster: UInt32) -> UnsafeMutableBufferPointer<UInt8>? {
guard fromCluster != 0 else {
kprint("It's a directory!")
return nil
}
let clusters = GetClusterChain(firstCluster: fromCluster)
let count = clusters.count * 512
let File = UnsafeMutableBufferPointer<UInt8>(start: UnsafeMutablePointer<UInt8>.allocate(capacity: count), count: count)
for (i, cluster) in clusters.enumerated() {
_ = DiskDevice.read(lba: GetLBA(fromCluster: cluster), count: SectorsPerCluster, buffer: UnsafeMutableBufferPointer<UInt8>(start: File.baseAddress!.advanced(by: i * 512 * SectorsPerCluster), count: 512 * SectorsPerCluster))
}
return File
}
func WriteFile(fromCluster: UInt32, file: UnsafeMutableBufferPointer<UInt8>) {
guard fromCluster >= 2 else {
kprint("It's a directory!")
return
}
let clusters = GetClusterChain(firstCluster: fromCluster)
var i = 0
for cluster in clusters {
if i >= file.count {
let buf = UnsafeMutableBufferPointer<UInt8>(start: UnsafeMutablePointer<UInt8>.allocate(capacity: 512), count: 512)
DiskDevice.write(lba: GetLBA(fromCluster: cluster), count: SectorsPerCluster, buffer: buf.baseAddress!)
buf.deallocate()
continue
}
DiskDevice.write(lba: GetLBA(fromCluster: cluster), count: SectorsPerCluster, buffer: file.baseAddress!.advanced(by: i))
i += 512
}
}
fileprivate func GetLBA(fromCluster cluster: UInt32) -> UInt64 {
return UInt64(Int64(FirstUsableCluster) + (Int64(cluster) - 2) * Int64(SectorsPerCluster))
}
fileprivate func GetClusterChain(firstCluster: UInt32) -> [UInt32] {
var cluster = firstCluster
var chain = 1 as UInt32
var array = [UInt32]()
while (chain != 0) && (chain & 0x0FFFFFFF) < 0x0FFFFFF8 {
let FATSector = FirstLBA + UInt64(Header.ReservedSectorCount) + (UInt64(cluster * 4) / 512)
let FATOffset = Int((cluster * 4) % 512) / 4
let buffer = UnsafeBufferPointer<UInt32>(start: UnsafeMutablePointer<UInt32>(bitPattern: UInt(bitPattern: DiskDevice.read(lba: FATSector).baseAddress)), count: 128)
chain = buffer[FATOffset] & 0x0FFFFFFF
if cluster <= LastLBA {
array.append(cluster)
}
cluster = chain
}
return array
}
fileprivate func RemoveClusterChain(firstCluster: UInt32) {
var cluster = firstCluster
var chain = 1 as UInt32
while (chain != 0) && (chain & 0x0FFFFFFF) < 0x0FFFFFF8 {
let FATSector = FirstLBA + UInt64(Header.ReservedSectorCount) + (UInt64(cluster * 4) / 512)
let FATOffset = Int(cluster % 512)
let buffer = UnsafeMutableBufferPointer<UInt32>(start: UnsafeMutablePointer<UInt32>(bitPattern: UInt(bitPattern: DiskDevice.read(lba: FATSector).baseAddress)) , count: 128)
chain = buffer[FATOffset] & 0x0FFFFFFF
buffer[FATOffset] = 0
cluster = chain
}
}
}
|
apache-2.0
|
6a9c16747857b385b77ae02b334775f5
| 33.739407 | 235 | 0.584863 | 4.132308 | false | false | false | false |
hari-tw/QXCameraKit
|
QXCameraKit/HttpAsynchronousRequest.swift
|
2
|
2067
|
import Foundation
class HttpAsynchronousRequest:NSObject {
var apiName:NSString
var receiveData:NSMutableData
var closure:APIResponseClosure
var url:NSString
var params:NSString
init(url:NSString, postParams params:NSString, apiName name:NSString, closure:APIResponseClosure) {
self.receiveData = NSMutableData()
self.url = url
self.params = params
self.apiName = name
self.closure = closure
}
func execute(){
var url = NSURL(string:self.url)
var request = NSMutableURLRequest(URL:url!, cachePolicy:NSURLRequestCachePolicy.UseProtocolCachePolicy, timeoutInterval:10.0)
request.HTTPMethod = "POST"
request.HTTPBody = self.params.dataUsingEncoding(NSUTF8StringEncoding)
var connection = NSURLConnection(request:request, delegate:self, startImmediately:false)
connection!.start()
}
func connection(connection:NSURLConnection, didReceiveResponse response:NSURLResponse) {
self.receiveData.length = 0
}
func connection(connection:NSURLConnection, didReceiveData data:NSData) {
self.receiveData.appendData(data)
}
func connection(connection: NSURLConnection, didFailWithError error: NSError) {
NSLog("HttpRequest didFailWithError = %@", error)
var errorResponse = "{ \"id\"= 0 , \"error\"=[16,\"Transport Error\"]}"
var data = errorResponse.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
var e:NSError?
var dict = NSJSONSerialization.JSONObjectWithData(data!, options:NSJSONReadingOptions.MutableContainers, error:&e) as NSDictionary
self.closure(json:dict, isSucceeded:false)
}
func connectionDidFinishLoading(connection: NSURLConnection) {
var e:NSError?
var dict = NSJSONSerialization.JSONObjectWithData(self.receiveData, options:NSJSONReadingOptions.MutableContainers, error: &e) as NSDictionary
self.closure(json:dict, isSucceeded:true)
}
}
|
mit
|
3f4086cbe5a2ff0f63b1c040c343106f
| 35.280702 | 150 | 0.697146 | 5.193467 | false | false | false | false |
Daniel-Lopez/DraggableButtonView-Swift
|
src/DraggableButtonView.swift
|
2
|
5146
|
//
// DraggableButtonView.swift
// DraggableButtonViewDemo
//
// Created by Lopez, Daniel on 6/9/16.
// Copyright © 2016 Lopez, Daniel. All rights reserved.
//
import UIKit
class DraggableButtonView: UIView, UIGestureRecognizerDelegate
{
fileprivate let DEFAULT_BG_COLOR: CGColor = UIColor.black.cgColor
fileprivate let DEFAULT_BG_OPACITY: Float = 0.4
fileprivate let DEFAULT_STROKE_COLOR: CGColor = UIColor.clear.cgColor
fileprivate let DEFAULT_STROKE_WIDTH: CGFloat = 2.0
fileprivate var canDrag = false
fileprivate var scaleFactor: CGFloat = 6.0
fileprivate var initialPoint = CGPoint.zero
fileprivate let circleLayer = CAShapeLayer()
weak var delegate: DraggableButtonViewDelegate?
weak var dataSource: DraggableButtonViewDataSource?
{
didSet
{
// Need to check that dataSource was not set to nil
guard let ds = dataSource else { return }
scaleFactor = ds.scaleFactor
}
}
override init(frame: CGRect)
{
super.init(frame: frame)
let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(panDetected))
let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(longPressDetected))
panRecognizer.delegate = self
longPressRecognizer.delegate = self
self.addGestureRecognizer(panRecognizer)
self.addGestureRecognizer(longPressRecognizer)
backgroundColor = .clear
}
required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool
{
return true
}
@objc fileprivate func panDetected(_ gesture: UIPanGestureRecognizer)
{
guard canDrag else { return }
let translation = gesture.translation(in: self.superview)
self.center = CGPoint(x: initialPoint.x + translation.x, y: initialPoint.y + translation.y)
}
@objc fileprivate func longPressDetected(_ gesture: UILongPressGestureRecognizer)
{
if gesture.state == .began
{
canDrag = true
circleLayer.transform = CATransform3DMakeScale(scaleFactor, scaleFactor, 1)
}
else if gesture.state == .ended
{
canDrag = false
circleLayer.transform = CATransform3DMakeScale(1.0, 1.0, 1)
}
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
{
if let sup = self.superview
{
sup.bringSubview(toFront: self)
initialPoint = self.center
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?)
{
guard let del = delegate else { return }
if let touch = touches.first
{
let touchPoint = touch.location(in: self.superview)
del.draggableViewTapped(at: touchPoint)
}
}
fileprivate func drawCircle(_ rect: CGRect)
{
let circlePath = UIBezierPath(roundedRect: rect, cornerRadius: rect.width / 2)
circleLayer.path = circlePath.cgPath
if let ds = dataSource
{
circleLayer.fillColor = ds.bgColor.cgColor
circleLayer.opacity = ds.bgOpacity
circleLayer.strokeColor = ds.strokeColor.cgColor
circleLayer.lineWidth = CGFloat(ds.strokeWidth)
if let image = ds.bgImage
{
let imageLayer = CALayer()
imageLayer.contents = image.cgImage
imageLayer.bounds = CGRect(x: 0, y: 0, width: rect.width / 2, height: rect.height / 2)
imageLayer.position = CGPoint(x: rect.width / 2, y: rect.width / 2)
circleLayer.addSublayer(imageLayer)
}
}
else
{
circleLayer.fillColor = DEFAULT_BG_COLOR
circleLayer.opacity = DEFAULT_BG_OPACITY
}
circleLayer.bounds = rect
circleLayer.position = CGPoint(x: rect.midX,y: rect.midY)
circleLayer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
layer.addSublayer(circleLayer)
}
override func draw(_ rect: CGRect)
{
drawCircle(rect)
}
}
// MARK: - DraggableButtonViewDelegate
protocol DraggableButtonViewDelegate: class
{
// Passes the touch point in the button's super view
func draggableViewTapped(at point: CGPoint)
}
// MARK: - DraggableButtonViewDataSource
protocol DraggableButtonViewDataSource: class
{
var bgColor: UIColor { get } // background color
var bgOpacity: Float { get } // background opacity
var strokeColor: UIColor { get } // stroke color
var strokeWidth: CGFloat { get } // stroke(line) width
var scaleFactor: CGFloat { get } // scale factor on long press
var bgImage: UIImage? { get } // background image
}
|
mit
|
6b7c695d92291221bb43ef989662b0d3
| 30.759259 | 155 | 0.62449 | 4.947115 | false | false | false | false |
mspvirajpatel/SwiftyBase
|
SwiftyBase/Classes/Controller/BaseVerticalScrollViewController.swift
|
1
|
4339
|
//
// BaseVerstical.swift
// Pods
//
// Created by MacMini-2 on 14/09/17.
//
//
import Foundation
import UIKit
public class BaseVerticalScrollViewController: UIViewController, ContainerViewControllerDelegate {
public var topVc: UIViewController!
public var middleVc: UIViewController!
public var bottomVc: UIViewController!
public var scrollView: UIScrollView!
public class func verticalScrollVcWith(middleVc: UIViewController,
topVc: UIViewController? = nil,
bottomVc: UIViewController? = nil) -> BaseVerticalScrollViewController {
let middleScrollVc = BaseVerticalScrollViewController()
middleScrollVc.topVc = topVc
middleScrollVc.middleVc = middleVc
middleScrollVc.bottomVc = bottomVc
return middleScrollVc
}
override public func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view:
setupScrollView()
}
func setupScrollView() {
scrollView = UIScrollView()
scrollView.isPagingEnabled = true
scrollView.showsVerticalScrollIndicator = false
scrollView.bounces = false
let view = (
x: self.view.bounds.origin.x,
y: self.view.bounds.origin.y,
width: self.view.bounds.width,
height: self.view.bounds.height
)
scrollView.frame = CGRect(x: view.x, y: view.y, width: view.width, height: view.height)
self.view.addSubview(scrollView)
let scrollWidth: CGFloat = view.width
var scrollHeight: CGFloat
switch (topVc, bottomVc) {
case (nil, nil):
scrollHeight = view.height
middleVc.view.frame = CGRect(x: 0, y: 0, width: view.width, height: view.height)
addChild(middleVc)
scrollView.addSubview(middleVc.view)
middleVc.didMove(toParent: self)
case (_?, nil):
scrollHeight = 2 * view.height
topVc.view.frame = CGRect(x: 0, y: 0, width: view.width, height: view.height)
middleVc.view.frame = CGRect(x: 0, y: view.height, width: view.width, height: view.height)
addChild(topVc)
addChild(middleVc)
scrollView.addSubview(topVc.view)
scrollView.addSubview(middleVc.view)
topVc.didMove(toParent: self)
middleVc.didMove(toParent: self)
scrollView.contentOffset.y = middleVc.view.frame.origin.y
case (nil, _?):
scrollHeight = 2 * view.height
middleVc.view.frame = CGRect(x: 0, y: 0, width: view.width, height: view.height)
bottomVc.view.frame = CGRect(x: 0, y: view.height, width: view.width, height: view.height)
addChild(middleVc)
addChild(bottomVc)
scrollView.addSubview(middleVc.view)
scrollView.addSubview(bottomVc.view)
middleVc.didMove(toParent: self)
bottomVc.didMove(toParent: self)
scrollView.contentOffset.y = 0
default:
scrollHeight = 3 * view.height
topVc.view.frame = CGRect(x: 0, y: 0, width: view.width, height: view.height)
middleVc.view.frame = CGRect(x: 0, y: view.height, width: view.width, height: view.height)
bottomVc.view.frame = CGRect(x: 0, y: 2 * view.height, width: view.width, height: view.height)
addChild(topVc)
addChild(middleVc)
addChild(bottomVc)
scrollView.addSubview(topVc.view)
scrollView.addSubview(middleVc.view)
scrollView.addSubview(bottomVc.view)
topVc.didMove(toParent: self)
middleVc.didMove(toParent: self)
bottomVc.didMove(toParent: self)
scrollView.contentOffset.y = middleVc.view.frame.origin.y
}
scrollView.contentSize = CGSize(width: scrollWidth, height: scrollHeight)
}
// MARK: - ContainerViewControllerDelegate Methods
public func outerScrollViewShouldScroll() -> Bool {
if scrollView.contentOffset.y < middleVc.view.frame.origin.y || scrollView.contentOffset.y > 2 * middleVc.view.frame.origin.y {
return false
} else {
return true
}
}
}
|
mit
|
7d565086a8cedc9b8f6f0e27fb0d1d17
| 33.165354 | 135 | 0.613736 | 4.352056 | false | false | false | false |
kesun421/firefox-ios
|
Client/Frontend/Settings/NewTabContentSettingsViewController.swift
|
1
|
2714
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import Foundation
import Shared
class CurrentTabSetting: Setting {
let profile: Profile
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var style: UITableViewCellStyle { return .value1 }
override var accessibilityIdentifier: String? { return "NewTabOption" }
init(profile: Profile) {
self.profile = profile
super.init(title: NSAttributedString(string: NewTabAccessors.getNewTabPage(profile.prefs).settingTitle, attributes: [NSForegroundColorAttributeName: UIConstants.TableViewRowTextColor]))
}
override func onClick(_ navigationController: UINavigationController?) {
let viewController = NewTabChoiceViewController(prefs: profile.prefs)
navigationController?.pushViewController(viewController, animated: true)
}
}
class NewTabContentSettingsViewController: SettingsTableViewController {
init() {
super.init(style: .grouped)
self.title = Strings.SettingsNewTabTitle
hasSectionSeparatorLine = false
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func generateSettings() -> [SettingSection] {
let tabSetting = CurrentTabSetting(profile: profile)
let firstSection = SettingSection(title: NSAttributedString(string: Strings.SettingsNewTabSectionName), footerTitle: nil, children: [tabSetting])
let isPocketEnabledDefault = Pocket.IslocaleSupported(Locale.current.identifier)
let pocketSetting = BoolSetting(prefs: profile.prefs, prefKey: PrefsKeys.ASPocketStoriesVisible, defaultValue: isPocketEnabledDefault, attributedTitleText: NSAttributedString(string: Strings.SettingsNewTabPocket))
let bookmarks = BoolSetting(prefs: profile.prefs, prefKey: PrefsKeys.ASBookmarkHighlightsVisible, defaultValue: true, attributedTitleText: NSAttributedString(string: Strings.SettingsNewTabHighlightsBookmarks))
let history = BoolSetting(prefs: profile.prefs, prefKey: PrefsKeys.ASRecentHighlightsVisible, defaultValue: true, attributedTitleText: NSAttributedString(string: Strings.SettingsNewTabHiglightsHistory))
let options = AppConstants.MOZ_POCKET_STORIES ? [pocketSetting, bookmarks, history] : [bookmarks, history]
let secondSection = SettingSection(title: NSAttributedString(string: Strings.SettingsNewTabASTitle), footerTitle: nil, children: options)
return [firstSection, secondSection]
}
}
|
mpl-2.0
|
e4d17461e69fd2708ef18a2b06f7eda1
| 48.345455 | 221 | 0.760501 | 5.189293 | false | false | false | false |
krimpedance/KRAlertController
|
KRAlertController/Classes/KRAlertController.swift
|
1
|
12358
|
//
// KRAlertContoller.swift
//
// Copyright © 2016年 Krimpedance. All rights reserved.
//
import UIKit
/**
* KRAlertController is a beautiful and easy-to-use alert controller
* A KRAlertController object displays an alert message to the user.
* After configuring the alert controller with the actions and style you want, present it using the `show()` method.
*/
public final class KRAlertController {
/// Alert title
public var title: String?
/// Alert message
public var message: String?
/// Alert style (read only)
public fileprivate(set) var style = KRAlertControllerStyle.alert
/// The actions that the user can take in response to the alert or action sheet. (read-only)
public fileprivate(set) var actions = [KRAlertAction]()
/// The array of text fields displayed by the alert. (read-only)
public fileprivate(set) var textFields = [UITextField]()
/**
Creates and returns a controller for displaying an alert to the user. Default alert type is `.Normal`.
- parameter title: The title of the alert.
- parameter message: Descriptive text that provides additional details about the reason for the alert.
- parameter style: Constants indicating the type of alert to display.
*/
public convenience init(title: String?, message: String?, style: KRAlertControllerStyle = .alert) {
self.init()
self.title = title
self.message = message
self.style = style
}
}
/**
* Add Actions -------------
*/
extension KRAlertController {
/**
Attaches an cancel action object to the alert or action sheet.
- parameter title: Cancel button title.
- parameter handler: Cancel button action handler.
- returns: KRAlertController object.
*/
public func addCancel(title: String="Cancel", handler: KRAlertActionHandler? = nil) -> KRAlertController {
let action = KRAlertAction(title: title, style: .cancel, isPreferred: true, handler: handler)
if actions.contains(where: { $0.style == .cancel }) {
fatalError("KRAlertController can only have one action with a style of KRAlertActionStyle.Cancel")
}
actions.append(action)
return self
}
/**
Attaches an destructive action object to the alert or action sheet.
- parameter title: Destructive button title.
- parameter isPreferred: When true, Action title become preferred style.
- parameter handler: Destructive button action handler.
- returns: KRAlertController object.
*/
public func addDestructive(title: String, isPreferred: Bool = false, handler: KRAlertActionHandler? = nil) -> KRAlertController {
let action = KRAlertAction(title: title, style: .destructive, isPreferred: isPreferred, handler: handler)
actions.append(action)
return self
}
/**
Attaches an action object to the alert or action sheet.
- parameter title: Button title.
- parameter isPreferred: When true, Action title become preferred style.
- parameter handler: Button action handler.
- returns: KRAlertController object.
*/
public func addAction(title: String, isPreferred: Bool = false, handler: KRAlertActionHandler? = nil) -> KRAlertController {
let action = KRAlertAction(title: title, style: .default, isPreferred: isPreferred, handler: handler)
actions.append(action)
return self
}
/**
Adds a text field to an alert. But several setting would be reset.
- Frame
- Font size
- Border width
- Border color
- Text color
- Placeholder color
- parameter configurationHandler: A block for configuring the text field prior to displaying the alert.
- returns: KRAlertController object.
*/
public func addTextField(_ configurationHandler: ((_ textField: UITextField) -> Void)? = nil) -> KRAlertController {
assert(style == .alert, "Text fields can only be added to an alert controller of style KRAlertControllerStyle.Alert")
assert(textFields.count < 3, "KRAlertController can add text fields up to 3")
let textField = UITextField()
configurationHandler?(textField)
textFields.append(textField)
return self
}
}
/**
* Show actions ------------
*/
extension KRAlertController {
/**
Display alert. Default view controller to display alert is visible view controller of key window.
The completion handler is called after the viewDidAppear: method is called on the presented view controller.
- parameter presentingVC: The view controller to display over the current view controller’s content.
- parameter animated: Pass true to animate the presentation; otherwise, pass false.
- parameter completion: The block to execute after the presentation finishes. This block has no return value and takes no parameters. You may specify nil for this parameter.
- returns: No return value
*/
public func show(presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> Void)? = nil) {
show(.normal, presentingVC: presentingVC, animated: animated, completion: completion)
}
/**
Display success alert. Default view controller to display alert is visible view controller of key window.
The completion handler is called after the viewDidAppear: method is called on the presented view controller.
- parameter icon: Pass true to display success glaph icon; otherwise, pass false..
- parameter presentingVC: The view controller to display over the current view controller’s content.
- parameter animated: Pass true to animate the presentation; otherwise, pass false.
- parameter completion: The block to execute after the presentation finishes. This block has no return value and takes no parameters. You may specify nil for this parameter.
- returns: No return value
*/
public func showSuccess(icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> Void)? = nil) {
show(.success(icon: icon), presentingVC: presentingVC, animated: animated, completion: completion)
}
/**
Display information alert. Default view controller to display alert is visible view controller of key window.
The completion handler is called after the viewDidAppear: method is called on the presented view controller.
- parameter icon: Pass true to display information glaph icon; otherwise, pass false..
- parameter presentingVC: The view controller to display over the current view controller’s content.
- parameter animated: Pass true to animate the presentation; otherwise, pass false.
- parameter completion: The block to execute after the presentation finishes. This block has no return value and takes no parameters. You may specify nil for this parameter.
- returns: No return value
*/
public func showInformation(icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> Void)? = nil) {
show(.information(icon: icon), presentingVC: presentingVC, animated: animated, completion: completion)
}
/**
Display warning alert. Default view controller to display alert is visible view controller of key window.
The completion handler is called after the viewDidAppear: method is called on the presented view controller.
- parameter icon: Pass true to display warning glaph icon; otherwise, pass false..
- parameter presentingVC: The view controller to display over the current view controller’s content.
- parameter animated: Pass true to animate the presentation; otherwise, pass false.
- parameter completion: The block to execute after the presentation finishes. This block has no return value and takes no parameters. You may specify nil for this parameter.
- returns: No return value
*/
public func showWarning(icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> Void)? = nil) {
show(.warning(icon: icon), presentingVC: presentingVC, animated: animated, completion: completion)
}
/**
Display error alert. Default view controller to display alert is visible view controller of key window.
The completion handler is called after the viewDidAppear: method is called on the presented view controller.
- parameter icon: Pass true to display error glaph icon; otherwise, pass false..
- parameter presentingVC: The view controller to display over the current view controller’s content.
- parameter animated: Pass true to animate the presentation; otherwise, pass false.
- parameter completion: The block to execute after the presentation finishes. This block has no return value and takes no parameters. You may specify nil for this parameter.
- returns: No return value
*/
public func showError(icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> Void)? = nil) {
show(.error(icon: icon), presentingVC: presentingVC, animated: animated, completion: completion)
}
/**
Display edit alert. Default view controller to display alert is visible view controller of key window.
The completion handler is called after the viewDidAppear: method is called on the presented view controller.
- parameter icon: Pass true to display edit glaph icon; otherwise, pass false..
- parameter presentingVC: The view controller to display over the current view controller’s content.
- parameter animated: Pass true to animate the presentation; otherwise, pass false.
- parameter completion: The block to execute after the presentation finishes. This block has no return value and takes no parameters. You may specify nil for this parameter.
- returns: No return value
*/
public func showEdit(icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> Void)? = nil) {
show(.edit(icon: icon), presentingVC: presentingVC, animated: animated, completion: completion)
}
/**
Display authorize alert. Default view controller to display alert is visible view controller of key window.
The completion handler is called after the viewDidAppear: method is called on the presented view controller.
- parameter icon: Pass true to display authorize glaph icon; otherwise, pass false..
- parameter presentingVC: The view controller to display over the current view controller’s content.
- parameter animated: Pass true to animate the presentation; otherwise, pass false.
- parameter completion: The block to execute after the presentation finishes. This block has no return value and takes no parameters. You may specify nil for this parameter.
- returns: No return value
*/
public func showAuthorize(icon: Bool, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> Void)? = nil) {
show(.authorize(icon: icon), presentingVC: presentingVC, animated: animated, completion: completion)
}
}
/**
* Private actions ------------
*/
extension KRAlertController {
fileprivate func show(_ type: KRAlertControllerType, presentingVC: UIViewController? = nil, animated: Bool = true, completion: (() -> Void)? = nil) {
guard let viewController = presentingVC ?? UIApplication.shared.topViewController() else {
print("View controller to present alert controller isn't found!")
return
}
let alertVC = makeAlertViewController(type)
alertVC.statusBarHidden = viewController.prefersStatusBarHidden
viewController.present(alertVC, animated: false) {
UIView.animate(withDuration: 0.2, animations: {
alertVC.showContent()
})
}
}
fileprivate func makeAlertViewController(_ type: KRAlertControllerType) -> KRAlertBaseViewController {
let baseVC = KRAlertBaseViewController(title: title, message: message, actions: actions, textFields: textFields, style: style, type: type)
return baseVC
}
}
|
mit
|
ec24e14fdafc26978b81d2823d2c2530
| 48.364 | 180 | 0.699133 | 4.926547 | false | false | false | false |
cliffpanos/True-Pass-iOS
|
iOSApp/CheckIn/Primary Controllers/TruePassesPageViewController.swift
|
1
|
3394
|
//
// TruePassesPageViewController.swift
// True Pass
//
// Created by Cliff Panos on 6/19/17.
// Copyright © 2017 Clifford Panos. All rights reserved.
//
import UIKit
class TruePassPageViewController: UIPageViewController, UIPageViewControllerDelegate, UIPageViewControllerDataSource {
var truePassControllers = [UIViewController]()
var isEmpty = false
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
self.dataSource = self
self.view.backgroundColor = UIColor.white
for location in C.nearestTruePassLocations {
let pvc = C.storyboard.instantiateViewController(withIdentifier: "checkInPassViewController") as! CheckInPassViewController
pvc.locationForPass = location
pvc.changedBottomConstraint = 0
truePassControllers.append(pvc)
}
if truePassControllers.isEmpty {
let pvc = C.storyboard.instantiateViewController(withIdentifier: "checkInPassViewController") as! CheckInPassViewController
pvc.changedBottomConstraint = 0
truePassControllers.append(pvc)
isEmpty = true
}
self.setViewControllers([truePassControllers.first!], direction: .forward, animated: false)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
for view in self.view.subviews {
if let pageControl = view as? UIPageControl {
pageControl.backgroundColor = UIColor.white
pageControl.currentPageIndicatorTintColor = isEmpty ? UIColor.white : UIColor.TrueColors.trueBlue
pageControl.pageIndicatorTintColor = UIColor.TrueColors.lightBlueGray
}
}
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = truePassControllers.index(of: viewController) else {
return nil
}
let previousIndex = viewControllerIndex - 1
//Loop
guard previousIndex >= 0 else {
return nil
// return truePassControllers.last
}
guard truePassControllers.count > previousIndex else {
return nil
}
return truePassControllers[previousIndex]
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = truePassControllers.index(of: viewController) else {
return nil
}
let nextIndex = viewControllerIndex + 1
let count = truePassControllers.count
//Loop
guard count != nextIndex else {
return nil
// return truePassControllers.first
}
guard count > nextIndex else {
return nil
}
return truePassControllers[nextIndex]
}
func presentationCount(for pageViewController: UIPageViewController) -> Int {
let count = C.truePassLocations.count
return count > 0 ? count : 1
}
func presentationIndex(for pageViewController: UIPageViewController) -> Int {
return 0
}
}
|
apache-2.0
|
03cf56460011e89b6ed1afe343b244e1
| 32.594059 | 149 | 0.644268 | 5.91115 | false | false | false | false |
kyleweiner/Cool-Beans
|
Cool Beans/Controllers/ConnectedViewController.swift
|
1
|
3282
|
//
// ConnectedViewController.swift
// Created by Kyle on 11/14/14.
//
import UIKit
struct Temperature {
enum State {
case Unknown, Cold, Cool, Warm, Hot
}
var degreesCelcius: Float
var degressFahrenheit: Float {
return (degreesCelcius * 1.8) + 32.0
}
func state() -> State {
switch Int(degressFahrenheit) {
case let x where x <= 39: return .Cold
case 40...65: return .Cool
case 66...80: return .Warm
case let x where x >= 81: return .Hot
default: return .Unknown
}
}
}
class ConnectedViewController: UIViewController {
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var temperatureView: TemperatureView!
var connectedBean: PTDBean?
private var currentTemperature: Temperature = Temperature(degreesCelcius: 0) {
didSet {
updateTemperatureView()
updateBean()
}
}
private let refreshControl = UIRefreshControl()
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
// Update the name label.
temperatureView.nameLabel.text = connectedBean?.name ?? "Unknown"
// Add pull-to-refresh control.
refreshControl.addTarget(self, action: #selector(didPullToRefresh(_:)), forControlEvents: .ValueChanged)
refreshControl.tintColor = .whiteColor()
scrollView.addSubview(refreshControl)
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
connectedBean?.readTemperature()
}
// MARK: - Actions
func didPullToRefresh(sender: AnyObject) {
refreshControl.endRefreshing()
connectedBean?.readTemperature()
}
// MARK: - Helper
func updateTemperatureView() {
// Update the temperature label.
temperatureView.temperatureLabel.text = String(format: "%.f℉", currentTemperature.degressFahrenheit)
// Update the background color.
var backgroundColor: UIColor
switch currentTemperature.state() {
case .Unknown: backgroundColor = .blackColor()
case .Cold: backgroundColor = .CBColdColor()
case .Cool: backgroundColor = .CBCoolColor()
case .Warm: backgroundColor = .CBWarmColor()
case .Hot: backgroundColor = .CBHotColor()
}
UIView.animateWithDuration(0.4, animations: { [unowned self] in
self.scrollView.backgroundColor = backgroundColor
self.temperatureView.containerView.backgroundColor = backgroundColor
})
}
func updateBean() {
connectedBean?.setLedColor(temperatureView.containerView.backgroundColor)
}
}
// MARK: - PTDBeanDelegate
extension ConnectedViewController: PTDBeanDelegate {
func bean(bean: PTDBean!, didUpdateTemperature degrees_celsius: NSNumber!) {
let newTemperature = Temperature(degreesCelcius: degrees_celsius.floatValue)
if newTemperature.degreesCelcius != currentTemperature.degreesCelcius {
currentTemperature = newTemperature
#if DEBUG
print("TEMPERATURE UPDATED \nOld: \(currentTemperature.degressFahrenheit)℉ \nNew: \(newTemperature.degressFahrenheit)℉")
#endif
}
}
}
|
mit
|
c4a2e1107f7ac241238017b673ffd13c
| 27.745614 | 136 | 0.65232 | 4.867756 | false | false | false | false |
LiulietLee/BilibiliCD
|
BCD/ViewController/TutorialContentViewController.swift
|
1
|
858
|
//
// TutorialContentViewController.swift
// BCD
//
// Created by Liuliet.Lee on 19/7/2017.
// Copyright © 2017 Liuliet.Lee. All rights reserved.
//
import UIKit
class TutorialContentViewController: UIViewController {
@IBOutlet private weak var imageView: UIImageView!
@IBOutlet weak var insideButton: UIButton! {
didSet {
insideButton.accessibilityIgnoresInvertColors = true
}
}
var image = UIImage()
var index = 0
override func viewDidLoad() {
super.viewDidLoad()
imageView.image = image
insideButton.titleLabel!.lineBreakMode = .byWordWrapping
if index != 7 {
insideButton.removeFromSuperview()
}
}
@IBAction func goInside() {
let vc = HisTutViewController()
present(vc, animated: true)
}
}
|
gpl-3.0
|
62ee0a2c44c0871dab6361ebe92ca9f8
| 22.162162 | 64 | 0.621937 | 4.925287 | false | false | false | false |
latera1n/LR-Daily-Key-Count-OS-X
|
DailyKeyCount/AppDelegate.swift
|
1
|
5279
|
//
// AppDelegate.swift
// DailyKeyCount
//
// Created by DengYuchi on 2/1/16.
// Copyright © 2016 LateRain. All rights reserved.
//
import Cocoa
import AppKit
import ServiceManagement
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var mainMenu: NSMenu!
@IBOutlet weak var startAtLoginMenuItem: NSMenuItem!
let statusItem = NSStatusBar.system().statusItem(withLength: NSSquareStatusItemLength)
let popover = NSPopover()
let bundleIdentifierCFString = "io.laterain.DailyKeyCountHelper" as CFString
let userDefaults = UserDefaults.standard
let startAtLoginKey = "userDefaultsStartAtLoginKey"
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
let isStartAtLogin = userDefaults.bool(forKey: startAtLoginKey)
startAtLoginMenuItem.state = isStartAtLogin ? NSOnState : NSOffState
if let menuBarButton = statusItem.button {
menuBarButton.target = self
menuBarButton.image = NSImage(named: "menu-bar-icon")
}
popover.behavior = NSPopoverBehavior.transient
popover.contentViewController = MainViewController(nibName: "MainViewController", bundle: nil)
statusItem.action = #selector(AppDelegate.togglePopups(_:))
statusItem.sendAction(on: NSEventMask(rawValue: UInt64(Int((NSEventMask.leftMouseUp.rawValue | NSEventMask.rightMouseUp.rawValue)))))
showPopover(nil)
closePopover(nil)
}
func showPopover(_ sender: AnyObject?) {
if let button = statusItem.button {
popover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.maxY)
print(NSEvent.mouseLocation())
let cgEvent = CGEvent(mouseEventSource: nil, mouseType: CGEventType.leftMouseDown, mouseCursorPosition: CGPoint(x: NSEvent.mouseLocation().x, y: NSEvent.mouseLocation().y - 40.0), mouseButton: CGMouseButton.left)
let event = NSEvent(cgEvent: cgEvent!)
popover.mouseDown(with: event!)
popover.mouseUp(with: event!)
}
}
func closePopover(_ sender: AnyObject?) {
popover.performClose(sender)
}
func togglePopups(_ sender: AnyObject?) {
let event: NSEvent! = NSApp.currentEvent!
if event.type == NSEventType.leftMouseUp {
if popover.isShown {
closePopover(sender)
} else {
showPopover(sender)
}
} else {
statusItem.popUpMenu(self.mainMenu)
}
}
@IBAction func quitApp(_ sender: AnyObject) {
NSApplication.shared().terminate(sender)
}
@IBAction func startAtLoginClicked(_ sender: AnyObject) {
toggleLaunchAtStartup()
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
// MARK: - Helpers
func toggleLaunchAtStartup() {
let itemReferences = itemReferencesInLoginItems()
let shouldBeToggled = (itemReferences.existingReference == nil)
if let loginItemsRef = LSSharedFileListCreate(nil, kLSSharedFileListSessionLoginItems.takeRetainedValue(), nil).takeRetainedValue() as LSSharedFileList? {
if shouldBeToggled {
let appUrl = NSURL.fileURL(withPath: Bundle.main.bundlePath) as CFURL!
LSSharedFileListInsertItemURL(loginItemsRef, itemReferences.lastReference, nil, nil, appUrl, nil, nil)
startAtLoginMenuItem.state = NSOnState
userDefaults.set(true, forKey: startAtLoginKey)
} else {
if let itemRef = itemReferences.existingReference {
LSSharedFileListItemRemove(loginItemsRef, itemRef);
startAtLoginMenuItem.state = NSOffState
userDefaults.set(false, forKey: startAtLoginKey)
}
}
userDefaults.synchronize()
}
}
func applicationIsInStartUpItems() -> Bool {
return (itemReferencesInLoginItems().existingReference != nil)
}
func itemReferencesInLoginItems() -> (existingReference: LSSharedFileListItem?, lastReference: LSSharedFileListItem?) {
let appURL = NSURL.fileURL(withPath: Bundle.main.bundlePath)
if let loginItemsRef = LSSharedFileListCreate(nil, kLSSharedFileListSessionLoginItems.takeRetainedValue(), nil).takeRetainedValue() as LSSharedFileList? {
let loginItems: NSArray = LSSharedFileListCopySnapshot(loginItemsRef, nil).takeRetainedValue() as NSArray
let lastItemRef: LSSharedFileListItem = loginItems.lastObject as! LSSharedFileListItem
for (index, _) in loginItems.enumerated() {
let currentItemRef: LSSharedFileListItem = loginItems.object(at: index) as! LSSharedFileListItem
if let itemURL = LSSharedFileListItemCopyResolvedURL(currentItemRef, 0, nil) {
if (itemURL.takeRetainedValue() as NSURL).isEqual(appURL) {
return (currentItemRef, lastItemRef)
}
}
}
return (nil, lastItemRef)
}
return (nil, nil)
}
}
|
mit
|
9cfbb39779ac86102cc2f288de6e2805
| 40.559055 | 224 | 0.663888 | 5.210267 | false | false | false | false |
1457792186/JWSwift
|
熊猫TV2/XMTV/Classes/Home/View/PageMenuView.swift
|
2
|
12290
|
//
// PageMenuView.swift
// XMTV
//
// Created by Mac on 2017/1/7.
// Copyright © 2017年 Mac. All rights reserved.
//
import UIKit
private let selectedColor = UIColor(r: 108, g: 198, b: 152)
private let normalColor = UIColor.darkGray
private let kScrollLineH: CGFloat = 4
private let lineH: CGFloat = 0.5
private let kAddButtonW:CGFloat = 40
// MARK: - 代理
protocol PageMenuViewDelegate: class {
func pageMenuView(_ titleView : PageMenuView, selectedIndex index : Int)
}
class PageMenuView: UIView {
// MARK: - 代理
weak var delegate: PageMenuViewDelegate?
// let common = Common()
fileprivate var channels: [GameModel] = [GameModel]()
fileprivate var currentButtonIndex :Int = 0
// 默认的title就是精彩推荐和全部直播
fileprivate var titles :[String] = ["精彩推荐", "全部直播"]
fileprivate lazy var titleButtons: [UIButton] = [UIButton]()
fileprivate lazy var scrollView: UIScrollView = {
let scrollView = UIScrollView()
scrollView.showsHorizontalScrollIndicator = false
scrollView.scrollsToTop = false
scrollView.isPagingEnabled = false
scrollView.bounces = false
scrollView.backgroundColor = UIColor.white
return scrollView
}()
fileprivate lazy var rightButton: UIButton = {
let button = UIButton()
button.setImage(UIImage(named: "addbutton_43x40_"), for: .normal)
button.backgroundColor = UIColor.white
button.addTarget(self, action: #selector(self.addItemClick), for: .touchUpInside)
return button
}()
fileprivate lazy var scrollLine: UIView = {
let scrollLine = UIView()
scrollLine.backgroundColor = selectedColor
return scrollLine
}()
// , titles: [String]
override init(frame: CGRect) {
super.init(frame: frame)
addSubview(scrollView)
scrollView.frame = bounds
setupUI()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension PageMenuView {
// MARK: - 设置UI
fileprivate func setupUI() {
addSubview(rightButton)
rightButton.frame = CGRect(x: kScreenW - kAddButtonW, y: 0, width: kAddButtonW, height: self.frame.size.height)
setupTitleButtons()
setupButtomLine()
titleButtonClick(sender: titleButtons[0])
}
// MARK: - 设置标题按钮
fileprivate func setupTitleButtons() {
let bW: CGFloat = frame.width / 3
let bH: CGFloat = frame.height - kScrollLineH
let bY: CGFloat = 0
let newtitles = common.unarchiveToStringArray(appendPath: PAGE_TITLES)
if newtitles != nil {
self.titles = newtitles!
print("newtitles-", self.titles)
}
print("titles-", self.titles)
for (index, title) in titles.enumerated() {
let button = UIButton()
button.tag = index
let img = titleToSting(title: title)
var image = ""
if index == 0 { image = img + "_h_icon_13x13_" } else { image = img + "_icon_13x13_" }
button.setImage(UIImage(named: image), for: .normal)
button.setTitle(title, for: .normal)
button.setTitleColor(normalColor, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
button.imageEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 0)
button.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 10)
let bX: CGFloat = bW * CGFloat(index)
button.frame = CGRect(x: bX, y:bY , width: bW, height: bH)
scrollView.addSubview(button)
titleButtons.append(button)
button.addTarget(self, action: #selector(self.titleButtonClick(sender:)), for: .touchUpInside)
}
scrollView.contentSize = CGSize(width: bW * CGFloat(titles.count), height: 0)
}
// MARK: - 设置底部分割线
fileprivate func setupButtomLine() {
let buttomLine: UIView = UIView()
buttomLine.backgroundColor = normalColor
buttomLine.frame = CGRect(x: 0, y: frame.height - lineH, width: frame.width, height: lineH)
addSubview(buttomLine)
guard let firstButton = titleButtons.first else { return }
firstButton.setTitleColor(selectedColor, for: .normal)
scrollView.addSubview(scrollLine)
scrollLine.frame = CGRect(x: firstButton.frame.origin.x + firstButton.frame.width * 0.1, y: frame.height - kScrollLineH, width: firstButton.frame.width * 0.8, height: kScrollLineH)
}
}
// MARK: - 点击标题按钮
extension PageMenuView {
// MARK: - 点击标题按钮
@objc fileprivate func titleButtonClick(sender: UIButton) {
setupTitleCenter(button: sender)
if sender.tag == currentButtonIndex { return }
if currentButtonIndex > titleButtons.count - 1 {
currentButtonIndex = titleButtons.count - 1
}
let oldButton = titleButtons[currentButtonIndex]
sender.setTitleColor(selectedColor, for: .normal)
oldButton.setTitleColor(normalColor, for: .normal)
sender.setImage(UIImage(named: titleToSting(title: sender.currentTitle!) + "_h_icon_13x13_"), for: .normal)
oldButton.setImage(UIImage(named: titleToSting(title: oldButton.currentTitle!) + "_icon_13x13_"), for: .normal)
currentButtonIndex = sender.tag
let scrollLinePosition = sender.frame.origin.x + sender.frame.width * 0.1
scrollLine.frame.size.width = sender.frame.width * 0.8
UIView.animate(withDuration: 0.2, animations: {
self.scrollLine.frame.origin.x = scrollLinePosition//X
})
delegate?.pageMenuView(self, selectedIndex: currentButtonIndex)
}
// MARK: - 让标题按钮自动居中(如果按钮的中心点 > 屏幕的中心点则将按钮中心点偏移)
fileprivate func setupTitleCenter(button: UIButton) {
// 判断标题按钮是否需要移动
var offsetX = button.center.x - kScreenW * 0.5
let maxOffsetX = scrollView.contentSize.width - kScreenW
// print("offsetX",offsetX)
// print("maxOffsetX",maxOffsetX)
if (offsetX < 0) {
offsetX = 0
}
if (offsetX > maxOffsetX) {
// 当处于最后一个标题按钮并且maxOffsetX > 0 的时候,为防止被最右边添加按钮挡住,需要增加一个偏移
if button.tag == (self.titles.count - 1) {
if maxOffsetX > 0 {
offsetX = maxOffsetX + 40
}
} else {
if button.tag != 0 {
offsetX = maxOffsetX
}
}
}
scrollView.setContentOffset(CGPoint(x: offsetX, y: 0), animated: true)
}
// MARK: - 点击添加按钮
@objc fileprivate func addItemClick() {
if let nextResponder = next?.next, nextResponder.isKind(of: UIViewController.self){
let vc = nextResponder as! UIViewController
let subcatevc = AllSubcateVC()
vc.navigationController?.pushViewController(subcatevc, animated: true)
subcatevc.channelBlock = { channels in
var newTitles = ["精彩推荐", "全部直播"]
for model in channels {
newTitles.append(model.cname)
}
self.reloadTitles(newTitles)
}
}
}
}
//MARK:- 左右滑动屏幕,切换title时调用这个方法
extension PageMenuView{
func setTitleWithProgress(_ progress:CGFloat,sourceIndex : Int,targetIndex : Int){
let sourceButton = titleButtons[sourceIndex]
let targetButton = titleButtons[targetIndex]
let moveTotalX = targetButton.frame.origin.x - sourceButton.frame.origin.x
let moveX = moveTotalX * progress
sourceButton.setTitleColor(normalColor, for: .normal)
sourceButton.setImage(UIImage(named: titleToSting(title: sourceButton.currentTitle!) + "_icon_13x13_"), for: .normal)
targetButton.setTitleColor(selectedColor, for: .normal)
targetButton.setImage(UIImage(named: titleToSting(title: targetButton.currentTitle!) + "_h_icon_13x13_"), for: .normal)
scrollLine.frame.origin.x = sourceButton.frame.origin.x + sourceButton.frame.width*0.1 + moveX
currentButtonIndex = targetIndex
}
}
// MARK: - 刷新PageMenuView
extension PageMenuView {
fileprivate func reloadTitles(_ channels: [String]) {
scrollView.subviews.forEach { (subview) in
subview.removeFromSuperview()
}
titles.removeAll()
titleButtons.removeAll()
// 重新设置UI
self.titles = channels
print("self.titles-", self.titles)
common.archiveWithStringArray(channel: self.titles, appendPath: PAGE_TITLES)
setupUI()
// 注意: 将当前的currentButtonIndex更新,因为一旦移除了频道,titleButtons数组更新了,如果不重置,当取出按钮时,则会发生数组越界
currentButtonIndex = 0
}
/** 找到当前View所在的控制器
func getFatherController(view: UIView)-> UIViewController? {
var next: UIView? = view
repeat{
if let nextResponder = next?.next , nextResponder.isKind(of: UIViewController.self){
return (nextResponder as! UIViewController)
}
next = next?.superview
} while next != nil
return nil
}
*/
/// 因为这个标题按钮的图片是从本地加载的,而不是从网络获取的,本来是想将标题转换成小写首字母,但是尝试了多种办法后失败了,所以就用这种笨办法,如果你有更好的办法可以在github上 issu 我, 多谢!!!
func titleToSting(title :String) -> String {
if title == "精彩推荐" {return "jptj"}
else if title == "全部直播" {return "alllive"}
else if title == "炉石传说" {return "lscs"}
else if title == "守望先锋" {return "swxf"}
else if title == "英雄联盟" {return "yxlm"}
else if title == "户外直播" {return "hwzb"}
else if title == "主机游戏" {return "zjyx"}
else if title == "穿越火线" {return "cyhx"}
else if title == "魔兽世界" {return "mssj"}
else if title == "风暴英雄" {return "fbyx"}
else if title == "体育竞技" {return "tujj"}
else if title == "我的世界" {return "wdsj"}
else if title == "格斗游戏" {return "gdyx"}
else if title == "怀旧经典" {return "hjjd"}
else if title == "战争游戏" {return "zzyx"}
else if title == "萌宠乐园" {return "mcly"}
else if title == "皇室战争" {return "hszz"}
else if title == "熊猫星秀" {return "defult"}
else if title == "黎明杀机" {return "defult"}
else if title == "流放之路" {return "defult"}
else if title == "外服网游" {return "defult"}
else if title == "网络游戏" {return "defult"}
else if title == "综合手游" {return "defult"}
else if title == "捕鱼天地" {return "defult"}
else if title == "DNF" {return "dxcyys"}
else if title == "天谕" {return "ty"}
else if title == "音乐" {return "yyzb"}
else if title == "桌游" {return "defult"}
else if title == "饥荒" {return "defult"}
else if title == "剑网3" {return "jw3"}
else if title == "阴阳师" {return "dxcyys"}
else if title == "CS:GO" {return "csgo"}
else if title == "DOTA2" {return "dota2"}
else if title == "拳皇97" {return "qh97"}
else if title == "星际争霸2" {return "xjzb"}
else if title == "魔兽DOTA1" {return "mssj"}
else if title == "精灵宝可梦" {return "defult"}
else if title == "天涯明月刀" {return "ty"}
else if title == "跑跑卡丁车" {return "ppkdc"}
else if title == "暗黑破坏神3" {return "ahphs3"}
else {return ""}
}
}
|
apache-2.0
|
6cd2b0c4c4cf663a8705c4060737f1b1
| 37.690476 | 188 | 0.607824 | 3.886232 | false | false | false | false |
PairOfNewbie/BeautifulDay
|
BeautifulDay/Controller/Main/MainListController.swift
|
1
|
11204
|
//
// MainListController.swift
// BeautifulDay
//
// Created by DaiFengyi on 16/5/3.
// Copyright © 2016年 PairOfNewbie. All rights reserved.
//
import UIKit
private let mainListCellIdentifier = "MainListCell"
private let loadMoreTableCellIdentifier = "LoadMoreTableCell"
class MainListController: UITableViewController {
var trk : Track? = nil
let activityIndicator = UIActivityIndicatorView()
//MARK:- Life cycle
override func viewDidLoad() {
super.viewDidLoad()
let rc = UIRefreshControl()
rc.addTarget(self, action: #selector(MainListController.refresh(_:)), forControlEvents: .ValueChanged)
refreshControl = rc
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
tableView.pagingEnabled = true
tableView.registerNib(UINib(nibName: mainListCellIdentifier, bundle: nil), forCellReuseIdentifier: mainListCellIdentifier)
tableView.registerNib(UINib(nibName: loadMoreTableCellIdentifier, bundle:nil), forCellReuseIdentifier: loadMoreTableCellIdentifier)
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
if albumList.isEmpty {
refresh(refreshControl!)
refreshControl?.beginRefreshing()
}
self.navigationController?.setNavigationBarHidden(false, animated: true)
self.navigationController?.navigationBar.translucentBar()
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.setNavigationBarHidden(false, animated: true)
self.navigationController?.navigationBar.opaqueBar()
}
// MARK: - Refresh
@objc private func refresh(sender: UIRefreshControl) {
updateDiscoverUsers(mode: .TopRefresh) {
dispatch_async(dispatch_get_main_queue()) {
sender.endRefreshing()
}
}
}
private var currentPageIndex = 0
private var isFetching = false
private enum UpdateMode {
case Static
case TopRefresh
case LoadMore
}
private func updateDiscoverUsers(mode mode: UpdateMode, finish: (() -> Void)? = nil) {
if isFetching {
return
}
isFetching = true
if case .Static = mode {
activityIndicator.startAnimating()
view.bringSubviewToFront(activityIndicator)
}
if case .LoadMore = mode {
currentPageIndex += 1
} else {
currentPageIndex = 1
}
// todo 根据updateMode的区别来做不同的事情
fetchAlbumList({ (error) in
print(error.description)
}) { (al) in
dispatch_async(dispatch_get_main_queue(), {[weak self] in
albumList = al
self?.tableView.reloadData()
self?.isFetching = false
finish?()
})
}
// discoverUsers(masterSkillIDs: [], learningSkillIDs: [], discoveredUserSortStyle: discoveredUserSortStyle, inPage: currentPageIndex, withPerPage: 21, failureHandler: { (reason, errorMessage) in
// defaultFailureHandler(reason: reason, errorMessage: errorMessage)
//
// dispatch_async(dispatch_get_main_queue()) { [weak self] in
// self?.activityIndicator.stopAnimating()
// self?.isFetching = false
//
// finish?()
// }
//
// }, completion: { discoveredUsers in
//
// for user in discoveredUsers {
//
// for skill in user.masterSkills {
//
// let skillLocalName = skill.localName ?? ""
//
// let skillID = skill.id
//
// if let _ = skillSizeCache[skillID] {
//
// } else {
// let rect = skillLocalName.boundingRectWithSize(CGSize(width: CGFloat(FLT_MAX), height: SkillCell.height), options: [.UsesLineFragmentOrigin, .UsesFontLeading], attributes: skillTextAttributes, context: nil)
//
// skillSizeCache[skillID] = rect
// }
// }
// }
//
// dispatch_async(dispatch_get_main_queue()) { [weak self] in
//
// guard let strongSelf = self else {
// return
// }
//
// var wayToUpdate: UICollectionView.WayToUpdate = .None
//
// if case .LoadMore = mode {
// let oldDiscoveredUsersCount = strongSelf.discoveredUsers.count
// strongSelf.discoveredUsers += discoveredUsers
// let newDiscoveredUsersCount = strongSelf.discoveredUsers.count
//
// let indexPaths = Array(oldDiscoveredUsersCount..<newDiscoveredUsersCount).map({ NSIndexPath(forItem: $0, inSection: Section.User.rawValue) })
// if !indexPaths.isEmpty {
// wayToUpdate = .Insert(indexPaths)
// }
//
// } else {
// strongSelf.discoveredUsers = discoveredUsers
// wayToUpdate = .ReloadData
// }
//
// strongSelf.activityIndicator.stopAnimating()
// strongSelf.isFetching = false
//
// finish?()
//
// wayToUpdate.performWithCollectionView(strongSelf.discoveredUsersCollectionView)
// }
// })
}
// MARK: - Table view data source
private enum Section: Int {
case Normal
case LoadMore
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 2
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case Section.Normal.rawValue:
return albumList.count
case Section.LoadMore.rawValue:
return albumList.isEmpty ? 0 : 1
default:
return 0
}
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch indexPath.section {
case Section.Normal.rawValue:
let cell = tableView.dequeueReusableCellWithIdentifier(mainListCellIdentifier, forIndexPath: indexPath) as! MainListCell
return cell
case Section.LoadMore.rawValue:
let cell = tableView.dequeueReusableCellWithIdentifier(loadMoreTableCellIdentifier, forIndexPath: indexPath) as! LoadMoreTableCell
return cell
default:
return UITableViewCell()
}
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
switch indexPath.section {
case Section.Normal.rawValue:
return tableView.bounds.height
case Section.LoadMore.rawValue:
return 44
default:
return 0
}
}
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
switch indexPath.section {
case Section.Normal.rawValue:
if let cell = cell as? MainListCell {
cell.album = albumList[indexPath.row]
}
// 暂时注释掉loadMore
// case Section.LoadMore.rawValue:
// if let cell = cell as? LoadMoreTableCell {
// print("load more data")
// if !cell.loadingActivityIndicator.isAnimating() {
// cell.loadingActivityIndicator.startAnimating()
// }
// updateDiscoverUsers(mode: .LoadMore, finish: {[weak cell] in
// cell?.loadingActivityIndicator.stopAnimating()
// })
// }
default:
break
}
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
performSegueWithIdentifier("showAlbumDetail", sender: indexPath.row)
}
/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
if let row = sender as? Int {
let adc = segue.destinationViewController as! AlbumDetailController
adc.albumId = albumList[row].albumId!
}
}
@IBAction func unwindToThisViewController(segue: UIStoryboardSegue) {
}
}
|
mit
|
68c5c6855fa9b29bf0898a5a29791121
| 37.640138 | 244 | 0.574729 | 5.732546 | false | false | false | false |
ProfileCreator/ProfileCreator
|
ProfileCreator/ProfileCreator/Profile Editor TableView CellView TableView Items/EditorTableViewCellViewComboBox.swift
|
1
|
4263
|
//
// EditorTableViewCellViewPopUpButton.swift
// ProfileCreator
//
// Created by Erik Berglund.
// Copyright © 2018 Erik Berglund. All rights reserved.
//
import Cocoa
import ProfilePayloads
class EditorTableViewCellViewComboBox: NSTableCellView {
// MARK: -
// MARK: Variables
let comboBox = NSComboBox()
// MARK: -
// MARK: Initialization
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
required init(cellView: EditorTableViewProtocol & NSComboBoxDelegate, keyPath: String, value aValue: Any?, subkey: PayloadSubkey, row: Int) {
super.init(frame: NSRect.zero)
var titles = [String]()
if let rangeListTitles = subkey.rangeListTitles {
titles = rangeListTitles
} else if let rangeList = subkey.rangeList {
for value in rangeList {
titles.append(String(describing: value))
}
}
self.comboBox.translatesAutoresizingMaskIntoConstraints = false
self.comboBox.controlSize = .small
self.comboBox.delegate = cellView
self.comboBox.target = cellView
self.comboBox.addItems(withObjectValues: titles)
self.comboBox.identifier = NSUserInterfaceItemIdentifier(rawValue: keyPath)
self.comboBox.tag = row
self.addSubview(self.comboBox)
// ---------------------------------------------------------------------
// Get Value
// ---------------------------------------------------------------------
let value: Any?
if let userValue = aValue {
value = userValue
} else if let valueDefault = subkey.defaultValue() {
value = valueDefault
} else {
value = self.comboBox.objectValues.first
}
// ---------------------------------------------------------------------
// Select Value
// ---------------------------------------------------------------------
if
let selectedValue = value,
let title = PayloadUtility.title(forRangeListValue: selectedValue, subkey: subkey),
comboBox.objectValues.contains(value: selectedValue, ofType: .string) {
comboBox.objectValue = title
} else {
comboBox.objectValue = value
}
// ---------------------------------------------------------------------
// Setup Variables
// ---------------------------------------------------------------------
var constraints = [NSLayoutConstraint]()
// CenterY
constraints.append(NSLayoutConstraint(item: self,
attribute: .centerY,
relatedBy: .equal,
toItem: self.comboBox,
attribute: .centerY,
multiplier: 1.0,
constant: 0.7))
// Leading
constraints.append(NSLayoutConstraint(item: self.comboBox,
attribute: .leading,
relatedBy: .equal,
toItem: self,
attribute: .leading,
multiplier: 1.0,
constant: 2.0))
// Trailing
constraints.append(NSLayoutConstraint(item: self,
attribute: .trailing,
relatedBy: .equal,
toItem: self.comboBox,
attribute: .trailing,
multiplier: 1.0,
constant: 3.0))
// ---------------------------------------------------------------------
// Activate Layout Constraints
// ---------------------------------------------------------------------
NSLayoutConstraint.activate(constraints)
}
}
|
mit
|
7f43d04f07dc4469c3c44295b27eee31
| 38.462963 | 145 | 0.420695 | 6.8192 | false | false | false | false |
cao903775389/MRCBaseLibrary
|
MRCBaseLibrary/Classes/MRCExtension/UIBarButtonItemExtensions.swift
|
1
|
2185
|
//
// UIBarButtonItemExtensions.swift
// Pods
//
// Created by 逢阳曹 on 2017/5/27.
//
//
import Foundation
extension UIBarButtonItem {
/**
* !@brief 创建纯图片按钮的BarButtonItem
* @param image 默认正常状态下图片
* @param selectedImage 选中图片
*/
public class func createImageBarButtonItem(_ image: UIImage, selectedImage: UIImage?, target: Any?, action: Selector?) -> UIBarButtonItem {
return self.createBarButtonItem(nil, font: nil, image: image, selectedImage: selectedImage, titleColor: nil, target: target, action: action)
}
/**
* !@brief 创建纯文字按钮的BarButtonItem
* @param title 文字
* @param font 文字大小
* @param titleColor 文字颜色
*/
public class func createTitleBarButtonItem(_ title: String, font: UIFont = UIFont.systemFont(ofSize: 13), titleColor: UIColor = UIColor(rgba: "#323232"), target: Any?, action: Selector?) -> UIBarButtonItem {
return self.createBarButtonItem(title, font: font, image: nil, selectedImage: nil, titleColor: titleColor, target: target, action: action)
}
/**
* !@brief 创建UIBarButtonItem
*/
public class func createBarButtonItem(_ title: String?, font: UIFont?, image: UIImage?, selectedImage: UIImage?, titleColor: UIColor?, target: Any?, action: Selector?) -> UIBarButtonItem {
let button = UIButton.createButton(title, font: font, image: image, selectedImage: selectedImage, titleColor: titleColor)
//绑定方法
if target != nil && action != nil {
button.addTarget(target!, action: action!, for: UIControlEvents.touchUpInside)
}
//纯文字 或者 纯图片
if title != nil && font != nil {
let size = (title! as NSString).size(attributes: [NSFontAttributeName: font!])
button.frame = CGRect(x: 0, y: 0, width: size.width < 52 ? 52 : size.width + 10, height: 44)
}else if image != nil {
button.frame = CGRect(x: 0, y: 0, width: 30, height: 44)
}
return UIBarButtonItem(customView: button)
}
}
|
mit
|
a6db6326bf72eb344ccf07299a77b533
| 36.690909 | 211 | 0.626146 | 4.283058 | false | false | false | false |
galv/reddift
|
reddift/Network/Session.swift
|
1
|
4853
|
//
// Session.swift
// reddift
//
// Created by sonson on 2015/04/14.
// Copyright (c) 2015年 sonson. All rights reserved.
//
import Foundation
/// For JSON object, typically this alias means [AnyObject] or [String:AnyObject], and so on.
public typealias JSON = Any
/// For JSON object, typically this alias means [String:AnyObject]
public typealias JSONDictionary = Dictionary<String, AnyObject>
/// For JSON object, typically this alias means [AnyObject]
public typealias JSONArray = Array<AnyObject>
/// For reddit object.
public typealias RedditAny = Any
/// Session class to communicate with reddit.com using OAuth.
public class Session : NSObject, NSURLSessionDelegate, NSURLSessionDataDelegate {
/// Token object to access via OAuth
public var token:Token? = nil
/// Base URL for OAuth API
let baseURL:String
/// Session object to communicate a server
var URLSession:NSURLSession = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration())
/// Duration until rate limit of API usage as second.
var x_ratelimit_reset:Int = 0
/// Count of use API after rete limit is reseted.
var x_ratelimit_used:Int = 0
/// Duration until rate limit of API usage as second.
var x_ratelimit_remaining:Int = 0
/// OAuth endpoint URL
static let OAuthEndpointURL = "https://oauth.reddit.com/"
/// Public endpoint URL
static let publicEndpointURL = "https://www.reddit.com/"
/**
Initialize session object with OAuth token.
- parameter token: Token object, that is an instance of OAuth2Token or OAuth2AppOnlyToken.
*/
public init(token:Token) {
self.token = token
baseURL = Session.OAuthEndpointURL
}
/**
Initialize anonymouse session object
*/
override public init() {
baseURL = Session.publicEndpointURL
super.init()
}
/**
Update API usage state.
- parameter response: NSURLResponse object is passed from NSURLSession.
*/
func updateRateLimitWithURLResponse(response:NSURLResponse?, verbose:Bool = false) {
if let response = response, let httpResponse:NSHTTPURLResponse = response as? NSHTTPURLResponse {
if let temp = httpResponse.allHeaderFields["x-ratelimit-reset"] as? String {
x_ratelimit_reset = Int(temp) ?? 0
}
if let temp = httpResponse.allHeaderFields["x-ratelimit-used"] as? String {
x_ratelimit_used = Int(temp) ?? 0
}
if let temp = httpResponse.allHeaderFields["x-ratelimit-remaining"] as? String {
x_ratelimit_remaining = Int(temp) ?? 0
}
}
if verbose {
print("x_ratelimit_reset \(x_ratelimit_reset)")
print("x_ratelimit_used \(x_ratelimit_used)")
print("x_ratelimit_remaining \(x_ratelimit_remaining)")
}
}
/**
Returns object which is generated from JSON object from reddit.com.
This method automatically parses JSON and generates data.
- parameter response: NSURLResponse object is passed from NSURLSession.
- parameter completion: The completion handler to call when the load request is complete.
- returns: Data task which requests search to reddit.com.
*/
func handleRequest(request:NSMutableURLRequest, completion:(Result<RedditAny>) -> Void) -> NSURLSessionDataTask? {
let task = URLSession.dataTaskWithRequest(request, completionHandler: { (data:NSData?, response:NSURLResponse?, error:NSError?) -> Void in
self.updateRateLimitWithURLResponse(response)
let result = resultFromOptionalError(Response(data: data, urlResponse: response), optionalError:error)
.flatMap(response2Data)
.flatMap(data2Json)
.flatMap(json2RedditAny)
completion(result)
})
task.resume()
return task
}
/**
Returns JSON object which is obtained from reddit.com.
- parameter response: NSURLResponse object is passed from NSURLSession.
- parameter completion: The completion handler to call when the load request is complete.
- returns: Data task which requests search to reddit.com.
*/
func handleAsJSONRequest(request:NSMutableURLRequest, completion:(Result<JSON>) -> Void) -> NSURLSessionDataTask? {
let task = URLSession.dataTaskWithRequest(request, completionHandler: { (data:NSData?, response:NSURLResponse?, error:NSError?) -> Void in
self.updateRateLimitWithURLResponse(response)
let result = resultFromOptionalError(Response(data: data, urlResponse: response), optionalError:error)
.flatMap(response2Data)
.flatMap(data2Json)
completion(result)
})
task.resume()
return task
}
}
|
mit
|
90e4ced57e2a672b0a68cff4e7589e66
| 37.5 | 146 | 0.671202 | 4.709709 | false | false | false | false |
kaltura/playkit-ios
|
Example/Tests/Helpers/PluginTestConfiguration.swift
|
1
|
1426
|
// ===================================================================================================
// Copyright (C) 2017 Kaltura Inc.
//
// Licensed under the AGPLv3 license,
// unless a different license for a particular library is specified in the applicable library path.
//
// You may obtain a copy of the License at
// https://www.gnu.org/licenses/agpl-3.0.html
// ===================================================================================================
import Foundation
enum PluginTestConfiguration {
case TVPAPI
case Phoenix
mutating func next() {
switch self {
case .TVPAPI: self = .Phoenix
case .Phoenix: self = .TVPAPI
}
}
var pluginName: String {
switch self {
case .TVPAPI: return "TVPAPIAnalyticsPluginMock"
case .Phoenix: return "PhoenixAnalyticsPluginMock"
}
}
var paramsDict: [String : Any] {
switch self {
case .TVPAPI: return [
"fileId": "464302",
"baseUrl": "http://tvpapi-preprod.ott.kaltura.com/v3_9/gateways/jsonpostgw.aspx?",
"timerInterval":30,
"initObj": ["": ""]
]
case .Phoenix: return [
"fileId": "464302",
"baseUrl": "http://api-preprod.ott.kaltura.com/v4_1/api_v3/",
"partnerId": 198,
"timerInterval": 30
]
}
}
}
|
agpl-3.0
|
119581bb6f3072aa366a780e777f74bd
| 28.708333 | 102 | 0.479663 | 4.401235 | false | false | false | false |
snailjj/iOSDemos
|
SnailSwiftDemos/SnailSwiftDemos/MainViewController.swift
|
2
|
3058
|
//
// MainViewController.swift
// SnailSwiftDemos
//
// Created by Jian Wu on 2016/11/4.
// Copyright © 2016年 Snail. All rights reserved.
//
import UIKit
class MainViewController: CustomViewController,UITableViewDataSource,UITableViewDelegate {
@IBOutlet weak var aTableView: UITableView!
var cellNames = ["Foundations","CoreFrameworks","Skills","ThirdFrameworks","AppleOtherTargets","UIKits","Sensor","Point","SmallPoints"]
override func viewDidLoad() {
super.viewDidLoad()
self.automaticallyAdjustsScrollViewInsets = false
// Do any additional setup after loading the view.
leftBtn.isHidden = true
rightBtn.isHidden = false
navTitleLabel.text = "主界面"
aTableView.register(UITableViewCell.self, forCellReuseIdentifier: "MainCell")
//设置系统分割线的长短
aTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0)
}
//MARK: - UITableViewDelegate methods
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return cellNames.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MainCell", for: indexPath)
cell.textLabel?.text = cellNames[indexPath.row]
cell.selectionStyle = .none
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.performSegue(withIdentifier: cellNames[indexPath.row], sender: nil)
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 20))
headerView.backgroundColor = UIColor.red
return nil
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 20
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.00001
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let headerView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 20))
headerView.backgroundColor = UIColor.yellow
return nil
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
|
apache-2.0
|
23ee351a424e2f7c1ef86f1800d33957
| 34.22093 | 139 | 0.677121 | 5.073702 | false | false | false | false |
nbrady-techempower/FrameworkBenchmarks
|
frameworks/Swift/perfect/Sources/Perfect-MySQL/main.swift
|
22
|
8200
|
import PerfectHTTP
import PerfectHTTPServer
import PerfectLib
import PerfectMySQL
import Foundation
let tfbHost = "tfb-database"
let database = "hello_world"
let username = "benchmarkdbuser"
let password = "benchmarkdbpass"
let mysql = MySQL()
let connected = mysql.connect(host: tfbHost, user: username, password: password)
let _ = mysql.selectDatabase(named: database)
class LinearCongruntialGenerator {
var state = 0
let a, c, m, shift: Int
init() {
self.a = 214013
self.c = 2531011
self.m = Int(pow(2.0, 31.0))
self.shift = 16
}
func random() -> Int {
state = (a * state + c) % m
return state >> shift
}
}
let numGenerator = LinearCongruntialGenerator()
func fetchFromFortune() -> [[String: String]] {
var arrOfFortunes = [[String: String]]()
let querySuccess = mysql.query(statement: "SELECT id, message FROM fortune")
guard querySuccess else {
let errorObject = ["id": "Failed to execute query"]
arrOfFortunes.append(errorObject)
return arrOfFortunes
}
let results = mysql.storeResults()!
results.forEachRow { row in
if let id = row[0], let message = row[1] {
let resObj = ["id": String(describing: id), "message": message]
arrOfFortunes.append(resObj)
} else {
print("not correct values returned: ", row)
}
}
return arrOfFortunes
}
func fetchFromWorld(id: String?) -> [String:Any] {
var returnObj = [String: Any]()
var errorObject = [String: Any]()
var rand:Int = 0
if id == nil {
rand = numGenerator.random() % 10000 + 1
} else {
rand = Int(id!)!
}
let querySuccess = mysql.query(statement: "SELECT id, randomNumber FROM World WHERE id = \(rand)")
guard querySuccess else {
errorObject["id"] = "Failed to execute query"
return errorObject
}
let results = mysql.storeResults()!
results.forEachRow { row in
if let id = row[0], let randomNumber = row[1] {
returnObj["id"] = id
returnObj["randomNumber"] = randomNumber
} else {
returnObj["id"] = "No return value"
returnObj["randomNumber"] = "what happened?"
}
}
return returnObj
}
func updateOneFromWorld() -> [String: Any] {
var returnObj = [String: Any]()
var errorObject = [String: Any]()
let worldToUpdate = fetchFromWorld(id: nil)
let id: String = worldToUpdate["id"] as! String
let newRandom = numGenerator.random() % 10000
let querySuccess = mysql.query(statement: "UPDATE World SET randomNumber = \(newRandom) WHERE id = \(id)")
guard querySuccess else {
errorObject["id"] = "Failed to execute query"
return errorObject
}
if let results = mysql.storeResults() {
results.forEachRow { row in
if let id = row[0], let randomNumber = row[1] {
returnObj["id"] = id
returnObj["randomNumber"] = randomNumber
} else {
returnObj["id"] = "No return value"
returnObj["randomNumber"] = "what happened?"
}
}
return returnObj
} else {
returnObj["id"] = id
returnObj["randomNumber"] = newRandom
return returnObj
}
}
func fortunesHandler(request: HTTPRequest, response: HTTPResponse) {
var arrOfFortunes = fetchFromFortune()
let newObj: [String: String] = ["id": "0", "message": "Additional fortune added at request time."]
arrOfFortunes.append(newObj)
let sortedArr = arrOfFortunes.sorted(by: ({ $0["message"]! < $1["message"]! }))
let htmlToRet = spoofHTML(fortunesArr: sortedArr)
response.appendBody(string: htmlToRet)
setHeaders(response: response, contentType: "text/html")
response.setHeader(.custom(name: "CustomLength"), value: String(describing: htmlToRet.count + 32))
response.completed()
}
func updatesHandler(request: HTTPRequest, response: HTTPResponse) {
let queryStr = returnCorrectTuple(queryArr: request.queryParams)
var totalQueries = sanitizeQueryValue(queryString: queryStr)
var updateArr: Array = [[String: Any]]()
while 0 < totalQueries {
updateArr.append(updateOneFromWorld())
totalQueries -= 1
}
do {
response.appendBody(string: try updateArr.jsonEncodedString())
} catch {
response.appendBody(string: String(describing: updateArr))
}
setHeaders(response: response, contentType: "application/json")
response.completed()
}
func multipleDatabaseQueriesHandler(request: HTTPRequest, response: HTTPResponse) {
let queryStr = returnCorrectTuple(queryArr: request.queryParams)
var totalQueries = sanitizeQueryValue(queryString: queryStr)
var queryArr: Array = [[String: Any]]()
while 0 < totalQueries {
queryArr.append(fetchFromWorld(id: nil))
totalQueries -= 1
}
do {
response.appendBody(string: try queryArr.jsonEncodedString())
} catch {
response.appendBody(string: String(describing: queryArr))
}
setHeaders(response: response, contentType: "application/json")
response.completed()
}
func singleDatabaseQueryHandler(request: HTTPRequest, response: HTTPResponse) {
let res = fetchFromWorld(id: nil)
let errorPayload: [String: Any] = [
"error": "Could not set body!"
]
var responseString: String = ""
var errorString: String = ""
do {
errorString = try errorPayload.jsonEncodedString()
} catch {
// Nothing to do here - we already have an empty value
}
do {
responseString = try res.jsonEncodedString()
response.appendBody(string: responseString)
} catch {
response.status = HTTPResponseStatus.internalServerError
response.appendBody(string: errorString)
}
setHeaders(response: response, contentType: "application/json")
response.completed()
}
// Helpers
func setHeaders(response: HTTPResponse, contentType: String) {
response.setHeader(.contentType, value: contentType)
response.setHeader(.custom(name: "Server"), value: "Perfect")
let currDate: String = getCurrDate()
response.setHeader(.custom(name: "Date"), value: currDate)
}
func getCurrDate() -> String {
let now = getNow()
do {
let formatted = try formatDate(now, format: "%a, %d %b %Y %H:%M:%S %Z", timezone: nil, locale: nil)
return formatted
} catch {
return "error formatting date string"
}
}
func returnCorrectTuple(queryArr: [(String, String)]) -> String {
for tup in queryArr {
if String(describing: tup.0) == "queries" {
return String(describing: tup.1)
}
}
return "nil"
}
func sanitizeQueryValue(queryString: String) -> Int {
if let queryNum = Int(queryString) {
if queryNum > 0 && queryNum < 500 {
return queryNum
} else if queryNum > 500 {
return 500
} else {
return 1
}
} else {
return 1
}
}
func spoofHTML(fortunesArr: [[String: Any]]) -> String {
var htmlToRet = "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"
for fortune in fortunesArr {
htmlToRet += "<tr><td>\(fortune["id"]!)</td><td>\(fortune["message"]!)</td></tr>"
}
htmlToRet += "</table></body></html>";
return htmlToRet
}
var routes = Routes()
routes.add(method: .get, uri: "/fortunes", handler: fortunesHandler)
routes.add(method: .get, uri: "/updates", handler: updatesHandler)
routes.add(method: .get, uri: "/queries", handler: multipleDatabaseQueriesHandler)
routes.add(method: .get, uri: "/db", handler: singleDatabaseQueryHandler)
routes.add(method: .get, uri: "/**",
handler: StaticFileHandler(documentRoot: "./webroot", allowResponseFilters: true).handleRequest)
try HTTPServer.launch(name: "localhost",
port: 8080,
routes: routes,
responseFilters: [
(PerfectHTTPServer.HTTPFilter.contentCompression(data: [:]), HTTPFilterPriority.high)])
|
bsd-3-clause
|
cfb2a8ba627e58ba116c6196ffa024e6
| 25.198083 | 128 | 0.629024 | 4.045387 | false | false | false | false |
adib/Core-ML-Playgrounds
|
Photo-Explorations/PhotoPlays.playground/Pages/Vision UI.xcplaygroundpage/Contents.swift
|
1
|
10581
|
//: [Previous](@previous)
import Foundation
import UIKit
import Vision
import PlaygroundSupport
class ViewController : UIViewController,UIScrollViewDelegate {
var mainImage = #imageLiteral(resourceName: "pexels-photo-109919.jpeg")
lazy var mainScrollView = {
() -> UIScrollView in
let scrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: 320, height: 320))
scrollView.minimumZoomScale = 0.5
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.delegate = self
let imageView = self.mainImageView
imageView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(imageView)
let viewBindings = [
"imageView" : imageView
]
scrollView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[imageView]|", options: [], metrics: nil, views: viewBindings))
scrollView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[imageView]|", options: [], metrics: nil, views: viewBindings))
scrollView.backgroundColor = .green
return scrollView
}()
lazy var mainImageView = {
() -> UIImageView in
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFit
imageView.setContentHuggingPriority(.defaultHigh, for: .vertical)
imageView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
return imageView
}()
override func loadView() {
mainImageView.image = mainImage
let resetButton = UIButton(type: .system)
resetButton.addTarget(self, action: #selector(resetImage), for: .primaryActionTriggered)
resetButton.setTitle(NSLocalizedString("Reset", comment: "Reset Button"), for: .normal)
let faceRectanglesButton = UIButton(type: .system)
faceRectanglesButton.addTarget(self, action: #selector(detectFaceRectangles), for: .primaryActionTriggered)
faceRectanglesButton.setTitle(NSLocalizedString("Face Rectangles", comment: "Recognize Button"), for: .normal)
let recognizeButton = UIButton(type: .system)
recognizeButton.addTarget(self, action: #selector(detectFaceLandmarks), for: .primaryActionTriggered)
recognizeButton.setTitle(NSLocalizedString("Face Landmarks", comment: "Recognize Button"), for: .normal)
let maskButton = UIButton(type: .system)
maskButton.addTarget(self, action: #selector(maskFaces), for: .primaryActionTriggered)
maskButton.setTitle(NSLocalizedString("Mask", comment: "Mask Button"), for: .normal)
let buttonBar = UIStackView(arrangedSubviews:[resetButton,faceRectanglesButton,recognizeButton,maskButton])
buttonBar.axis = .horizontal
buttonBar.distribution = .fillEqually
buttonBar.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
let rootStackView = UIStackView(arrangedSubviews:[mainScrollView,buttonBar])
rootStackView.axis = .vertical
rootStackView.distribution = .fill
self.view = rootStackView
}
override func viewDidLoad() {
super.viewDidLoad()
}
// MARK: UIScrollViewDelegate
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
if scrollView === mainScrollView {
return mainImageView
}
return nil
}
// MARK: - Actions
@IBAction func resetImage() {
print("Reset image")
mainImageView.image = mainImage
mainScrollView.setNeedsLayout()
}
@IBAction func detectFaceRectangles() throws {
print("detect face rectangles")
let image = mainImage
let faceFeaturesRequest = VNDetectFaceRectanglesRequest { (request : VNRequest, error : Error?) in
let imageSize = image.size
UIGraphicsBeginImageContextWithOptions(imageSize, true, 1)
let currentContext = UIGraphicsGetCurrentContext()!
defer {
let resultImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
DispatchQueue.main.async {
self.mainImageView.image = resultImage
}
}
image.draw(in: CGRect(origin: CGPoint(x:0,y:0), size: imageSize))
// Translate to cartesian
currentContext.translateBy(x: 0, y: imageSize.height)
currentContext.scaleBy(x: 1.0, y: -1.0)
let faceBoxColor = UIColor.magenta
currentContext.setStrokeColor(faceBoxColor.cgColor)
currentContext.setLineWidth(4)
for observation in request.results! {
if let faceObservation = observation as? VNFaceObservation {
let boundingBox = faceObservation.boundingBox
let rectBox = CGRect(x: boundingBox.origin.x * imageSize.width, y: boundingBox.origin.y * imageSize.height,width:boundingBox.size.width * imageSize.width, height: boundingBox.size.height * imageSize.height)
print("boundingBox: \(boundingBox) rectBox: \(rectBox)")
currentContext.stroke(rectBox)
}
}
}
let requestHandler = VNImageRequestHandler(cgImage:image.cgImage! , options: [:])
try requestHandler.perform([faceFeaturesRequest])
}
@IBAction func detectFaceLandmarks() throws {
print("detect face landmarks")
let image = mainImage
DispatchQueue.global(qos: .userInitiated).async {
let faceFeaturesRequest = VNDetectFaceLandmarksRequest { (request : VNRequest, error : Error?) in
let imageSize = image.size
UIGraphicsBeginImageContextWithOptions(imageSize, true, 1)
let currentContext = UIGraphicsGetCurrentContext()!
defer {
let resultImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
DispatchQueue.main.async {
self.mainImageView.image = resultImage
}
}
image.draw(in: CGRect(origin: CGPoint(x:0,y:0), size: imageSize))
currentContext.translateBy(x: 0, y: imageSize.height)
currentContext.scaleBy(x: 1.0, y: -1.0)
let faceBoxColor = UIColor.green
let faceBoxLine = CGFloat(4)
let faceContourColor = UIColor.yellow
let faceContourLine = CGFloat(3)
let eyebrowColor = UIColor.blue
let eyebrowLine = CGFloat(3)
let eyeColor = UIColor.cyan
let eyeLine = CGFloat(3)
for observation in request.results! {
if let faceObservation = observation as? VNFaceObservation {
let boundingBox = faceObservation.boundingBox
let rectBox = CGRect(x: boundingBox.origin.x * imageSize.width, y: boundingBox.origin.y * imageSize.height,width:boundingBox.size.width * imageSize.width, height: boundingBox.size.height * imageSize.height)
print("boundingBox: \(boundingBox) rectBox: \(rectBox)")
currentContext.setStrokeColor(faceBoxColor.cgColor)
currentContext.setLineWidth(4)
currentContext.stroke(rectBox)
func draw(faceRegion:VNFaceLandmarkRegion2D?,color:UIColor,lineWidth:CGFloat){
guard let region = faceRegion else {
return
}
let points = region.normalizedPoints
let path = UIBezierPath(baseRect: rectBox,relativePoints: UnsafeBufferPointer(start: points, count: region.pointCount))
color.setStroke()
path.lineWidth = lineWidth
path.stroke()
}
draw(faceRegion: faceObservation.landmarks?.faceContour, color: faceContourColor, lineWidth: faceContourLine)
draw(faceRegion: faceObservation.landmarks?.leftEye, color: eyeColor, lineWidth: eyeLine)
draw(faceRegion: faceObservation.landmarks?.rightEye, color: eyeColor, lineWidth: eyeLine)
draw(faceRegion: faceObservation.landmarks?.leftEyebrow, color: eyebrowColor, lineWidth: eyeLine)
draw(faceRegion: faceObservation.landmarks?.rightEyebrow, color: eyebrowColor, lineWidth: eyeLine)
}
}
}
faceFeaturesRequest.preferBackgroundProcessing = true
let requestHandler = VNImageRequestHandler(cgImage:image.cgImage! , options: [:])
do {
try requestHandler.perform([faceFeaturesRequest])
} catch let e as NSError {
print("Error during request: \(e)")
}
}
}
@IBAction func maskFaces() {
print("Mask faces")
}
}
struct ImageModifier {
var buttonTitle = ""
}
extension UIBezierPath {
convenience init(baseRect: CGRect,relativePoints: UnsafeBufferPointer<CGPoint>) {
self.init()
let pointCount = relativePoints.count
for i in 0..<pointCount {
let curPoint = relativePoints[i]
let curPos = CGPoint(x: baseRect.minX + CGFloat(curPoint.x) * baseRect.width, y: baseRect.minY + CGFloat(curPoint.y) * baseRect.height)
//let firstPos : CGPoint
if i == 0 {
// first point
self.move(to: curPos)
} else {
self.addLine(to: curPos)
}
}
}
}
let viewController = ViewController()
viewController.preferredContentSize = CGSize(width: 600, height: 600)
PlaygroundPage.current.liveView = viewController
PlaygroundPage.current.needsIndefiniteExecution
//: [Next](@next)
|
bsd-3-clause
|
21027cdff2a952cabeaafc9e5973b404
| 41.155378 | 230 | 0.591532 | 5.637187 | false | false | false | false |
apple/swift-format
|
Sources/SwiftFormatCore/FindingCategorizing.swift
|
1
|
1427
|
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
/// Types that conform to this protocol can be used as the category of a finding.
///
/// A finding's category should have a human-readable string representation (by overriding the
/// `description` property from the inherited `CustomStringConvertible` conformance). This is meant
/// to be displayed as part of the diagnostic message when the finding is presented to the user.
/// For example, the category `Indentation` in the message `[Indentation] Indent by 2 spaces`.
public protocol FindingCategorizing: CustomStringConvertible {
/// The default severity of findings emitted in this category.
///
/// By default, all findings are warnings. Individual categories may choose to override this to
/// make the findings in those categories more severe.
var defaultSeverity: Finding.Severity { get }
}
extension FindingCategorizing {
public var defaultSeverity: Finding.Severity { .warning }
}
|
apache-2.0
|
dbef8c1131d1638693ca8bf274a25284
| 48.206897 | 99 | 0.674142 | 5.078292 | false | false | false | false |
lohmander/SimpleToast
|
Toast/Toast/Toast.swift
|
1
|
3916
|
//
// Toast.swift
// Toast
//
// Created by Hannes Lohmander on 13/07/15.
// Copyright (c) 2015 Lohmander. All rights reserved.
//
import Foundation
public class Toast {
public static let LENGTH_SHORT: Double = 2
public static let LENGTH_LONG: Double = 5
/// Shared toast appearance settings
public static let appearance = ToastAppearance()
/// Shared keyboard observer used to determine appropriate toast position
private static var keyboardObserver: KeyboardObserver?
var text: String!
var duration: Double!
var toast: ToastView!
/**
Initializes keyboard observer used to figure out the appropriate
toast position
:returns: Void
*/
public class func initKeyboardObserver() -> Void {
Toast.keyboardObserver = KeyboardObserver()
}
/**
Initializes a Toast-object with sepcified text and duration
:param: text Text message to show
:param: duration Time to show the toast
:returns: Toast
*/
public class func makeText(text: String, duration: Double = Toast.LENGTH_LONG) -> Toast {
let toast = Toast()
toast.text = text
toast.duration = duration
return toast
}
/**
Displays the toast on screen
:returns: Void
*/
public func show() -> Void {
let keyWindow = UIApplication.sharedApplication().keyWindow
if let windowView = keyWindow?.subviews.first as? UIView {
toast = ToastView()
toast.textLabel?.text = self.text
let margin = Toast.appearance.margin
let views = ["toast": toast]
let yMargin: CGFloat
if let kO = Toast.keyboardObserver {
yMargin = margin + kO.offset
} else {
yMargin = margin
}
windowView.addSubview(toast)
let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:[toast]-\(yMargin)-|", options: NSLayoutFormatOptions(0), metrics: nil, views: views)
let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|-(>=\(margin))-[toast]-(>=\(margin))-|", options: NSLayoutFormatOptions(0), metrics: nil, views: views)
let centerContraint = NSLayoutConstraint(item: toast, attribute: .CenterX, relatedBy: .Equal, toItem: windowView, attribute: .CenterX, multiplier: 1, constant: 0)
windowView.addConstraints(verticalConstraints)
windowView.addConstraints(horizontalConstraints)
windowView.addConstraint(centerContraint)
UIView.animateWithDuration(Toast.appearance.animationDuration, animations: { () -> Void in
self.toast.alpha = 1
})
delayHide(duration)
}
}
/**
Hide the toast
:returns: Void
*/
public func hide() -> Void {
UIView.animateWithDuration(Toast.appearance.animationDuration, animations: { () -> Void in
self.toast.alpha = 0
}) { (_) -> Void in
self.remove()
}
}
/**
Hide the toast after x seconds
:param: delay Number of seconds to wait before hiding
:returns: Void
*/
public func delayHide(delay: Double) -> Void {
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
self.hide()
}
}
/**
Remove the toast from the view tree (automatically called by
hide after animation has finished)
:returns: Void
*/
public func remove() -> Void {
self.toast.removeFromSuperview()
}
}
|
mit
|
742f575ee9270f620de7d29be908ecb2
| 29.364341 | 194 | 0.584525 | 5.173052 | false | false | false | false |
OscarSwanros/swift
|
test/Constraints/array_literal.swift
|
2
|
9385
|
// RUN: %target-typecheck-verify-swift
struct IntList : ExpressibleByArrayLiteral {
typealias Element = Int
init(arrayLiteral elements: Int...) {}
}
struct DoubleList : ExpressibleByArrayLiteral {
typealias Element = Double
init(arrayLiteral elements: Double...) {}
}
struct IntDict : ExpressibleByArrayLiteral {
typealias Element = (String, Int)
init(arrayLiteral elements: Element...) {}
}
final class DoubleDict : ExpressibleByArrayLiteral {
typealias Element = (String, Double)
init(arrayLiteral elements: Element...) {}
}
final class List<T> : ExpressibleByArrayLiteral {
typealias Element = T
init(arrayLiteral elements: T...) {}
}
final class Dict<K,V> : ExpressibleByArrayLiteral {
typealias Element = (K,V)
init(arrayLiteral elements: (K,V)...) {}
}
infix operator =>
func => <K, V>(k: K, v: V) -> (K,V) { return (k,v) }
func useIntList(_ l: IntList) {}
func useDoubleList(_ l: DoubleList) {}
func useIntDict(_ l: IntDict) {}
func useDoubleDict(_ l: DoubleDict) {}
func useList<T>(_ l: List<T>) {}
func useDict<K,V>(_ d: Dict<K,V>) {}
useIntList([1,2,3])
useIntList([1.0,2,3]) // expected-error{{cannot convert value of type 'Double' to expected element type 'Int'}}
useIntList([nil]) // expected-error {{nil is not compatible with expected element type 'Int'}}
useDoubleList([1.0,2,3])
useDoubleList([1.0,2.0,3.0])
useIntDict(["Niners" => 31, "Ravens" => 34])
useIntDict(["Niners" => 31, "Ravens" => 34.0]) // expected-error{{cannot convert value of type '(String, Double)' to expected element type '(String, Int)'}}
// <rdar://problem/22333090> QoI: Propagate contextual information in a call to operands
useDoubleDict(["Niners" => 31, "Ravens" => 34.0])
useDoubleDict(["Niners" => 31.0, "Ravens" => 34])
useDoubleDict(["Niners" => 31.0, "Ravens" => 34.0])
// Generic slices
useList([1,2,3])
useList([1.0,2,3])
useList([1.0,2.0,3.0])
useDict(["Niners" => 31, "Ravens" => 34])
useDict(["Niners" => 31, "Ravens" => 34.0])
useDict(["Niners" => 31.0, "Ravens" => 34.0])
// Fall back to [T] if no context is otherwise available.
var a = [1,2,3]
var a2 : [Int] = a
var b = [1,2,3.0]
var b2 : [Double] = b
var arrayOfStreams = [1..<2, 3..<4]
struct MyArray : ExpressibleByArrayLiteral {
typealias Element = Double
init(arrayLiteral elements: Double...) {
}
}
var myArray : MyArray = [2.5, 2.5]
// Inference for tuple elements.
var x1 = [1]
x1[0] = 0
var x2 = [(1, 2)]
x2[0] = (3, 4)
var x3 = [1, 2, 3]
x3[0] = 4
func trailingComma() {
_ = [1, ]
_ = [1, 2, ]
_ = ["a": 1, ]
_ = ["a": 1, "b": 2, ]
}
func longArray() {
var _=["1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"]
}
[1,2].map // expected-error {{expression type '((Int) throws -> _) throws -> [_]' is ambiguous without more context}}
// <rdar://problem/25563498> Type checker crash assigning array literal to type conforming to _ArrayProtocol
func rdar25563498<T : ExpressibleByArrayLiteral>(t: T) {
var x: T = [1] // expected-error {{cannot convert value of type '[Int]' to specified type 'T'}}
// expected-warning@-1{{variable 'x' was never used; consider replacing with '_' or removing it}}
}
func rdar25563498_ok<T : ExpressibleByArrayLiteral>(t: T) -> T
where T.ArrayLiteralElement : ExpressibleByIntegerLiteral {
let x: T = [1]
return x
}
class A { }
class B : A { }
class C : A { }
/// Check for defaulting the element type to 'Any' / 'Any?'.
func defaultToAny(i: Int, s: String) {
let a1 = [1, "a", 3.5]
// expected-error@-1{{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}}
let _: Int = a1 // expected-error{{value of type '[Any]'}}
let a2: Array = [1, "a", 3.5]
// expected-error@-1{{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}}
let _: Int = a2 // expected-error{{value of type 'Array<Any>'}}
let a3 = [1, "a", nil, 3.5]
// expected-error@-1{{heterogeneous collection literal could only be inferred to '[Any?]'; add explicit type annotation if this is intentional}}
let _: Int = a3 // expected-error{{value of type '[Any?]'}}
let a4: Array = [1, "a", nil, 3.5]
// expected-error@-1{{heterogeneous collection literal could only be inferred to '[Any?]'; add explicit type annotation if this is intentional}}
let _: Int = a4 // expected-error{{value of type 'Array<Any?>'}}
let a5 = []
// expected-error@-1{{empty collection literal requires an explicit type}}
let _: Int = a5 // expected-error{{value of type '[Any]'}}
let _: [Any] = [1, "a", 3.5]
let _: [Any] = [1, "a", [3.5, 3.7, 3.9]]
let _: [Any] = [1, "a", [3.5, "b", 3]]
let _: [Any?] = [1, "a", nil, 3.5]
let _: [Any?] = [1, "a", nil, [3.5, 3.7, 3.9]]
let _: [Any?] = [1, "a", nil, [3.5, "b", nil]]
let a6 = [B(), C()]
let _: Int = a6 // expected-error{{value of type '[A]'}}
}
func noInferAny(iob: inout B, ioc: inout C) {
var b = B()
var c = C()
let _ = [b, c, iob, ioc] // do not infer [Any] when elements are lvalues or inout
let _: [A] = [b, c, iob, ioc] // do not infer [Any] when elements are lvalues or inout
b = B()
c = C()
}
/// Check handling of 'nil'.
protocol Proto1 {}
protocol Proto2 {}
struct Nilable: ExpressibleByNilLiteral {
init(nilLiteral: ()) {}
}
func joinWithNil<T>(s: String, a: Any, t: T, m: T.Type, p: Proto1 & Proto2, arr: [Int], opt: Int?, iou: Int!, n: Nilable) {
let a1 = [s, nil]
let _: Int = a1 // expected-error{{value of type '[String?]'}}
let a2 = [nil, s]
let _: Int = a2 // expected-error{{value of type '[String?]'}}
let a3 = ["hello", nil]
let _: Int = a3 // expected-error{{value of type '[String?]'}}
let a4 = [nil, "hello"]
let _: Int = a4 // expected-error{{value of type '[String?]'}}
let a5 = [(s, s), nil]
let _: Int = a5 // expected-error{{value of type '[(String, String)?]'}}
let a6 = [nil, (s, s)]
let _: Int = a6 // expected-error{{value of type '[(String, String)?]'}}
let a7 = [("hello", "world"), nil]
let _: Int = a7 // expected-error{{value of type '[(String, String)?]'}}
let a8 = [nil, ("hello", "world")]
let _: Int = a8 // expected-error{{value of type '[(String, String)?]'}}
let a9 = [{ $0 * 2 }, nil]
let _: Int = a9 // expected-error{{value of type '[((Int) -> Int)?]'}}
let a10 = [nil, { $0 * 2 }]
let _: Int = a10 // expected-error{{value of type '[((Int) -> Int)?]'}}
let a11 = [a, nil]
let _: Int = a11 // expected-error{{value of type '[Any?]'}}
let a12 = [nil, a]
let _: Int = a12 // expected-error{{value of type '[Any?]'}}
let a13 = [t, nil]
let _: Int = a13 // expected-error{{value of type '[T?]'}}
let a14 = [nil, t]
let _: Int = a14 // expected-error{{value of type '[T?]'}}
let a15 = [m, nil]
let _: Int = a15 // expected-error{{value of type '[T.Type?]'}}
let a16 = [nil, m]
let _: Int = a16 // expected-error{{value of type '[T.Type?]'}}
let a17 = [p, nil]
let _: Int = a17 // expected-error{{value of type '[(Proto1 & Proto2)?]'}}
let a18 = [nil, p]
let _: Int = a18 // expected-error{{value of type '[(Proto1 & Proto2)?]'}}
let a19 = [arr, nil]
let _: Int = a19 // expected-error{{value of type '[[Int]?]'}}
let a20 = [nil, arr]
let _: Int = a20 // expected-error{{value of type '[[Int]?]'}}
let a21 = [opt, nil]
let _: Int = a21 // expected-error{{value of type '[Int?]'}}
let a22 = [nil, opt]
let _: Int = a22 // expected-error{{value of type '[Int?]'}}
let a23 = [iou, nil]
let _: Int = a23 // expected-error{{value of type '[Int?]'}}
let a24 = [nil, iou]
let _: Int = a24 // expected-error{{value of type '[Int?]'}}
let a25 = [n, nil]
let _: Int = a25 // expected-error{{value of type '[Nilable]'}}
let a26 = [nil, n]
let _: Int = a26 // expected-error{{value of type '[Nilable]'}}
}
struct OptionSetLike : ExpressibleByArrayLiteral {
typealias Element = OptionSetLike
init() { }
init(arrayLiteral elements: OptionSetLike...) { }
static let option: OptionSetLike = OptionSetLike()
}
func testOptionSetLike(b: Bool) {
let _: OptionSetLike = [ b ? [] : OptionSetLike.option, OptionSetLike.option]
let _: OptionSetLike = [ b ? [] : .option, .option]
}
// Join of class metatypes - <rdar://problem/30233451>
class Company<T> {
init(routes: [() -> T]) { }
}
class Person { }
class Employee: Person { }
class Manager: Person { }
let routerPeople = Company(
routes: [
{ () -> Employee.Type in
_ = ()
return Employee.self
},
{ () -> Manager.Type in
_ = ()
return Manager.self
}
]
)
// Same as above but with existentials
protocol Fruit {}
protocol Tomato : Fruit {}
struct Chicken : Tomato {}
protocol Pear : Fruit {}
struct Beef : Pear {}
let routerFruit = Company(
routes: [
{ () -> Tomato.Type in
_ = ()
return Chicken.self
},
{ () -> Pear.Type in
_ = ()
return Beef.self
}
]
)
// Infer [[Int]] for SR3786aa.
// FIXME: As noted in SR-3786, this was the behavior in Swift 3, but
// it seems like the wrong choice and is less by design than by
// accident.
let SR3786a: [Int] = [1, 2, 3]
let SR3786aa = [SR3786a.reversed(), SR3786a]
|
apache-2.0
|
0ca3805055a97bf4b5ee322a2869c18e
| 27.966049 | 178 | 0.592541 | 3.036234 | false | false | false | false |
Spriter/SwiftyHue
|
Sources/BridgeServices/BridgeFinder/Scanner/NUPNPScanner.swift
|
1
|
1823
|
//
// NUPNPScanner.swift
// HueSDK
//
// Created by Nils Lattek on 24.04.16.
// Copyright © 2016 Nils Lattek. All rights reserved.
//
import Foundation
class NUPNPScanner: NSObject, Scanner {
weak var delegate: ScannerDelegate?
required init(delegate: ScannerDelegate? = nil) {
self.delegate = delegate
super.init()
}
func start() {
let request = createRequest()
startRequest(request as URLRequest)
}
func stop() {
}
private func createRequest() -> URLRequest {
let url = URL(string: "https://www.meethue.com/api/nupnp")!
var request = URLRequest(url: url)
request.httpMethod = "GET"
return request
}
private func startRequest(_ request: URLRequest) {
let task = URLSession.shared.dataTask(with: request) { [weak self] (data, response, error) in
guard let this = self else {
return
}
if error != nil || data == nil {
this.delegate?.scanner(this, didFinishWithResults: [])
return
}
let ips = this.parseResults(data!)
this.delegate?.scanner(this, didFinishWithResults: ips)
}
task.resume()
}
private func parseResults(_ data: Data) -> [String] {
var ips = [String]()
do {
if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [[String: String]] {
for bridgeJson in json {
if let ip = bridgeJson["internalipaddress"] {
ips.append(ip)
}
}
}
} catch let error as NSError {
print("Error while parsing nupnp results: \(error)")
}
return ips
}
}
|
mit
|
26d32aaae758f489250e076eeee48518
| 23.621622 | 108 | 0.535675 | 4.43309 | false | false | false | false |
envoyproxy/envoy-mobile
|
test/swift/apps/experimental/ViewController.swift
|
2
|
6082
|
import Envoy
import UIKit
private let kCellID = "cell-id"
private let kRequestAuthority = "api.lyft.com"
private let kRequestPath = "/ping"
private let kRequestScheme = "https"
private let kFilteredHeaders =
["server", "filter-demo", "async-filter-demo", "x-envoy-upstream-service-time"]
final class ViewController: UITableViewController {
private var results = [Result<Response, RequestError>]()
private var timer: Foundation.Timer?
private var streamClient: StreamClient?
private var pulseClient: PulseClient?
override func viewDidLoad() {
super.viewDidLoad()
let engine = EngineBuilder()
.addLogLevel(.debug)
.addPlatformFilter(DemoFilter.init)
.addPlatformFilter(BufferDemoFilter.init)
.addPlatformFilter(AsyncDemoFilter.init)
.h2ExtendKeepaliveTimeout(true)
.enableAdminInterface()
.enableInterfaceBinding(true)
.enablePlatformCertificateValidation(true)
.addNativeFilter(
name: "envoy.filters.http.buffer",
typedConfig: """
{\
"@type":"type.googleapis.com/envoy.extensions.filters.http.buffer.v3.Buffer",\
"max_request_bytes":5242880\
}
"""
)
.setOnEngineRunning { NSLog("Envoy async internal setup completed") }
.addStringAccessor(name: "demo-accessor", accessor: { return "PlatformString" })
.addKeyValueStore(name: "demo-kv-store", keyValueStore: UserDefaults.standard)
.setEventTracker { NSLog("Envoy event emitted: \($0)") }
.build()
self.streamClient = engine.streamClient()
self.pulseClient = engine.pulseClient()
NSLog("started Envoy, beginning requests...")
self.startRequests()
}
deinit {
self.timer?.invalidate()
}
// MARK: - Requests
private func startRequests() {
self.timer = .scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] _ in
self?.performRequest()
self?.recordStats()
}
}
private func performRequest() {
guard let streamClient = self.streamClient else {
NSLog("failed to start request - Envoy is not running")
return
}
NSLog("starting request to '\(kRequestPath)'")
// Note: this request will use an h2 stream for the upstream request.
// The Objective-C example uses http/1.1. This is done on purpose to test both paths in
// end-to-end tests in CI.
let headers = RequestHeadersBuilder(method: .get, scheme: kRequestScheme,
authority: kRequestAuthority, path: kRequestPath)
.addUpstreamHttpProtocol(.http2)
.build()
streamClient
.newStreamPrototype()
.setOnResponseHeaders { [weak self] headers, _, _ in
let statusCode = headers.httpStatus.map(String.init) ?? "nil"
let message = "received headers with status \(statusCode)"
let headerMessage = headers.caseSensitiveHeaders()
.filter { kFilteredHeaders.contains($0.key) }
.map { "\($0.key): \($0.value.joined(separator: ", "))" }
.joined(separator: "\n")
NSLog(message)
if let filterDemoValue = headers.value(forName: "filter-demo")?.first {
NSLog("filter-demo: \(filterDemoValue)")
}
if let asyncFilterDemoValue = headers.value(forName: "async-filter-demo")?.first {
NSLog("async-filter-demo: \(asyncFilterDemoValue)")
}
let response = Response(message: message,
headerMessage: headerMessage)
self?.add(result: .success(response))
}
.setOnError { [weak self] error, _ in
let message: String
if let attemptCount = error.attemptCount {
message = "failed within Envoy library after \(attemptCount) attempts: \(error.message)"
} else {
message = "failed within Envoy library: \(error.message)"
}
NSLog(message)
self?.add(result: .failure(RequestError(message: message)))
}
.start()
.sendHeaders(headers, endStream: true)
}
private func add(result: Result<Response, RequestError>) {
self.results.insert(result, at: 0)
self.tableView.reloadData()
}
private func recordStats() {
guard let pulseClient = self.pulseClient else {
NSLog("failed to send stats - Envoy is not running")
return
}
let counter = pulseClient.counter(elements: ["foo", "bar", "counter"])
counter.increment()
counter.increment(count: 5)
let gauge = pulseClient.gauge(elements: ["foo", "bar", "gauge"])
gauge.set(value: 5)
gauge.add(amount: 10)
gauge.sub(amount: 1)
let timer = pulseClient.timer(elements: ["foo", "bar", "timer"])
let distribution = pulseClient.distribution(elements: ["foo", "bar", "distribution"])
timer.recordDuration(durationMs: 15)
distribution.recordValue(value: 15)
}
// MARK: - UITableView
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.results.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath)
-> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: kCellID) ??
UITableViewCell(style: .subtitle, reuseIdentifier: kCellID)
let result = self.results[indexPath.row]
switch result {
case .success(let response):
cell.textLabel?.text = response.message
cell.detailTextLabel?.text = response.headerMessage
cell.textLabel?.textColor = .black
cell.detailTextLabel?.lineBreakMode = .byWordWrapping
cell.detailTextLabel?.numberOfLines = 0
cell.detailTextLabel?.textColor = .black
cell.contentView.backgroundColor = .white
case .failure(let error):
cell.textLabel?.text = error.message
cell.detailTextLabel?.text = nil
cell.textLabel?.textColor = .white
cell.detailTextLabel?.textColor = .white
cell.contentView.backgroundColor = .red
}
return cell
}
}
|
apache-2.0
|
cd0b86bc49b59d09f8631af67da950dc
| 32.788889 | 98 | 0.657021 | 4.304317 | false | false | false | false |
jeremiahyan/ResearchKit
|
samples/ORKParkinsonStudy/ORKParkinsonStudy/Main/Header/HeaderView.swift
|
2
|
7291
|
/*
Copyright (c) 2018, Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Neither the name of the copyright holder(s) nor the names of any contributors
may be used to endorse or promote products derived from this software without
specific prior written permission. No license is granted to the trademarks of
the copyright holders even if such marks are included in this software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import Foundation
import UIKit
class HeaderView: UIView {
var title: String!
var descriptionText: NSAttributedString!
var iconName: String!
var invertColors: Bool!
let PADDING: CGFloat = 30.0
let CIRCLEDIM: CGFloat = 60.0
var nameContainer: UIView!
var iconContainer: UIView!
var bottomLineView: UIView!
init(title: String, descriptionText: NSAttributedString, iconName: String, invertColors: Bool) {
super.init(frame: .zero)
self.backgroundColor = UIColor.clear
self.title = title
self.descriptionText = descriptionText
self.iconName = iconName
self.invertColors = invertColors
self.setupNameView()
self.setupIcon()
self.setupConstraints()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNameView() {
self.nameContainer = UIView()
self.nameContainer.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(self.nameContainer)
let activeLabel = UILabel()
activeLabel.attributedText = self.descriptionText
activeLabel.translatesAutoresizingMaskIntoConstraints = false
activeLabel.textColor = UIColor.white
self.nameContainer.addSubview(activeLabel)
let nameLabel = UILabel()
nameLabel.text = self.title
nameLabel.textColor = (self.invertColors == true) ? UIColor.white : UIColor.black
nameLabel.translatesAutoresizingMaskIntoConstraints = false
let largeFont = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .largeTitle)
let boldFont = largeFont.withSymbolicTraits(.traitBold)
nameLabel.font = UIFont(descriptor: boldFont!, size: 0)
self.nameContainer.addSubview(nameLabel)
activeLabel.topAnchor.constraint(equalTo: nameLabel.bottomAnchor, constant: 3.0).isActive = true
activeLabel.leadingAnchor.constraint(equalTo: self.nameContainer.safeAreaLayoutGuide.leadingAnchor, constant: PADDING).isActive = true
activeLabel.bottomAnchor.constraint(equalTo: self.nameContainer.bottomAnchor, constant: -(PADDING + (CIRCLEDIM / 2) - 15)).isActive = true
nameLabel.topAnchor.constraint(equalTo: self.nameContainer.topAnchor, constant: PADDING).isActive = true
nameLabel.leadingAnchor.constraint(equalTo: self.nameContainer.safeAreaLayoutGuide.leadingAnchor, constant: PADDING).isActive = true
bottomLineView = UIView()
bottomLineView.backgroundColor = Colors.tableViewBackgroundColor.color
bottomLineView.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(bottomLineView)
nameContainer.backgroundColor = invertColors ? UIColor.clear : UIColor.white
}
func setupIcon() {
self.iconContainer = UIView()
self.iconContainer.layer.cornerRadius = CIRCLEDIM / 2
self.iconContainer.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(iconContainer)
let iconView = UIImageView()
iconView.image = UIImage(named: self.iconName)?.withRenderingMode(.alwaysTemplate)
iconView.contentMode = .scaleAspectFit
iconView.translatesAutoresizingMaskIntoConstraints = false
self.iconContainer.addSubview(iconView)
let iconPadding: CGFloat = 5.0
iconView.topAnchor.constraint(equalTo: self.iconContainer.topAnchor, constant: iconPadding).isActive = true
iconView.leadingAnchor.constraint(equalTo: self.iconContainer.leadingAnchor, constant: iconPadding).isActive = true
iconView.trailingAnchor.constraint(equalTo: self.iconContainer.trailingAnchor, constant: -iconPadding).isActive = true
iconView.bottomAnchor.constraint(equalTo: self.iconContainer.bottomAnchor, constant: -iconPadding).isActive = true
iconContainer.backgroundColor = invertColors ? UIColor.white : UIColor.clear
}
override func tintColorDidChange() {
super.tintColorDidChange()
self.nameContainer.backgroundColor = invertColors ? UIColor.clear: UIColor.white
self.iconContainer.backgroundColor = invertColors ? UIColor.white : UIColor.clear
}
func setupConstraints() {
self.nameContainer.topAnchor.constraint(equalTo: self.topAnchor, constant: 20.0).isActive = true
self.nameContainer.leadingAnchor.constraint(equalTo: self.leadingAnchor).isActive = true
self.nameContainer.trailingAnchor.constraint(equalTo: self.trailingAnchor).isActive = true
self.iconContainer.heightAnchor.constraint(equalToConstant: CIRCLEDIM).isActive = true
self.iconContainer.widthAnchor.constraint(equalToConstant: CIRCLEDIM).isActive = true
self.iconContainer.leadingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.leadingAnchor, constant: PADDING).isActive = true
self.iconContainer.topAnchor.constraint(equalTo: self.nameContainer.bottomAnchor, constant: -(CIRCLEDIM / 2)).isActive = true
self.iconContainer.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: 0.0).isActive = true
bottomLineView.leadingAnchor.constraint(equalTo: self.leadingAnchor).isActive = true
bottomLineView.trailingAnchor.constraint(equalTo: self.trailingAnchor).isActive = true
bottomLineView.topAnchor.constraint(equalTo: self.nameContainer.bottomAnchor).isActive = true
bottomLineView.bottomAnchor.constraint(equalTo: self.iconContainer.bottomAnchor).isActive = true
}
}
|
bsd-3-clause
|
9b00d4e061b9573ba801ddb6198f5fd3
| 49.282759 | 146 | 0.73721 | 5.215308 | false | false | false | false |
rene-dohan/CS-IOS
|
Renetik/Renetik/Classes/Core/Protocols/CSHasDialog.swift
|
1
|
1892
|
//
// Created by Rene Dohan on 1/11/20.
//
import Foundation
public protocol CSHasDialogVisible: class {
var isDialogVisible: Bool { get }
func hideDialog(animated: Bool)
}
public extension CSHasDialogVisible {
func hideDialog() { hideDialog(animated: true) }
}
public struct CSDialogAction {
public let title: String?, action: Func
public init(action: @escaping Func) {
self.title = nil
self.action = action
}
public init(title: String?, action: @escaping Func) {
self.title = title
self.action = action
}
}
public protocol CSHasDialogProtocol {
@discardableResult
func show(title: String?, message: String,
positive: CSDialogAction?, negative: CSDialogAction?,
cancel: CSDialogAction?) -> CSHasDialogVisible
}
public extension CSHasDialogProtocol {
@discardableResult
public func show(message: String,
positiveTitle: String = .cs_dialog_ok,
onPositive: Func? = nil,
onCanceled: Func? = nil,
canCancel: Bool = true) -> CSHasDialogVisible {
show(title: nil, message: message,
positive: CSDialogAction(title: positiveTitle, action: onPositive ?? {}),
negative: nil, cancel: canCancel ? CSDialogAction(action: onCanceled ?? {}) : nil)
}
@discardableResult
public func show(message: String, onPositive: Func? = nil) -> CSHasDialogVisible {
show(message: message, positiveTitle: .cs_dialog_ok, onPositive: onPositive)
}
@discardableResult
public func show(title: String? = nil, message: String,
positive: CSDialogAction?, negative: CSDialogAction? = nil) -> CSHasDialogVisible {
show(title: title, message: message, positive: positive,
negative: negative, cancel: nil)
}
}
|
mit
|
2b20c7c791d9952de785faebace49dda
| 30.533333 | 104 | 0.630021 | 4.33945 | false | false | false | false |
Adorkable/BingAPIiOS
|
BingAPI/Routes/SearchSuggestRoute.swift
|
1
|
2900
|
//
// SearchSuggestRoute.swift
// BingAPI
//
// Created by Ian on 6/12/15.
// Copyright (c) 2015 Adorkable. All rights reserved.
//
import AdorkableAPIBase
public class SearchSuggestRoute: RouteBase<Bing> {
public typealias ResultsHandler = (SuccessResult<[String]>) -> Void
override public var baseUrl : NSURL? {
return NSURL(string: "http://api.bing.com")
}
override public static var httpMethod : String {
return "GET"
}
override public var path : String {
get {
return "/osjson.aspx"
}
}
var searchText : String
init(searchText : String, timeoutInterval : NSTimeInterval = Bing.timeoutInterval, cachePolicy : NSURLRequestCachePolicy = Bing.cachePolicy) {
self.searchText = searchText
super.init(timeoutInterval: timeoutInterval, cachePolicy: cachePolicy)
}
override public var query : String {
get {
var result = ""
RouteBase<Bing>.addParameter(&result, name: "query", value: self.searchText)
return result
}
}
func start(configureUrlRequest : ( (urlRequest : NSMutableURLRequest) -> Void)?,
resultsHandler : ResultsHandler) {
let task = self.jsonTask(configureUrlRequest) { (result) -> Void in
switch result {
case .Success(let jsonObject):
if let jsonArray = jsonObject as? NSArray
{
let results = self.dynamicType.parseResults(jsonArray)
resultsHandler(results)
} else
{
let error = NSError(domain: "In results expected Array, unexpected format " + _stdlib_getDemangledTypeName(jsonObject), code: 0, userInfo: nil)
resultsHandler(.Failure(error))
}
break
case .Failure(let error):
resultsHandler(.Failure(error))
}
}
if task != nil
{
task!.resume()
} else
{
let error = NSError(domain: "Unable to create SearchRoute task", code: 0, userInfo: nil)
resultsHandler(.Failure(error))
}
}
internal class func parseResults(jsonResponse : NSArray) -> SuccessResult<[String]> {
var result = Array<String>()
for baseEntry in jsonResponse
{
if let suggestions = baseEntry as? NSArray
{
for suggestionObject in suggestions
{
if let suggestion = suggestionObject as? String
{
result.append(suggestion)
}
}
}
}
return .Success(result)
}
}
|
mit
|
cb65085c4526f7ed814d3eeedff28e44
| 28.292929 | 163 | 0.527931 | 5.390335 | false | false | false | false |
google/iosched-ios
|
Source/IOsched/Screens/Onboarding/CountdownView.swift
|
1
|
22643
|
//
// Copyright (c) 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Lottie
import UIKit
class CountdownView: UIView {
@available(*, unavailable)
required init(coder: NSCoder) {
fatalError("NSCoding not supported")
}
public init() {
super.init(frame: CGRect(x: 0, y: 0, width: 260, height: 240))
addSubview(secondsOnesDigit)
addSubview(secondsTensDigit)
addSubview(minutesOnesDigit)
addSubview(minutesTensDigit)
addSubview(hoursOnesDigit)
addSubview(hoursTensDigit)
addSubview(daysOnesDigit)
addSubview(daysTensDigit)
addSubview(secondsLabel)
addSubview(minutesLabel)
addSubview(hoursLabel)
addSubview(daysLabel)
addConstraints(digitConstraints)
addConstraints(labelConstraints)
isUserInteractionEnabled = true
setupInitialState()
setContentCompressionResistancePriority(.required, for: .vertical)
setContentCompressionResistancePriority(.required, for: .horizontal)
}
convenience override init(frame: CGRect) {
self.init()
}
static var contentSize: CGSize {
if IODateComparer.currentDateRelativeToIO() != .before {
return .zero
} else {
return CGSize(width: 260, height: 240)
}
}
override var intrinsicContentSize: CGSize {
return CountdownView.contentSize
}
private lazy var targetDate: Date = {
return IODateComparer.ioStartDate
}()
func timeLeftUntilTargetDate(from date: Date = Date()) -> TimeInterval {
let difference = targetDate.timeIntervalSince(date)
return difference > 0 ? difference : 0
}
func setupInitialState() {
for view in allAnimationViews {
if let animationView = view as? AnimationView {
animationView.stop()
}
}
let timeRemaining = timeLeftUntilTargetDate()
setTimeRemaining(timeRemaining)
var progress = progressInterval(from: secondsOnes, to: 0)
secondsOnesDigit.currentProgress = progress.0
progress = progressInterval(from: secondsTens, to: 0)
secondsTensDigit.currentProgress = progress.0
progress = progressInterval(from: minutesOnes, to: 0)
minutesOnesDigit.currentProgress = progress.0
progress = progressInterval(from: minutesTens, to: 0)
minutesTensDigit.currentProgress = progress.0
progress = progressInterval(from: hoursOnes, to: 0)
hoursOnesDigit.currentProgress = progress.0
progress = progressInterval(from: hoursTens, to: 0)
hoursTensDigit.currentProgress = progress.0
progress = progressInterval(from: daysOnes, to: 0)
daysOnesDigit.currentProgress = progress.0
progress = progressInterval(from: daysTens, to: 0)
daysTensDigit.currentProgress = progress.0
}
// MARK: - Number animation views
private func animationView() -> AnimationView {
let view = AnimationView()
view.animation = nil
view.translatesAutoresizingMaskIntoConstraints = false
view.contentMode = .scaleAspectFit
view.animation = CountdownView.animation
view.loopMode = .playOnce
view.backgroundBehavior = .stop
return view
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
// Multi-touch is not enabled by default, so touches should only have one object.
if let touch = touches.first, bounds.contains(touch.location(in: self)) {
viewTapped(self)
}
}
private static let animation = Animation.named("countdown9-0")
private func newTimer() -> Timer {
let timer = Timer.scheduledTimer(timeInterval: 1,
target: self,
selector: #selector(updateWithAnimations(_:)),
userInfo: nil,
repeats: true)
timer.tolerance = 0.1
return timer
}
private var timer: Timer? {
didSet {
oldValue?.invalidate()
}
}
var paused: Bool {
return timer == nil
}
func play() {
timer = newTimer()
}
func stop() {
timer = nil
}
@objc private func viewTapped(_ sender: Any) {
if paused {
play()
} else {
stop()
}
}
@objc private func updateWithAnimations(_ sender: Any) {
let timeRemaining = timeLeftUntilTargetDate()
setTimeRemaining(timeRemaining)
if timeRemaining == 0 {
collapse()
}
}
private var isCollapsed: Bool = false
private func collapse() {
stop()
for view in subviews {
view.removeFromSuperview()
}
isCollapsed = true
}
private func setTimeRemaining(_ timeRemaining: TimeInterval) {
let seconds = Int(timeRemaining.truncatingRemainder(dividingBy: 60))
let secondsOnes = seconds % 10
let secondsTens = (seconds - secondsOnes) / 10
let minutes = Int(timeRemaining / 60) % 60
let minutesOnes = minutes % 10
let minutesTens = (minutes - minutesOnes) / 10
let hours = Int(timeRemaining / 3600) % 24
let hoursOnes = hours % 10
let hoursTens = (hours - hoursOnes) / 10
let days = Int(timeRemaining / 86400) // disregard leap seconds, acquire bugs
let daysOnes = days % 10
let daysTens = (days % 100 - daysOnes) / 10
self.secondsOnes = secondsOnes
self.secondsTens = secondsTens
self.minutesOnes = minutesOnes
self.minutesTens = minutesTens
self.hoursOnes = hoursOnes
self.hoursTens = hoursTens
self.daysOnes = daysOnes
self.daysTens = daysTens
}
private func progressInterval(from oldValue: Int, to newValue: Int) -> (CGFloat, CGFloat) {
let startingProgress = (CGFloat(10 - oldValue) / 10).truncatingRemainder(dividingBy: 1)
let endingProgress = CGFloat(10 - newValue) / 10
return (startingProgress, endingProgress)
}
private func animateView(_ view: AnimationView,
oldValue: Int,
newValue: Int) {
if oldValue == newValue { return }
// Special case for animating from 0 -> 6 for seconds' tens place digit.
if oldValue == 0 && newValue != 9 {
let animateOutProgressInterval: (CGFloat, CGFloat) = (0, 0.05)
let animateInStart = CGFloat(10 - newValue) / 10 - 0.05
let animateInEnd = animateInStart + 0.05
view.play(fromProgress: animateOutProgressInterval.0,
toProgress: animateOutProgressInterval.1,
completion: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
view.play(fromProgress: animateInStart, toProgress: animateInEnd, completion: nil)
}
} else {
let progress = progressInterval(from: oldValue, to: newValue)
view.play(fromProgress: progress.0, toProgress: progress.1, completion: nil)
}
}
private var secondsOnes: Int = 10 {
didSet {
animateView(secondsOnesDigit,
oldValue: oldValue,
newValue: secondsOnes)
}
}
private var secondsTens: Int = 10 {
didSet {
animateView(secondsTensDigit,
oldValue: oldValue,
newValue: secondsTens)
}
}
private var minutesOnes: Int = 10 {
didSet {
animateView(minutesOnesDigit,
oldValue: oldValue,
newValue: minutesOnes)
}
}
private var minutesTens: Int = 10 {
didSet {
animateView(minutesTensDigit,
oldValue: oldValue,
newValue: minutesTens)
}
}
private var hoursOnes: Int = 10 {
didSet {
animateView(hoursOnesDigit,
oldValue: oldValue,
newValue: hoursOnes)
}
}
private var hoursTens: Int = 10 {
didSet {
animateView(hoursTensDigit,
oldValue: oldValue,
newValue: hoursTens)
}
}
private var daysOnes: Int = 10 {
didSet {
animateView(daysOnesDigit,
oldValue: oldValue,
newValue: daysOnes)
}
}
private var daysTens: Int = 10 {
didSet {
animateView(daysTensDigit,
oldValue: oldValue,
newValue: daysTens)
}
}
private lazy var secondsOnesDigit = animationView()
private lazy var secondsTensDigit = animationView()
private lazy var minutesOnesDigit = animationView()
private lazy var minutesTensDigit = animationView()
private lazy var hoursOnesDigit = animationView()
private lazy var hoursTensDigit = animationView()
private lazy var daysOnesDigit = animationView()
private lazy var daysTensDigit = animationView()
private lazy var allAnimationViews: [UIView] = {
return [
secondsOnesDigit,
secondsTensDigit,
minutesOnesDigit,
minutesTensDigit,
hoursOnesDigit,
hoursTensDigit,
daysOnesDigit,
daysTensDigit,
secondsLabel,
minutesLabel,
hoursLabel,
daysLabel
]
}()
// Strings passed to this function should be localized.
private func digitsLabel(withText text: String) -> UILabel {
let label = UILabel()
label.isAccessibilityElement = false
label.textColor = UIColor(hex: "#747474")
label.text = text
label.font = UIFont.systemFont(ofSize: 11)
label.translatesAutoresizingMaskIntoConstraints = false
return label
}
lazy private var secondsLabel =
digitsLabel(withText: NSLocalizedString("S",
comment: "Abbreviation for seconds, capitalized where applicable"))
lazy private var minutesLabel =
digitsLabel(withText: NSLocalizedString("M",
comment: "Abbreviation for minutes, capitalized where applicable"))
lazy private var hoursLabel =
digitsLabel(withText: NSLocalizedString("H",
comment: "Abbreviation for hours, capitalized where applicable"))
lazy private var daysLabel =
digitsLabel(withText: NSLocalizedString("D",
comment: "Abbreviation for days, capitalized where applicable"))
// MARK: - Autolayout constraints
private var digitConstraints: [NSLayoutConstraint] {
let verticalSpacing: CGFloat = 22.5
let horizontalSpacing: CGFloat = 20
return [
// seconds ones digit
NSLayoutConstraint(item: secondsOnesDigit, attribute: .top,
relatedBy: .equal,
toItem: self, attribute: .centerY,
multiplier: 1,
constant: verticalSpacing),
NSLayoutConstraint(item: secondsOnesDigit, attribute: .left,
relatedBy: .equal,
toItem: self, attribute: .centerX,
multiplier: 1,
constant: horizontalSpacing + 60),
NSLayoutConstraint(item: secondsOnesDigit, attribute: .width,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 50),
NSLayoutConstraint(item: secondsOnesDigit, attribute: .height,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 80),
// seconds tens digit
NSLayoutConstraint(item: secondsTensDigit, attribute: .top,
relatedBy: .equal,
toItem: self, attribute: .centerY,
multiplier: 1,
constant: verticalSpacing),
NSLayoutConstraint(item: secondsTensDigit, attribute: .left,
relatedBy: .equal,
toItem: self, attribute: .centerX,
multiplier: 1,
constant: horizontalSpacing),
NSLayoutConstraint(item: secondsTensDigit, attribute: .width,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 50),
NSLayoutConstraint(item: secondsTensDigit, attribute: .height,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 80),
// minutes ones digit
NSLayoutConstraint(item: minutesOnesDigit, attribute: .top,
relatedBy: .equal,
toItem: self, attribute: .centerY,
multiplier: 1,
constant: verticalSpacing),
NSLayoutConstraint(item: minutesOnesDigit, attribute: .right,
relatedBy: .equal,
toItem: self, attribute: .centerX,
multiplier: 1,
constant: -horizontalSpacing),
NSLayoutConstraint(item: minutesOnesDigit, attribute: .width,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 50),
NSLayoutConstraint(item: minutesOnesDigit, attribute: .height,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 80),
// minutes tens digit
NSLayoutConstraint(item: minutesTensDigit, attribute: .top,
relatedBy: .equal,
toItem: self, attribute: .centerY,
multiplier: 1,
constant: verticalSpacing),
NSLayoutConstraint(item: minutesTensDigit, attribute: .right,
relatedBy: .equal,
toItem: self, attribute: .centerX,
multiplier: 1,
constant: -horizontalSpacing - 60),
NSLayoutConstraint(item: minutesTensDigit, attribute: .width,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 50),
NSLayoutConstraint(item: minutesTensDigit, attribute: .height,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 80),
// hours ones digit
NSLayoutConstraint(item: hoursOnesDigit, attribute: .bottom,
relatedBy: .equal,
toItem: self, attribute: .centerY,
multiplier: 1,
constant: -verticalSpacing),
NSLayoutConstraint(item: hoursOnesDigit, attribute: .left,
relatedBy: .equal,
toItem: self, attribute: .centerX,
multiplier: 1,
constant: horizontalSpacing + 60),
NSLayoutConstraint(item: hoursOnesDigit, attribute: .width,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 50),
NSLayoutConstraint(item: hoursOnesDigit, attribute: .height,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 80),
// hours tens digit
NSLayoutConstraint(item: hoursTensDigit, attribute: .bottom,
relatedBy: .equal,
toItem: self, attribute: .centerY,
multiplier: 1,
constant: -verticalSpacing),
NSLayoutConstraint(item: hoursTensDigit, attribute: .left,
relatedBy: .equal,
toItem: self, attribute: .centerX,
multiplier: 1,
constant: horizontalSpacing),
NSLayoutConstraint(item: hoursTensDigit, attribute: .width,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 50),
NSLayoutConstraint(item: hoursTensDigit, attribute: .height,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 80),
// days ones digit
NSLayoutConstraint(item: daysOnesDigit, attribute: .bottom,
relatedBy: .equal,
toItem: self, attribute: .centerY,
multiplier: 1,
constant: -verticalSpacing),
NSLayoutConstraint(item: daysOnesDigit, attribute: .right,
relatedBy: .equal,
toItem: self, attribute: .centerX,
multiplier: 1,
constant: -horizontalSpacing),
NSLayoutConstraint(item: daysOnesDigit, attribute: .width,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 50),
NSLayoutConstraint(item: daysOnesDigit, attribute: .height,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 80),
// days tens digit
NSLayoutConstraint(item: daysTensDigit, attribute: .bottom,
relatedBy: .equal,
toItem: self, attribute: .centerY,
multiplier: 1,
constant: -verticalSpacing),
NSLayoutConstraint(item: daysTensDigit, attribute: .right,
relatedBy: .equal,
toItem: self, attribute: .centerX,
multiplier: 1,
constant: -horizontalSpacing - 60),
NSLayoutConstraint(item: daysTensDigit, attribute: .width,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 50),
NSLayoutConstraint(item: daysTensDigit, attribute: .height,
relatedBy: .equal,
toItem: nil, attribute: .notAnAttribute,
multiplier: 1,
constant: 80)
]
}
private var labelConstraints: [NSLayoutConstraint] {
return [
// seconds
NSLayoutConstraint(item: secondsLabel, attribute: .left,
relatedBy: .equal,
toItem: secondsTensDigit, attribute: .left,
multiplier: 1,
constant: 0),
NSLayoutConstraint(item: secondsLabel, attribute: .top,
relatedBy: .equal,
toItem: secondsTensDigit, attribute: .bottom,
multiplier: 1,
constant: 2),
// minutes
NSLayoutConstraint(item: minutesLabel, attribute: .left,
relatedBy: .equal,
toItem: minutesTensDigit, attribute: .left,
multiplier: 1,
constant: 0),
NSLayoutConstraint(item: minutesLabel, attribute: .top,
relatedBy: .equal,
toItem: minutesTensDigit, attribute: .bottom,
multiplier: 1,
constant: 2),
// hours
NSLayoutConstraint(item: hoursLabel, attribute: .left,
relatedBy: .equal,
toItem: hoursTensDigit, attribute: .left,
multiplier: 1,
constant: 0),
NSLayoutConstraint(item: hoursLabel, attribute: .top,
relatedBy: .equal,
toItem: hoursTensDigit, attribute: .bottom,
multiplier: 1,
constant: 2),
// days
NSLayoutConstraint(item: daysLabel, attribute: .left,
relatedBy: .equal,
toItem: daysTensDigit, attribute: .left,
multiplier: 1,
constant: 0),
NSLayoutConstraint(item: daysLabel, attribute: .top,
relatedBy: .equal,
toItem: daysTensDigit, attribute: .bottom,
multiplier: 1,
constant: 2)
]
}
// MARK: - Accessibility
private static let dateComponentsFormatter: DateComponentsFormatter = {
let formatter = DateComponentsFormatter()
formatter.allowedUnits = [.day, .hour, .minute, .second]
formatter.allowsFractionalUnits = false
formatter.includesTimeRemainingPhrase = true
formatter.unitsStyle = .full
return formatter
}()
override var isAccessibilityElement: Bool {
get {
return true
} set {}
}
override var accessibilityLabel: String? {
get {
return NSLocalizedString("I/O 2019 countdown.",
comment: "Localized accessibility label for the I/O countdown animation")
} set {}
}
override var accessibilityValue: String? {
get {
let timeInterval = timeLeftUntilTargetDate()
let timeRemainingString =
CountdownView.dateComponentsFormatter.string(from: timeInterval)
return timeRemainingString
} set {}
}
override var accessibilityTraits: UIAccessibilityTraits {
get {
return UIAccessibilityTraits.updatesFrequently
} set {}
}
override func accessibilityActivate() -> Bool {
return false
}
}
|
apache-2.0
|
a9a798a1228819d2e71364c811566f02
| 35.2288 | 113 | 0.564943 | 5.278089 | false | false | false | false |
qinting513/SwiftNote
|
swift写的计算器/Calculator能算开方/Calculator/ViewController.swift
|
2
|
1560
|
//
// ViewController.swift
// Calculator
//
// Created by Qinting on 2016/12/3.
// Copyright © 2016年 QT. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
///结果显示
@IBOutlet private weak var displayLabel: UILabel!
/// 为了去除刚开始的0
private var userIsInTheMiddleTyping = false
///数字按钮的点击
@IBAction private func touchDigit(_ sender: UIButton) {
let digit = sender.currentTitle!
if userIsInTheMiddleTyping {
let textCurrentlyInDisplay = displayLabel.text
displayLabel.text = textCurrentlyInDisplay! + digit
}else {
displayLabel.text = digit
}
userIsInTheMiddleTyping = true
}
//计算属性 存储结果值
private var displayValue : Double {
/// 获取值
get{
return Double(displayLabel.text!)!
}
/// 当有值的时候 给label赋值
set {
displayLabel.text = String(newValue)
}
}
private var brain = CalculatorBrain()
/// 点击了 加减乘除等运算符 按钮
@IBAction private func performOperation(_ sender: UIButton) {
if userIsInTheMiddleTyping {
brain.setOperand(operand: displayValue)
userIsInTheMiddleTyping = false
}
if let mathematicalSymbol = sender.currentTitle {
brain.performOperation(symbol: mathematicalSymbol)
}
displayValue = brain.result
}
}
|
apache-2.0
|
85e6488f057cfa4d5e18e14254f1001a
| 23.183333 | 65 | 0.598208 | 4.935374 | false | false | false | false |
slavapestov/swift
|
test/1_stdlib/NSValueBridging.swift
|
4
|
1268
|
//===--- NSValueBridging.swift - Test bridging through NSValue ------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
//
// XFAIL: interpret
// REQUIRES: objc_interop
import StdlibUnittest
// Also import modules which are used by StdlibUnittest internally. This
// workaround is needed to link all required libraries in case we compile
// StdlibUnittest with -sil-serialize-all.
import SwiftPrivate
#if _runtime(_ObjC)
import ObjectiveC
#endif
import Foundation
var nsValueBridging = TestSuite("NSValueBridging")
nsValueBridging.test("NSRange") {
let nsValue = _bridgeToObjectiveC(NSRange(location: 17, length: 19)) as! NSValue
let swiftValue: NSRange = _forceBridgeFromObjectiveC(nsValue, NSRange.self)
expectEqual(17, swiftValue.location)
expectEqual(19, swiftValue.length)
}
runAllTests()
|
apache-2.0
|
899980bd65d6f89403b6c04d94fbb213
| 30.7 | 82 | 0.702681 | 4.480565 | false | true | false | false |
kstaring/swift
|
test/SILGen/toplevel.swift
|
4
|
3290
|
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen %s | %FileCheck %s
func markUsed<T>(_ t: T) {}
func trap() -> Never {
fatalError()
}
// CHECK-LABEL: sil @main
// CHECK: bb0({{%.*}} : $Int32, {{%.*}} : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
// -- initialize x
// CHECK: alloc_global @_Tv8toplevel1xSi
// CHECK: [[X:%[0-9]+]] = global_addr @_Tv8toplevel1xSi : $*Int
// CHECK: integer_literal $Builtin.Int2048, 999
// CHECK: store {{.*}} to [trivial] [[X]]
var x = 999
func print_x() {
markUsed(x)
}
// -- assign x
// CHECK: integer_literal $Builtin.Int2048, 0
// CHECK: assign {{.*}} to [[X]]
// CHECK: [[PRINT_X:%[0-9]+]] = function_ref @_TF8toplevel7print_xFT_T_ :
// CHECK: apply [[PRINT_X]]
x = 0
print_x()
// <rdar://problem/19770775> Deferred initialization of let bindings rejected at top level in playground
// CHECK: alloc_global @_Tv8toplevel5countSi
// CHECK: [[COUNTADDR:%[0-9]+]] = global_addr @_Tv8toplevel5countSi : $*Int
// CHECK-NEXT: [[COUNTMUI:%[0-9]+]] = mark_uninitialized [var] [[COUNTADDR]] : $*Int
let count: Int
// CHECK: cond_br
if x == 5 {
count = 0
// CHECK: assign {{.*}} to [[COUNTMUI]]
// CHECK: br [[MERGE:bb[0-9]+]]
} else {
count = 10
// CHECK: assign {{.*}} to [[COUNTMUI]]
// CHECK: br [[MERGE]]
}
// CHECK: [[MERGE]]:
// CHECK: load [trivial] [[COUNTMUI]]
markUsed(count)
var y : Int
func print_y() {
markUsed(y)
}
// -- assign y
// CHECK: alloc_global @_Tv8toplevel1ySi
// CHECK: [[Y1:%[0-9]+]] = global_addr @_Tv8toplevel1ySi : $*Int
// CHECK: [[Y:%[0-9]+]] = mark_uninitialized [var] [[Y1]]
// CHECK: assign {{.*}} to [[Y]]
// CHECK: [[PRINT_Y:%[0-9]+]] = function_ref @_TF8toplevel7print_yFT_T_
y = 1
print_y()
// -- treat 'guard' vars as locals
// CHECK-LABEL: function_ref toplevel.A.__allocating_init
// CHECK: switch_enum {{%.+}} : $Optional<A>, case #Optional.some!enumelt.1: [[SOME_CASE:.+]], default
// CHECK: [[SOME_CASE]]([[VALUE:%.+]] : $A):
// CHECK: store [[VALUE]] to [init] [[BOX:%.+]] : $*A
// CHECK-NOT: destroy_value
// CHECK: [[SINK:%.+]] = function_ref @_TF8toplevel8markUsedurFxT_
// CHECK-NOT: destroy_value
// CHECK: apply [[SINK]]<A>({{%.+}})
class A {}
guard var a = Optional(A()) else { trap() }
markUsed(a)
// CHECK: alloc_global @_Tv8toplevel21NotInitializedIntegerSi
// CHECK-NEXT: [[VARADDR:%[0-9]+]] = global_addr @_Tv8toplevel21NotInitializedIntegerSi
// CHECK-NEXT: [[VARMUI:%[0-9]+]] = mark_uninitialized [var] [[VARADDR]] : $*Int
// CHECK-NEXT: mark_function_escape [[VARMUI]] : $*Int
// <rdar://problem/21753262> Bug in DI when it comes to initialization of global "let" variables
let NotInitializedInteger : Int
func fooUsesUninitializedValue() {
_ = NotInitializedInteger
}
fooUsesUninitializedValue()
NotInitializedInteger = 10
fooUsesUninitializedValue()
// CHECK: [[RET:%[0-9]+]] = struct $Int32
// CHECK: return [[RET]]
// CHECK-LABEL: sil hidden @_TF8toplevel7print_xFT_T_
// CHECK-LABEL: sil hidden @_TF8toplevel7print_yFT_T_
// CHECK: sil hidden @_TF8toplevel13testGlobalCSEFT_Si
// CHECK-NOT: global_addr
// CHECK: %0 = global_addr @_Tv8toplevel1xSi : $*Int
// CHECK-NOT: global_addr
// CHECK: return
func testGlobalCSE() -> Int {
// We should only emit one global_addr in this function.
return x + x
}
|
apache-2.0
|
eb19a010716886c35d536ca81f48e350
| 25.532258 | 104 | 0.635258 | 3.095014 | false | false | false | false |
brentsimmons/Evergreen
|
Shared/ArticleStyles/ArticleThemeDownloader.swift
|
1
|
3886
|
//
// ArticleThemeDownloader.swift
// ArticleThemeDownloader
//
// Created by Stuart Breckenridge on 20/09/2021.
// Copyright © 2021 Ranchero Software. All rights reserved.
//
import Foundation
import Zip
public class ArticleThemeDownloader {
public enum ArticleThemeDownloaderError: LocalizedError {
case noThemeFile
public var errorDescription: String? {
switch self {
case .noThemeFile:
return "There is no NetNewsWire theme available."
}
}
}
public static let shared = ArticleThemeDownloader()
private init() {}
public func handleFile(at location: URL) throws {
createDownloadDirectoryIfRequired()
let movedFileLocation = try moveTheme(from: location)
let unzippedFileLocation = try unzipFile(at: movedFileLocation)
NotificationCenter.default.post(name: .didEndDownloadingTheme, object: nil, userInfo: ["url" : unzippedFileLocation])
}
/// Creates `Application Support/NetNewsWire/Downloads` if needed.
private func createDownloadDirectoryIfRequired() {
try? FileManager.default.createDirectory(at: downloadDirectory(), withIntermediateDirectories: true, attributes: nil)
}
/// Moves the downloaded `.tmp` file to the `downloadDirectory` and renames it a `.zip`
/// - Parameter location: The temporary file location.
/// - Returns: Destination `URL`.
private func moveTheme(from location: URL) throws -> URL {
var tmpFileName = location.lastPathComponent
tmpFileName = tmpFileName.replacingOccurrences(of: ".tmp", with: ".zip")
let fileUrl = downloadDirectory().appendingPathComponent("\(tmpFileName)")
try FileManager.default.moveItem(at: location, to: fileUrl)
return fileUrl
}
/// Unzips the zip file
/// - Parameter location: Location of the zip archive.
/// - Returns: Enclosed `.nnwtheme` file.
private func unzipFile(at location: URL) throws -> URL {
do {
let unzipDirectory = URL(fileURLWithPath: location.path.replacingOccurrences(of: ".zip", with: ""))
try Zip.unzipFile(location, destination: unzipDirectory, overwrite: true, password: nil, progress: nil, fileOutputHandler: nil) // Unzips to folder in Application Support/NetNewsWire/Downloads
try FileManager.default.removeItem(at: location) // Delete zip in Cache
let themeFilePath = findThemeFile(in: unzipDirectory.path)
if themeFilePath == nil {
throw ArticleThemeDownloaderError.noThemeFile
}
return URL(fileURLWithPath: unzipDirectory.appendingPathComponent(themeFilePath!).path)
} catch {
try? FileManager.default.removeItem(at: location)
throw error
}
}
/// Performs a deep search of the unzipped directory to find the theme file.
/// - Parameter searchPath: directory to search
/// - Returns: optional `String`
private func findThemeFile(in searchPath: String) -> String? {
if let directoryContents = FileManager.default.enumerator(atPath: searchPath) {
while let file = directoryContents.nextObject() as? String {
if file.hasSuffix(".nnwtheme") {
return file
}
}
}
return nil
}
/// The download directory used by the theme downloader: `Application Support/NetNewsWire/Downloads`
/// - Returns: `URL`
private func downloadDirectory() -> URL {
FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!.appendingPathComponent("NetNewsWire/Downloads", isDirectory: true)
}
/// Removes downloaded themes, where themes == folders, from `Application Support/NetNewsWire/Downloads`.
public func cleanUp() {
guard let filenames = try? FileManager.default.contentsOfDirectory(atPath: downloadDirectory().path) else {
return
}
for path in filenames {
do {
if FileManager.default.isFolder(atPath: downloadDirectory().appendingPathComponent(path).path) {
try FileManager.default.removeItem(atPath: downloadDirectory().appendingPathComponent(path).path)
}
} catch {
print(error)
}
}
}
}
|
mit
|
627fef49617601b7215aa6d9bdac3dab
| 34.972222 | 195 | 0.740283 | 4.072327 | false | false | false | false |
arthurhammer/Rulers
|
Rulers/Utilities/StatusItem+Utils.swift
|
1
|
771
|
import Cocoa
extension NSStatusBar {
static func addStatusItem(withLength length: CGFloat = NSVariableStatusItemLength) -> NSStatusItem {
return system().statusItem(withLength: length)
}
}
extension NSMenu {
func addItems(_ items: [NSMenuItem]) {
items.forEach(addItem)
}
}
extension NSMenuItem {
convenience init(title: String,
target: AnyObject? = nil,
action: Selector? = nil,
keyEquivalent: String? = nil) {
self.init(title: title, action: action, keyEquivalent: keyEquivalent ?? "")
self.target = target
}
var selected: Bool {
get { return state == NSOnState }
set { state = newValue ? NSOnState : NSOffState }
}
}
|
mit
|
a05d029166c6a1bfd677027d868ad55f
| 23.09375 | 104 | 0.597925 | 4.879747 | false | false | false | false |
TouchInstinct/LeadKit
|
TIUIElements/Sources/Wrappers/EdgeConstraints.swift
|
1
|
2444
|
//
// Copyright (c) 2022 Touch Instinct
//
// 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 UIKit
public struct EdgeConstraints {
public let leadingConstraint: NSLayoutConstraint
public let trailingConstraint: NSLayoutConstraint
public let topConstraint: NSLayoutConstraint
public let bottomConstraint: NSLayoutConstraint
public var allConstraints: [NSLayoutConstraint] {
[
leadingConstraint,
trailingConstraint,
topConstraint,
bottomConstraint
]
}
public init(leadingConstraint: NSLayoutConstraint,
trailingConstraint: NSLayoutConstraint,
topConstraint: NSLayoutConstraint,
bottomConstraint: NSLayoutConstraint) {
self.leadingConstraint = leadingConstraint
self.trailingConstraint = trailingConstraint
self.topConstraint = topConstraint
self.bottomConstraint = bottomConstraint
}
public func activate() {
NSLayoutConstraint.activate(allConstraints)
}
public func deactivate() {
NSLayoutConstraint.deactivate(allConstraints)
}
public func update(from insets: UIEdgeInsets) {
leadingConstraint.constant = insets.left
trailingConstraint.constant = -insets.right
topConstraint.constant = insets.top
bottomConstraint.constant = -insets.bottom
}
}
|
apache-2.0
|
6490377d636ceed651ff7998c85d5c09
| 36.6 | 81 | 0.717676 | 5.443207 | false | false | false | false |
mcgraw/dojo-instruments
|
instruments/TimeProfile.swift
|
1
|
3166
|
//
// TimeProfile.swift
// instruments
//
// Created by David McGraw on 1/26/15.
// Copyright (c) 2015 David McGraw. All rights reserved.
//
import UIKit
class TimeProfile: UIViewController {
// MARK: - IBOutlets
@IBOutlet weak var status: UILabel!
// MARK: - Public Properties
/// A list containing the data used for sorting
var numberList = [Int]()
/// A dedicated queue for the session
var sessionQueue = DispatchQueue(label: "session", attributes: [])
// MARK: - Lifecycle
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
status.text = "Generating random numbers"
sessionStep { (message) -> Void in
self.status.text = message
}
}
// MARK: - Private Methods
/**
Steps through a series of methods that sorts a series of random numbers. Observe
the effects in Instruments
*/
fileprivate func sessionStep(_ status: @escaping (_ message: String) -> Void) {
sessionQueue.async {
self.generateRandomNumbers(500)
DispatchQueue.main.async {
status("Insertion Sort")
}
self.insertionSort()
DispatchQueue.main.async {
status("Done. Generating new numbers")
}
self.generateRandomNumbers(500)
DispatchQueue.main.async {
status("Bubble Sort")
}
self.bubbleSort()
DispatchQueue.main.async {
status("Done")
}
}
}
/**
Generates a random list of numbers that are stored in `numberList`
*/
fileprivate func generateRandomNumbers(_ total: Int) {
for _ in 0 ..< total {
let rand = Int(arc4random() % 100000)
numberList.append(rand)
}
}
/**
Perfroms an insertion sort on the numbers contained in `numberList`
*/
fileprivate func insertionSort() {
var b = numberList
for i in 1..<b.count {
var y = i
while y > 0 && b[y] < b[y - 1] {
swap(&b[y - 1], &b[y])
y -= 1
}
}
numberList = b
}
/**
Perfroms a bubble sort on the numbers contained in `numberList`
*/
fileprivate func bubbleSort() {
var z, passes, key : Int
for x in 0..<numberList.count {
passes = (numberList.count - 1) - x;
for y in 0..<passes {
key = numberList[y]
if (key > numberList[y + 1]) {
z = numberList[y + 1]
numberList[y + 1] = key
numberList[y] = z
}
}
}
}
}
|
mit
|
3d4502a86ba502c2c6f098e6e7bd2993
| 22.109489 | 85 | 0.455464 | 5.294314 | false | false | false | false |
forgo/BabySync
|
bbsync/mobile/iOS/Baby Sync/Baby Sync/AuthCustom.swift
|
1
|
2967
|
//
// AuthCustom.swift
// SignInBase
//
// Created by Elliott Richerson on 10/25/15.
// Copyright © 2015 Elliott Richerson. All rights reserved.
//
import Alamofire
import UIKit
// MARK: - AuthCustomDelegate Protocol
protocol AuthCustomDelegate {
func didLogin(_ jwt: String, email: String)
func didEncounterLogin(_ errorsAPI: [ErrorAPI])
}
// MARK: - Custom Info Struct
struct AuthCustomInfo {
var userId: String = ""
var accessToken: String = ""
var name: String = ""
var email: String = ""
var pic: UIImage = AuthConstant.Default.ProfilePic
init() {
self.userId = ""
self.accessToken = ""
self.name = ""
self.email = ""
self.pic = AuthConstant.Default.ProfilePic
}
}
// MARK: - AuthCustom
class AuthCustom: NSObject, AuthAppMethod, AuthMethod, AuthCustomDelegate {
// Singleton
static let sharedInstance = AuthCustom()
fileprivate override init() {
self.info = AuthCustomInfo()
}
// Auth method classes invokes AuthDelegate methods to align SDK differences
var delegate: AuthDelegate?
// To keep track of internally until login process resolves
var info: AuthCustomInfo
// MARK: - AuthAppMethod Protocol
func configure(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [AnyHashable: Any]?) -> Bool {
return true
}
func openURL(_ application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return true
}
// MARK: - AuthMethod Protocol
func isLoggedIn() -> Bool {
return false
}
func login(_ email: String?, password: String?) {
if let e = email, let p = password {
BabySync.service.login(.Custom, email: e, password: p, accessToken: nil)
}
else {
let errorRef = AuthConstant.Error.Client.BadEmailOrPassword.self
let error: ErrorAPI = ErrorAPI(code: errorRef.code, message: errorRef.message)
let nsError: Error? = BabySync.errorFrom(error)
self.delegate?.loginError(.Custom, error: nsError)
}
}
func logout() {
// TODO: implement custom logout
self.delegate?.didLogout(.Custom)
}
// MARK: - AuthCustomDelegate
func didLogin(_ jwt: String, email: String) {
let authUser = AuthUser(service: .Custom, userId: "", accessToken: "", name: "Some Person", email: email, pic: AuthConstant.Default.ProfilePic, jwt: jwt)
self.delegate?.loginSuccess(.Custom, user: authUser, wasAlreadyLoggedIn: false)
}
func didEncounterLogin(_ errorsAPI: [ErrorAPI]) {
// TODO: Do we need to take into account errors past one if they exist?
if(errorsAPI.count > 0) {
let e: Error? = BabySync.errorFrom(errorsAPI[0])
self.delegate?.loginError(.Custom, error: e)
}
}
}
|
mit
|
be3c3c503c46c3816e2f99227578982b
| 29.895833 | 161 | 0.630816 | 4.30479 | false | false | false | false |
coderMONSTER/iosstar
|
iOSStar/Model/ShareDataModel/ShareDataModel.swift
|
1
|
1140
|
//
// ShareDataModel.swift
// iOSStar
//
// Created by sum on 2017/4/24.
// Copyright © 2017年 YunDian. All rights reserved.
//
import UIKit
class ShareDataModel: NSObject {
private static var model: ShareDataModel = ShareDataModel()
class func share() -> ShareDataModel{
return model
}
var wechatUserInfo = [String:String]()
dynamic var isweichaLogin : Bool = false
var phone : String = ""
var codeToeken : String = ""
dynamic var selectMonth : String = ""
var isReturnBackClick : Bool = false
var orderInfo : OrderInformation?
var isShowInWindows : Bool = false
var registerModel: RegisterRequestModel = RegisterRequestModel()
var wxregisterModel: WXRegisterRequestModel = WXRegisterRequestModel()
var controlSwitch: Bool = true
var buttonExtOnceSwitch = true
}
class OrderInformation: NSObject {
var orderAllPrice : String = ""
var orderAccount : String = ""
var orderPrice : String = ""
var orderStatus : String = ""
var orderInfomation : String = ""
var ordertitlename : String = "订单详情"
}
|
gpl-3.0
|
e1cc366e19bbc08b02077ade3d0bdcbd
| 27.225 | 74 | 0.660762 | 4.32567 | false | false | false | false |
subinspathilettu/SJRefresh
|
SJRefresh/Classes/UIImage+Gif.swift
|
1
|
2355
|
//
// UIImage+Gif.swift
// Pods
//
// Created by Subins Jose on 16/11/16.
// Copyright © 2016 Subins Jose. All rights reserved.
//
// 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 UIKit
import ImageIO
extension UIImage {
class func imagesFromGif(_ name: String) -> [UIImage]? {
// Check for existance of gif
guard let bundleURL = Bundle.main
.url(forResource: name, withExtension: "gif") else {
print("This image named \"\(name)\" does not exist")
return nil
}
return UIImage.imagesFromGifURL(bundleURL)
}
class func imagesFromGifURL(_ url: URL) -> [UIImage]? {
// Validate data
guard let imageData = try? Data(contentsOf: url) else {
print("Cannot turn image named \"\(url)\" into NSData")
return nil
}
return UIImage.imagesFromGifData(imageData)
}
class func imagesFromGifData(_ data: Data) -> [UIImage]? {
// Create source from data
guard let source = CGImageSourceCreateWithData(data as CFData, nil) else {
print("Source for the image does not exist")
return nil
}
let count = CGImageSourceGetCount(source)
var images = [UIImage]()
// Fill arrays
for index in 0..<count {
// Add image
if let image = CGImageSourceCreateImageAtIndex(source, index, nil) {
images.append(UIImage(cgImage: image))
}
}
return images
}
}
|
mit
|
7a326681aa9e48e6b7562eab6ea1ad9d
| 31.246575 | 99 | 0.715378 | 3.976351 | false | false | false | false |
slavapestov/swift
|
test/SourceKit/DocSupport/Inputs/cake.swift
|
4
|
607
|
public protocol Prot {
associatedtype Element
var p : Int { get }
func foo()
}
public class C1 : Prot {
public typealias Element = Int
public var p : Int = 0
public func foo() {}
public subscript(index: Int) -> Int { return 0 }
public subscript(index i: Float) -> Int { return 0 }
}
public func genfoo<T1 : Prot, T2 : C1 where T1.Element == Int, T2.Element == T1.Element>(x ix: T1, y iy: T2) {}
public extension Prot where Self.Element == Int {
final func extfoo() {}
}
public enum MyEnum : Int {
case Blah
}
protocol Prot1 {}
typealias C1Alias = C1
extension C1Alias : Prot1 {}
|
apache-2.0
|
a36ccaeb776ce06833a7ad54c86e1585
| 19.233333 | 111 | 0.654036 | 3.21164 | false | false | false | false |
laonayt/NewFreshBeen-Swift
|
WEFreshBeen/Classes/Base/Extension/UIImage + Extension.swift
|
1
|
1769
|
//
// UIImage + Extension.swift
// LoveFreshBeen
//
// Created by 维尼的小熊 on 16/1/12.
// Copyright © 2016年 tianzhongtao. All rights reserved.
// GitHub地址:https://github.com/ZhongTaoTian/LoveFreshBeen
// Blog讲解地址:http://www.jianshu.com/p/879f58fe3542
// 小熊的新浪微博:http://weibo.com/5622363113/profile?topnav=1&wvr=6
import UIKit
extension UIImage {
class func imageWithColor(color: UIColor, size: CGSize, alpha: CGFloat) -> UIImage {
let rect = CGRectMake(0, 0, size.width, size.height)
UIGraphicsBeginImageContext(rect.size)
let ref = UIGraphicsGetCurrentContext()
CGContextSetAlpha(ref, alpha)
CGContextSetFillColorWithColor(ref, color.CGColor)
CGContextFillRect(ref, rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
class func createImageFromView(view: UIView) -> UIImage {
UIGraphicsBeginImageContext(view.bounds.size);
view.layer.renderInContext(UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image
}
func imageClipOvalImage() -> UIImage {
UIGraphicsBeginImageContextWithOptions(self.size, false, 0.0)
let ctx = UIGraphicsGetCurrentContext()
let rect = CGRectMake(0, 0, self.size.width, self.size.height)
CGContextAddEllipseInRect(ctx, rect)
CGContextClip(ctx)
self.drawInRect(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
}
|
apache-2.0
|
90fa049cb98877e39323fb69347a33ec
| 30.454545 | 88 | 0.65896 | 4.859551 | false | false | false | false |
schrockblock/gtfs-stations
|
Pod/Classes/NYCRouteColorManager.swift
|
1
|
3498
|
//
// RouteColorManager.swift
// GTFS Stations
//
// Created by Elliot Schrock on 7/26/15.
// Copyright (c) 2015 Elliot Schrock. All rights reserved.
//
import UIKit
import SubwayStations
open class NYCRouteColorManager: NSObject, RouteColorManager {
@objc open func colorForRouteId(_ routeId: String!) -> UIColor {
var color: UIColor = UIColor(rgba: "#2F4F4F")
if ["1","2","3"].contains(routeId) {
color = UIColor(rgba: "#ED3B43")
}
if ["4","5","5X","6","6X"].contains(routeId) {
color = UIColor(rgba: "#00A55E")
}
if ["7","7X"].contains(routeId) {
color = UIColor(rgba: "#A23495")
}
if ["A","C","E"].contains(routeId) {
color = UIColor(rgba: "#006BB7")
}
if ["B","D","F","M"].contains(routeId) {
color = UIColor(rgba: "#F58120")
}
if routeId == "G" {
color = UIColor(rgba: "#6CBE45")
}
if routeId == "L" {
color = UIColor(rgba: "#2F4F4F")
}
if ["N","Q","R","W"].contains(routeId) {
color = UIColor(rgba: "#FFD51D")
}
if ["J","Z","JZ"].contains(routeId) {
color = UIColor(rgba: "#B1730E")
}
return color
}
}
extension UIColor {
@objc public convenience init(rgba: String) {
var red: CGFloat = 0.0
var green: CGFloat = 0.0
var blue: CGFloat = 0.0
var alpha: CGFloat = 1.0
if rgba.hasPrefix("#") {
let index = rgba.index(rgba.startIndex, offsetBy: 1)
let hex = String(rgba.suffix(from: index))
let scanner = Scanner(string: hex)
var hexValue: CUnsignedLongLong = 0
if scanner.scanHexInt64(&hexValue) {
switch (hex.count) {
case 3:
red = CGFloat((hexValue & 0xF00) >> 8) / 15.0
green = CGFloat((hexValue & 0x0F0) >> 4) / 15.0
blue = CGFloat(hexValue & 0x00F) / 15.0
case 4:
red = CGFloat((hexValue & 0xF000) >> 12) / 15.0
green = CGFloat((hexValue & 0x0F00) >> 8) / 15.0
blue = CGFloat((hexValue & 0x00F0) >> 4) / 15.0
alpha = CGFloat(hexValue & 0x000F) / 15.0
case 6:
red = CGFloat((hexValue & 0xFF0000) >> 16) / 255.0
green = CGFloat((hexValue & 0x00FF00) >> 8) / 255.0
blue = CGFloat(hexValue & 0x0000FF) / 255.0
case 8:
red = CGFloat((hexValue & 0xFF000000) >> 24) / 255.0
green = CGFloat((hexValue & 0x00FF0000) >> 16) / 255.0
blue = CGFloat((hexValue & 0x0000FF00) >> 8) / 255.0
alpha = CGFloat(hexValue & 0x000000FF) / 255.0
default:
print("Invalid RGB string, number of characters after '#' should be either 3, 4, 6 or 8", terminator: "")
}
} else {
print("Scan hex error")
}
} else {
print("Invalid RGB string, missing '#' as prefix", terminator: "")
}
self.init(red:red, green:green, blue:blue, alpha:alpha)
}
}
|
mit
|
149004e2ebf7ca34e3ddbad647350fa3
| 33.98 | 125 | 0.455975 | 3.961495 | false | false | false | false |
itsaboutcode/WordPress-iOS
|
WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationContentRouter.swift
|
1
|
3989
|
struct NotificationContentRouter {
private let coordinator: ContentCoordinator
private let notification: Notification
private let expirationFiveMinutes = TimeInterval(60 * 5)
init(activity: Notification, coordinator: ContentCoordinator) {
self.coordinator = coordinator
self.notification = activity
}
func routeTo(_ url: URL) {
guard let range = getRange(with: url) else {
return
}
do {
try displayContent(of: range, with: url)
} catch {
coordinator.displayWebViewWithURL(url)
}
}
/// Route to the controller that best represents the notification source.
///
/// - Throws: throws if the notification doesn't have a resource URL
///
func routeToNotificationSource() throws {
guard let fallbackURL = notification.resourceURL else {
throw DefaultContentCoordinator.DisplayError.missingParameter
}
do {
try displayNotificationSource()
} catch {
coordinator.displayWebViewWithURL(fallbackURL)
}
}
func routeTo(_ image: UIImage) {
coordinator.displayFullscreenImage(image)
}
private func displayNotificationSource() throws {
switch notification.kind {
case .follow:
try coordinator.displayStreamWithSiteID(notification.metaSiteID)
case .like:
fallthrough
case .matcher:
fallthrough
case .newPost:
fallthrough
case .post:
try coordinator.displayReaderWithPostId(notification.metaPostID, siteID: notification.metaSiteID)
case .comment:
fallthrough
case .commentLike:
// Focus on the primary comment, and default to the reply ID if its set
let commentID = notification.metaCommentID ?? notification.metaReplyID
try coordinator.displayCommentsWithPostId(notification.metaPostID,
siteID: notification.metaSiteID,
commentID: commentID)
default:
throw DefaultContentCoordinator.DisplayError.unsupportedType
}
}
private func displayContent(of range: FormattableContentRange, with url: URL) throws {
guard let range = range as? NotificationContentRange else {
throw DefaultContentCoordinator.DisplayError.missingParameter
}
switch range.kind {
case .site:
try coordinator.displayStreamWithSiteID(range.siteID)
case .post:
try coordinator.displayReaderWithPostId(range.postID, siteID: range.siteID)
case .comment:
// Focus on the comment reply if it's set over the primary comment ID
let commentID = notification.metaReplyID ?? notification.metaCommentID
try coordinator.displayCommentsWithPostId(range.postID, siteID: range.siteID, commentID: commentID)
case .stats:
/// Backup notifications are configured as "stat" notifications
/// For now this is just a workaround to fix the routing
if url.absoluteString.matches(regex: "\\/backup\\/").count > 0 {
try coordinator.displayBackupWithSiteID(range.siteID)
} else {
try coordinator.displayStatsWithSiteID(range.siteID, url: url)
}
case .follow:
try coordinator.displayFollowersWithSiteID(range.siteID, expirationTime: expirationFiveMinutes)
case .user:
try coordinator.displayStreamWithSiteID(range.siteID)
case .scan:
try coordinator.displayScanWithSiteID(range.siteID)
default:
throw DefaultContentCoordinator.DisplayError.unsupportedType
}
}
private func getRange(with url: URL) -> FormattableContentRange? {
return notification.contentRange(with: url)
}
}
|
gpl-2.0
|
1a5d80e44ac38d045323f860b26bdbb2
| 37.355769 | 111 | 0.631988 | 5.434605 | false | false | false | false |
Merlini93/Weibo
|
Weibo/Weibo/Classes/Home/Popover/PopoverAnimator.swift
|
1
|
2718
|
//
// PopoverAnimator.swift
// Weibo
//
// Created by 李遨东 on 16/9/9.
// Copyright © 2016年 Merlini. All rights reserved.
//
import UIKit
let kPopoverAnimatorWillShow = "PopoverAnimatorWillShow"
let kPopoverAnimatorWillDismiss = "PopoverAnimatorWillDismiss"
class PopoverAnimator: NSObject, UIViewControllerTransitioningDelegate,UIViewControllerAnimatedTransitioning{
var isPresent: Bool = false
var presentFrame = CGRectZero
func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController?{
let pc = PopoverPresentationController(presentedViewController: presented, presentingViewController: presenting)
pc.presentFrame = presentFrame
return pc
}
func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
isPresent = true
NSNotificationCenter.defaultCenter().postNotificationName(kPopoverAnimatorWillShow, object: self)
return self
}
func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
isPresent = false
NSNotificationCenter.defaultCenter().postNotificationName(kPopoverAnimatorWillDismiss, object: self)
return self
}
func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
return 0.3
}
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
if isPresent {
let view = transitionContext.viewForKey(UITransitionContextToViewKey)
transitionContext.containerView()?.addSubview(view!)
view?.transform = CGAffineTransformMakeScale(1.0, 0.0)
view?.layer.anchorPoint = CGPoint(x: 0.5, y: 0)
UIView.animateWithDuration(transitionDuration(transitionContext), animations: {
view?.transform = CGAffineTransformIdentity
}) { (_) in
transitionContext.completeTransition(true)
}
} else {
let view = transitionContext.viewForKey(UITransitionContextFromViewKey)
UIView.animateWithDuration(transitionDuration(transitionContext), animations: {
view?.transform = CGAffineTransformMakeScale(1.0, 0.01)
}, completion: { (_) in
transitionContext.completeTransition(true)
})
}
}
}
|
mit
|
f798bbd676f3165873ecab79dd4794e0
| 42.693548 | 218 | 0.716131 | 6.543478 | false | false | false | false |
itsaboutcode/WordPress-iOS
|
WordPress/Classes/ViewRelated/Post/PostEditor+BlogPicker.swift
|
1
|
4500
|
import UIKit
extension PostEditor where Self: UIViewController {
func blogPickerWasPressed() {
assert(isSingleSiteMode == false)
// if it's a reblog, we won't change the content, so don't show the alert
guard !postIsReblogged, post.hasSiteSpecificChanges() else {
displayBlogSelector()
return
}
displaySwitchSiteAlert()
}
func displayBlogSelector() {
guard let sourceView = navigationBarManager.blogPickerButton.imageView else {
fatalError()
}
// Setup Handlers
let successHandler: BlogSelectorSuccessHandler = { selectedObjectID in
self.dismiss(animated: true)
WPAnalytics.track(.editorPostSiteChanged)
guard let blog = self.mainContext.object(with: selectedObjectID) as? Blog else {
return
}
self.recreatePostRevision(in: blog)
self.mediaLibraryDataSource = MediaLibraryPickerDataSource(post: self.post)
}
let dismissHandler: BlogSelectorDismissHandler = {
self.dismiss(animated: true)
}
// Setup Picker
let selectorViewController = BlogSelectorViewController(selectedBlogObjectID: post.blog.objectID,
successHandler: successHandler,
dismissHandler: dismissHandler)
// Note:
// On iPad Devices, we'll disable the Picker's SearchController's "Autohide Navbar Feature", since
// upon dismissal, it may force the NavigationBar to show up, even when it was initially hidden.
selectorViewController.displaysNavigationBarWhenSearching = WPDeviceIdentification.isiPad()
if postIsReblogged {
selectorViewController.displaysOnlyDefaultAccountSites = true
}
// Setup Navigation
let navigationController = AdaptiveNavigationController(rootViewController: selectorViewController)
navigationController.configurePopoverPresentationStyle(from: sourceView)
// Done!
present(navigationController, animated: true)
}
func displaySwitchSiteAlert() {
let alert = UIAlertController(title: SwitchSiteAlert.title, message: SwitchSiteAlert.message, preferredStyle: .alert)
alert.addDefaultActionWithTitle(SwitchSiteAlert.acceptTitle) { _ in
self.displayBlogSelector()
}
alert.addCancelActionWithTitle(SwitchSiteAlert.cancelTitle)
present(alert, animated: true)
}
// TODO: Rip this and put it into PostService, as well
func recreatePostRevision(in blog: Blog) {
let shouldCreatePage = post is Page
let postService = PostService(managedObjectContext: mainContext)
let newPost = shouldCreatePage ? postService.createDraftPage(for: blog) : postService.createDraftPost(for: blog)
// if it's a reblog, use the existing content and don't strip the image
newPost.content = postIsReblogged ? post.content : contentByStrippingMediaAttachments()
newPost.postTitle = post.postTitle
newPost.password = post.password
newPost.dateCreated = post.dateCreated
newPost.dateModified = post.dateModified
newPost.status = post.status
if let source = post as? Post, let target = newPost as? Post {
target.tags = source.tags
}
discardChanges()
post = newPost
createRevisionOfPost()
RecentSitesService().touch(blog: blog)
// TODO: Add this snippet, if needed, once we've relocated this helper to PostService
//[self syncOptionsIfNecessaryForBlog:blog afterBlogChanged:YES];
}
}
private struct SwitchSiteAlert {
static let title = NSLocalizedString("Change Site", comment: "Title of an alert prompting the user that they are about to change the blog they are posting to.")
static let message = NSLocalizedString("Choosing a different site will lose edits to site specific content like media and categories. Are you sure?", comment: "And alert message warning the user they will loose blog specific edits like categories, and media if they change the blog being posted to.")
static let acceptTitle = NSLocalizedString("OK", comment: "Accept Action")
static let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel Action")
}
|
gpl-2.0
|
f205e4839910d6f5300fef43ab76682a
| 43.117647 | 321 | 0.664 | 5.501222 | false | false | false | false |
jeroendesloovere/examples-swift
|
Swift-Playgrounds/ControlFlow.playground/section-1.swift
|
1
|
6279
|
// Control Flow Chapter
for index in 1...5 {
println("\(index) times 5 is \(index * 5)")
}
let base = 3
let power = 10
var answer = 1
for _ in 1...power {
answer *= base
}
let names = ["Anna", "Alex", "Brian", "Jack"]
for name in names {
println("Hello, \(name)!")
}
let numberOfLegs = ["spider": 8, "ant": 6, "cat": 4]
for (animalName, legCount) in numberOfLegs {
println("\(animalName)s have \(legCount) legs")
}
for character in "Hello" {
println(character)
}
for var index = 0; index < 3; ++index {
println("index = \(index)")
}
var index: Int
for index = 0; index < 3; ++index {
println("index is \(index)")
}
println("The loop statements were executed \(index) times")
let finalSquare = 25
var board = [Int](count: finalSquare + 1, repeatedValue: 0)
board[03] = +08; board[06] = +11; board[09] = +09; board[10] = +02
board[14] = -10; board[19] = -11; board[22] = -02; board[24] = -08
var square = 0
var diceRoll = 0
while square < finalSquare {
// roll the dice
if ++diceRoll == 7 { diceRoll = 1 }
// move by the rolled amount
square += diceRoll
if square < board.count {
// if we're still on the board, move up or down for a snake or a ladder
square += board[square]
}
}
println("Game over!")
square = 0
diceRoll = 0
do {
// move up or down for a snake or ladder
square += board[square]
// roll the dice
if ++diceRoll == 7 { diceRoll = 1 }
// move by the rolled amount
square += diceRoll
} while square < finalSquare
println("Game over!")
// If
var temperatureInFarenheit = 30
if temperatureInFarenheit <= 32 {
println("It's very cold. Consider wearing a scarf")
}
temperatureInFarenheit = 40
if temperatureInFarenheit <= 32 {
println("It's very cold. Consider wearing a scarf")
} else {
println("It's not that cold. wear a t-shirt.")
}
temperatureInFarenheit = 90
if temperatureInFarenheit <= 32 {
println("It's very cold. Consider wearing a scarf")
} else if temperatureInFarenheit >= 86 {
println("It's really warm. Don't forget to wear sunscreen.")
} else {
println("It's not that cold. wear a t-shirt.")
}
temperatureInFarenheit = 72
if temperatureInFarenheit <= 32 {
println("It's very cold. Consider wearing a scarf")
} else if temperatureInFarenheit >= 86 {
println("It's really warm. Don't forget to wear sunscreen.")
}
// Switch
let someCharacter: Character = "e"
switch someCharacter {
case "a", "e", "i", "o", "u":
println("\(someCharacter) is a vowel")
case "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z":
println("\(someCharacter) is a consonant")
default:
println("\(someCharacter) is not a vowel or consonant")
}
let anotherCharacter: Character = "a"
switch anotherCharacter {
//case "a": // Not valid if this line is in place as no executble line for this case statement.
case "A":
println("The letter A")
default:
println("Not the letter A")
}
// Range Matching
let count = 3_000_000_000_000
let countedThings = "stars in the Milky Way"
var naturalCount: String
switch count {
case 0:
naturalCount = "no"
case 1...3:
naturalCount = "a few"
case 4...9:
naturalCount = "several"
case 10...99:
naturalCount = "tens of"
case 100...999:
naturalCount = "hundreds of"
case 1000...999_999:
naturalCount = "thousands of"
default:
naturalCount = "millions and millions of"
}
println("There are \(naturalCount) \(countedThings).")
// Tuples
let somePoint = (1,1)
switch somePoint {
case (0, 0):
println("(0,0) is at the origin")
case (_, 0):
println("\(somePoint.0),0) is on the x-axis")
case (0, _):
println("(0, \(somePoint.1)) is on the y-axis")
case (-2...2, -2...2):
println("(\(somePoint.0, somePoint.1)) is inside the box")
default:
println("(\(somePoint.0, somePoint.1)) is outside of the box")
}
// Value Bindings
let anotherPoint = (2, 0)
switch anotherPoint {
case (let x, 0):
println("on the x-axis with an x value of \(x)")
case (0, let y):
println("on the y-axis with a y value of \(y)")
case let (x, y):
println("somewhare else at (\(x), \(y))")
}
// Where
let yetAnotherPoint = (1, -1)
switch yetAnotherPoint {
case let (x, y) where x == y:
println("(\(x), \(y)) is on the line x == y")
case let (x, y) where x == -y:
println("(\(x), \(y)) is on the line x == -y")
case let (x, y):
println("(\(x), \(y)) is just some arbitrary point")
}
// Control Transfer Statements
// Continue
let puzzleInput = "great minds think alike"
var puzzleOutput = ""
for character in puzzleInput {
switch character {
case "a", "e", "i", "o", "u", " ":
continue
default:
puzzleOutput.append(character)
}
}
puzzleOutput
// Break
let numberSymbol: Character = "三" // Simplified Chinese for the number 3”
var possibleIntegerValue: Int?
switch numberSymbol {
case "1", "١", "一", "๑":
possibleIntegerValue = 1
case "2", "٢", "二", "๒":
possibleIntegerValue = 2
case "3", "٣", "三", "๓":
possibleIntegerValue = 3
case "4", "٤", "四", "๔":
possibleIntegerValue = 4
default:
break
}
if let integerValue = possibleIntegerValue {
println("The integer value of \(numberSymbol) is \(integerValue).")
} else {
println("An integer value could not be found for \(numberSymbol).")
}
// Fallthrough
let integerToDescribe = 5
var description = "The number \(integerToDescribe) is"
switch integerToDescribe {
case 2, 3, 5, 7, 11, 13, 17, 19:
description += " a prime number, and also"
fallthrough
default:
description += " an integer."
}
println(description)
// Labelled Statements
square = 0
diceRoll = 0
board = [Int](count: finalSquare + 1, repeatedValue: 0)
board[03] = +08; board[06] = +11; board[09] = +09; board[10] = +02
board[14] = -10; board[19] = -11; board[22] = -02; board[24] = -08
gameLoop: while square != finalSquare {
if ++diceRoll == 7 { diceRoll = 1}
switch square + diceRoll {
case finalSquare:
break gameLoop
case let newSquare where newSquare > finalSquare:
continue gameLoop
default:
square += diceRoll
square += board[square]
}
}
println("Game over!")
|
mit
|
2ae0d84144fa55ce7da456d19c2ad61b
| 23.433594 | 113 | 0.622702 | 3.290373 | false | false | false | false |
edopelawi/CascadingTableDelegate
|
Example/CascadingTableDelegate/AppDelegate.swift
|
1
|
1189
|
//
// AppDelegate.swift
// CascadingTableDelegate
//
// Created by Ricardo Pramana Suranta on 08/01/2016.
// Copyright (c) 2016 Ricardo Pramana Suranta. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let windowFrame = UIScreen.main.bounds
window = UIWindow(frame: windowFrame)
let welcomeViewController = WelcomeViewController()
let rootNavController = UINavigationController(rootViewController: welcomeViewController)
window?.rootViewController = rootNavController
window?.makeKeyAndVisible()
return true
}
func applicationWillResignActive(_ application: UIApplication) {
}
func applicationDidEnterBackground(_ application: UIApplication) {
}
func applicationWillEnterForeground(_ application: UIApplication) {
}
func applicationDidBecomeActive(_ application: UIApplication) {
}
func applicationWillTerminate(_ application: UIApplication) {
}
}
|
mit
|
07834d6a1e31771969199cea8894cf30
| 21.433962 | 145 | 0.738436 | 5.608491 | false | false | false | false |
jpush/jchat-swift
|
JChat/Src/ChatModule/Chat/Model/JCRemind.swift
|
1
|
551
|
//
// JCRemind.swift
// JChat
//
// Created by JIGUANG on 2017/7/19.
// Copyright © 2017年 HXHG. All rights reserved.
//
import UIKit
class JCRemind: NSObject {
var user: JMSGUser?
var startIndex: Int
var endIndex: Int
var length: Int
var isAtAll: Bool
init(_ user: JMSGUser?, _ startIndex: Int, _ endIndex: Int, _ length: Int, _ isAtAll: Bool) {
self.user = user
self.startIndex = startIndex
self.endIndex = endIndex
self.length = length
self.isAtAll = isAtAll
}
}
|
mit
|
af322259c13a23c3315111a192dcb933
| 20.92 | 97 | 0.604015 | 3.558442 | false | false | false | false |
dannys42/DTSImage
|
Sources/DTSImageRGBAF+Algorithms.swift
|
1
|
5610
|
//
// DTSImageRGBAF+Algorithms.swift
// Pods
//
// Created by Danny Sung on 12/04/2016.
//
//
import Foundation
import Accelerate
public extension DTSImageRGBAF {
/// Generate a new image by applying a PlanarF mask to the current image
///
/// The mask is applied to every component in the source image:
/// NewImage = self * mask
///
/// The receiving image and the passed image *must* have the same dimensions. The behavior is otherwise undefined.
///
/// - Parameter mask: Planar Float
/// - Returns: A new image in RGBAF format
public func applying(mask: DTSImagePlanarF) -> DTSImageRGBAF {
var destImage = DTSImageRGBAF(width: self.width, height: self.height)
for componentNdx in 0..<DTSImageRGBAF.numberOfComponentsPerPixel {
self.pixels.withUnsafeBufferPointer{ srcBufferPtr in
let srcPixels = srcBufferPtr.baseAddress!.advanced(by: componentNdx)
destImage.pixels.withUnsafeMutableBufferPointer{ dstBufferPtr in
let dstPixels = dstBufferPtr.baseAddress!.advanced(by: componentNdx)
vDSP_vmul(srcPixels, DTSImageRGBAF.numberOfComponentsPerPixel,
mask.pixels, 1,
dstPixels, DTSImageRGBAF.numberOfComponentsPerPixel,
UInt(self.numPixels))
}
}
}
return destImage
}
/// Create new image by multiplying receiver by the passed image
///
/// result = self * image
///
/// - Parameter image: image contents to multiply
/// - Returns: A enw image in RGBAF format
public func multiplying(image: DTSImageRGBAF) -> DTSImageRGBAF {
var destImage = DTSImageRGBAF(width: self.width, height: self.height)
destImage.pixels.withUnsafeMutableBufferPointer{ dstBufferPtr in
let dstPixels = dstBufferPtr.baseAddress!
let length = UInt(self.numberOfComponentsPerImage)
vDSP_vmul(self.pixels, 1, image.pixels, 1,
dstPixels, 1,
length)
}
return destImage
}
/// Creates a new image that compares the vector distance between the receiving image and the given image.
///
/// The receiving image and the passed image *must* have the same dimensions. The behavior is otherwise undefined.
///
/// result = (self - image)^2
/// - Parameter image: an image to calculate the vector distance with
/// - Returns: The resulting image to create
public func calculatingDistanceSquared(image: DTSImageRGBAF) -> DTSImageRGBAF {
var destImage = DTSImageRGBAF(width: self.width, height: self.height)
destImage.pixels.withUnsafeMutableBufferPointer{ dstBufferPtr in
let dstPixels = dstBufferPtr.baseAddress!
let length = UInt(self.numberOfComponentsPerImage)
vDSP_distancesq(self.pixels, 1, image.pixels, 1, dstPixels, length)
}
return destImage
}
/// Subtract the current image with contents of passed image
///
/// Note: result = self - image
///
/// - Parameter image: Image contents to subtract
/// - Returns: resulting image
public func subtracting(image: DTSImageRGBAF) -> DTSImageRGBAF {
var destImage = DTSImageRGBAF(width: self.width, height: self.height)
let minLength = min(self.numberOfComponentsPerImage, image.numberOfComponentsPerImage)
let length = UInt(minLength)
self.withUnsafePointerToComponents { inPixelsA in
image.withUnsafePointerToComponents { inPixelsB in
destImage.withUnsafeMutablePointerToComponents { dstPixels in
vDSP_vsub(inPixelsB, 1,
inPixelsA, 1,
dstPixels, 1,
length)
}
}
}
return destImage
}
/// Subtract 2 images, placing the result in the receiver
///
/// self = image1 - image 2
///
/// - Parameters:
/// - image1: Image to subtract from
/// - image2: Image components to subtract
/// - Returns: Number of components subtracted
public mutating func subtract(image1: DTSImageRGBAF, image2: DTSImageRGBAF, maxComponents: UInt = UInt.max) -> Int {
let minLength = min(self.numberOfComponentsPerImage,
image1.numberOfComponentsPerImage,
image2.numberOfComponentsPerImage,
Int(maxComponents))
let length = UInt(minLength)
image1.withUnsafePointerToComponents { inPixelsA in
image2.withUnsafePointerToComponents { inPixelsB in
self.withUnsafeMutablePointerToComponents { dstPixels in
vDSP_vsub(inPixelsB, 1,
inPixelsA, 1,
dstPixels, 1,
length)
}
}
}
return minLength
}
/// Inverts the value of each component in an image.
///
/// Note: result = 1.0 - self
///
/// - Returns: Resulting image
public func invertingValue() -> DTSImageRGBAF {
let oneImage = DTSImageRGBAF(width: self.width, height: self.height, fill: .white)
let dstImage = self.subtracting(image: oneImage)
return dstImage
}
}
|
mit
|
ab95de3b47ec739bf100a8949169efce
| 37.424658 | 120 | 0.591087 | 5.03139 | false | false | false | false |
vector-im/vector-ios
|
Riot/Modules/Room/ReactionHistory/ReactionHistoryViewModel.swift
|
1
|
6112
|
// File created from ScreenTemplate
// $ createScreen.sh ReactionHistory ReactionHistory
/*
Copyright 2019 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import Foundation
final class ReactionHistoryViewModel: ReactionHistoryViewModelType {
// MARK: - Constants
private enum Pagination {
static let count: UInt = 30
}
// MARK: - Properties
// MARK: Private
private let session: MXSession
private let roomId: String
private let eventId: String
private let aggregations: MXAggregations
private let eventFormatter: MXKEventFormatter
private let reactionsFormattingQueue: DispatchQueue
private var reactionHistoryViewDataList: [ReactionHistoryViewData] = []
private var operation: MXHTTPOperation?
private var nextBatch: String?
private var viewState: ReactionHistoryViewState?
private lazy var roomMembers: MXRoomMembers? = {
return buildRoomMembers()
}()
// MARK: Public
weak var viewDelegate: ReactionHistoryViewModelViewDelegate?
weak var coordinatorDelegate: ReactionHistoryViewModelCoordinatorDelegate?
// MARK: - Setup
init(session: MXSession, roomId: String, eventId: String) {
self.session = session
self.aggregations = session.aggregations
self.roomId = roomId
self.eventId = eventId
self.eventFormatter = EventFormatter(matrixSession: session)
self.reactionsFormattingQueue = DispatchQueue(label: "\(type(of: self)).reactionsFormattingQueue")
}
// MARK: - Public
func process(viewAction: ReactionHistoryViewAction) {
switch viewAction {
case .loadMore:
self.loadMoreHistory()
case .close:
self.coordinatorDelegate?.reactionHistoryViewModelDidClose(self)
}
}
// MARK: - Private
private func canLoadMoreHistory() -> Bool {
guard let viewState = self.viewState else {
return true
}
let canLoadMoreHistory: Bool
switch viewState {
case .loading:
canLoadMoreHistory = false
case .loaded(reactionHistoryViewDataList: _, allDataLoaded: let allDataLoaded):
canLoadMoreHistory = !allDataLoaded
default:
canLoadMoreHistory = true
}
return canLoadMoreHistory
}
private func loadMoreHistory() {
guard self.canLoadMoreHistory() else {
MXLog.debug("[ReactionHistoryViewModel] loadMoreHistory: pending loading or all data loaded")
return
}
guard self.operation == nil else {
MXLog.debug("[ReactionHistoryViewModel] loadMoreHistory: operation already pending")
return
}
self.update(viewState: .loading)
self.operation = self.aggregations.reactionsEvents(forEvent: self.eventId, inRoom: self.roomId, from: self.nextBatch, limit: Int(Pagination.count), success: { [weak self] (response) in
guard let self = self else {
return
}
self.nextBatch = response.nextBatch
self.operation = nil
self.process(reactionEvents: response.chunk, nextBatch: response.nextBatch)
}, failure: { [weak self] error in
guard let self = self else {
return
}
self.operation = nil
self.update(viewState: .error(error))
})
}
private func process(reactionEvents: [MXEvent], nextBatch: String?) {
self.reactionsFormattingQueue.async {
let reactionHistoryList = reactionEvents.compactMap { (reactionEvent) -> ReactionHistoryViewData? in
return self.reactionHistoryViewData(from: reactionEvent)
}
self.reactionHistoryViewDataList.append(contentsOf: reactionHistoryList)
let allDataLoaded = nextBatch == nil
DispatchQueue.main.async {
self.update(viewState: .loaded(reactionHistoryViewDataList: self.reactionHistoryViewDataList, allDataLoaded: allDataLoaded))
}
}
}
private func reactionHistoryViewData(from reactionEvent: MXEvent) -> ReactionHistoryViewData? {
guard let userId = reactionEvent.sender,
let reaction = reactionEvent.relatesTo?.key,
let reactionDateString = self.eventFormatter.dateString(fromTimestamp: reactionEvent.originServerTs, withTime: true) else {
return nil
}
let userDisplayName = self.userDisplayName(from: userId) ?? userId
return ReactionHistoryViewData(reaction: reaction, userDisplayName: userDisplayName, dateString: reactionDateString)
}
private func userDisplayName(from userId: String) -> String? {
guard let roomMembers = self.roomMembers else {
return nil
}
let roomMember = roomMembers.member(withUserId: userId)
return roomMember?.displayname
}
private func buildRoomMembers() -> MXRoomMembers? {
guard let room = self.session.room(withRoomId: self.roomId) else {
return nil
}
return room.dangerousSyncState?.members
}
private func update(viewState: ReactionHistoryViewState) {
self.viewState = viewState
self.viewDelegate?.reactionHistoryViewModel(self, didUpdateViewState: viewState)
}
}
|
apache-2.0
|
6dcd6c38381b64f556605fc20651b73d
| 33.145251 | 192 | 0.643488 | 5.521229 | false | false | false | false |
vector-im/vector-ios
|
Riot/Routers/NavigationRouterStore.swift
|
1
|
4453
|
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import WeakDictionary
/// `NavigationRouterStore` enables to get a NavigationRouter from a UINavigationController instance.
class NavigationRouterStore: NavigationRouterStoreProtocol {
// MARK: - Constants
static let shared = NavigationRouterStore()
// MARK: - Properties
// FIXME: WeakDictionary does not work with protocol
// Find a way to use NavigationRouterType as value
private var navigationRouters = WeakDictionary<UINavigationController, NavigationRouter>()
// MARK: - Setup
/// As we are ensuring that there is only one navigation controller per NavigationRouter, the class here should be used as a singleton.
private init() {
self.registerNavigationRouterNotifications()
}
// MARK: - Public
func navigationRouter(for navigationController: UINavigationController) -> NavigationRouterType {
if let existingNavigationRouter = self.findNavigationRouter(for: navigationController) {
return existingNavigationRouter
}
let navigationRouter = NavigationRouter(navigationController: RiotNavigationController())
return navigationRouter
}
// MARK: - Private
private func findNavigationRouter(for navigationController: UINavigationController) -> NavigationRouterType? {
return self.navigationRouters[navigationController]
}
private func removeNavigationRouter(for navigationController: UINavigationController) {
self.navigationRouters[navigationController] = nil
}
private func registerNavigationRouterNotifications() {
NotificationCenter.default.addObserver(self, selector: #selector(navigationRouterDidCreate(_:)), name: NavigationRouter.didCreate, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(navigationRouterWillDestroy(_:)), name: NavigationRouter.willDestroy, object: nil)
}
@objc private func navigationRouterDidCreate(_ notification: Notification) {
guard let userInfo = notification.userInfo,
let navigationRouter = userInfo[NavigationRouter.NotificationUserInfoKey.navigationRouter] as? NavigationRouterType,
let navigationController = userInfo[NavigationRouter.NotificationUserInfoKey.navigationController] as? UINavigationController else {
return
}
if let existingNavigationRouter = self.findNavigationRouter(for: navigationController) {
fatalError("\(existingNavigationRouter) is already tied to the same navigation controller as \(navigationRouter). We should have only one NavigationRouter per navigation controller")
} else {
// FIXME: WeakDictionary does not work with protocol
// Find a way to avoid this cast
self.navigationRouters[navigationController] = navigationRouter as? NavigationRouter
}
}
@objc private func navigationRouterWillDestroy(_ notification: Notification) {
guard let userInfo = notification.userInfo,
let navigationRouter = userInfo[NavigationRouter.NotificationUserInfoKey.navigationRouter] as? NavigationRouterType,
let navigationController = userInfo[NavigationRouter.NotificationUserInfoKey.navigationController] as? UINavigationController else {
return
}
if let existingNavigationRouter = self.findNavigationRouter(for: navigationController), existingNavigationRouter !== navigationRouter {
fatalError("\(existingNavigationRouter) is already tied to the same navigation controller as \(navigationRouter). We should have only one NavigationRouter per navigation controller")
}
self.removeNavigationRouter(for: navigationController)
}
}
|
apache-2.0
|
02b75944c52de5d3b8133379ee755e15
| 44.907216 | 194 | 0.724231 | 5.913679 | false | false | false | false |
johnnyclem/Swift-Roster
|
Swift Roster/DetailViewController.swift
|
1
|
2973
|
//
// DetailViewController.swift
// Swift Roster
//
// Created by John Clem on 6/3/14.
// Copyright (c) 2014 Code Fellows. All rights reserved.
//
import UIKit
class DetailViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
var selectedPerson = Person()
@IBOutlet var twitterTextField : UITextField
@IBOutlet var githubTextField : UITextField
@IBOutlet var imageView : UIImageView
override func viewDidLoad() {
super.viewDidLoad()
let imageTap = UITapGestureRecognizer(target: self, action: NSSelectorFromString("imagePressed"))
self.imageView.addGestureRecognizer(imageTap)
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.title = selectedPerson.fullName()
self.twitterTextField.text = selectedPerson.twitter
self.githubTextField.text = selectedPerson.github
if self.selectedPerson.image {
self.imageView.image = self.selectedPerson.image!
}
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
self.selectedPerson.twitter = self.twitterTextField.text
self.selectedPerson.github = self.githubTextField.text
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func setSelectedPerson(person : Person) {
selectedPerson = person
}
func imagePressed(){
var imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.allowsEditing = true
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
self.presentViewController(imagePicker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController!,
didFinishPickingMediaWithInfo info: NSDictionary!){
let originalImage = info[UIImagePickerControllerOriginalImage] as UIImage
self.imageView.image = originalImage
self.selectedPerson.image = originalImage
self.selectedPerson.hasImage = true
self.saveImageToDocumentsDirectory(originalImage)
self.dismissViewControllerAnimated(true, completion: nil)
}
func saveImageToDocumentsDirectory(image : UIImage) {
var pngData = UIImagePNGRepresentation(image)
let filePath = self.pathForDocumentDirectory() + "/\(self.selectedPerson.fullName()).png"
pngData.writeToFile(filePath, atomically: true)
}
func pathForDocumentDirectory() ->String {
let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true) as String[]
let documentsDirectory = paths[0]
println(documentsDirectory)
return documentsDirectory
}
}
|
mit
|
4c8af7b60dfb855d181d359c3e33b43e
| 36.1625 | 153 | 0.704675 | 5.728324 | false | false | false | false |
honghaoz/CrackingTheCodingInterview
|
Swift/LeetCode/Dynamic Programming/97_Interleaving String.swift
|
1
|
4240
|
// 97_Interleaving String
// https://leetcode.com/problems/interleaving-string
//
// Created by Honghao Zhang on 10/3/19.
// Copyright © 2019 Honghaoz. All rights reserved.
//
// Description:
// Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.
//
//Example 1:
//
//Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"
//Output: true
//Example 2:
//
//Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc"
//Output: false
//
import Foundation
class Num97 {
// MARK: Recursive
// The idea is straightforward: If s3 can be composed with s1 and s2, the first char of s3 must
// be equal to s1[0] or s2[0], if it's matched
// then we stripe it from both string and call with the rest string.
func isInterleave(_ s1: String, _ s2: String, _ s3: String) -> Bool {
return isInterleaveHelper(Array(s1), Array(s2), Array(s3))
}
func isInterleaveHelper(_ s1: [Character], _ s2: [Character], _ s3: [Character]) -> Bool {
guard s1.count > 0 else {
return s2 == s3
}
guard s2.count > 0 else {
return s1 == s3
}
guard s3.count > 0 else {
return s1.count == 0 && s2.count == 0
}
if s1[0] == s3[0] && s2[0] == s3[0] {
return isInterleaveHelper(s1[1...].array, s2, s3[1...].array) || isInterleaveHelper(s1, s2[1...].array, s3[1...].array)
}
else if s1[0] == s3[0] {
return isInterleaveHelper(s1[1...].array, s2, s3[1...].array)
}
else if s2[0] == s3[0] {
return isInterleaveHelper(s1, s2[1...].array, s3[1...].array)
}
else {
// no match, can't interleave
return false
}
}
// MARK: Recursive, slightly efficient
func isInterleave2(_ s1: String, _ s2: String, _ s3: String) -> Bool {
return isInterleaveHelper2(Array(s1), 0, Array(s2), 0, Array(s3), 0)
}
// i is the start index
func isInterleaveHelper2(_ s1: [Character], _ i1: Int, _ s2: [Character], _ i2: Int, _ s3: [Character], _ i3: Int) -> Bool {
guard i1 < s1.count else {
return s2[i2...] == s3[i3...]
}
guard i2 < s2.count else {
return s1[i1...] == s3[i3...]
}
guard i3 < s3.count else {
return i1 == s1.count && i2 == s2.count
}
if s1[i1] == s3[i3] && s2[i2] == s3[i3] {
return isInterleaveHelper2(s1, i1 + 1, s2, i2, s3, i3 + 1) || isInterleaveHelper2(s1, i1, s2, i2 + 1, s3, i3 + 1)
}
else if s1[i1] == s3[i3] {
return isInterleaveHelper2(s1, i1 + 1, s2, i2, s3, i3 + 1)
}
else if s2[i2] == s3[i3] {
return isInterleaveHelper2(s1, i1, s2, i2 + 1, s3, i3 + 1)
}
else {
// no match, can't interleave
return false
}
}
// MARK: - DP solution
// 2d array to represent if s1 prefix and s2 prefix can interleave s3 prefix
func isInterleave_DP(_ s1: String, _ s2: String, _ s3: String) -> Bool {
guard s1.count > 0 else {
return s2 == s3
}
guard s2.count > 0 else {
return s1 == s3
}
guard s3.count > 0 else {
return s1.count == 0 && s2.count == 0
}
guard s3.count == s1.count + s2.count else {
return false
}
// state
// s[i][j] represents if s1[0..<i] and s2[0..<j] can compose s3[0..<(i + j)]
var s: [[Bool]] = Array(repeating: Array(repeating: false, count: s2.count + 1), count: s1.count + 1)
// initialize
s[0][0] = true
for i in 1...s1.count {
// if s1[0..<i] is equal to s3[0..<i]
s[i][0] = s1[0..<i] == s3[0..<i]
}
for j in 1...s2.count {
// if s2[0..<i] is equal to s3[0..<j]
s[0][j] = s2[0..<j] == s3[0..<j]
}
// function
// s[i][j] == s[]
for i in 1...s1.count {
for j in 1...s2.count {
// if last char in s1 == s3, this is matched, check if s[i - 1][j]
if s1[i - 1] == s3[i + j - 1] {
s[i][j] = s[i][j] || s[i - 1][j] // If s[i][j] is true, keep it.
}
// if last char in s2 == s3, this is matched, check if s[i - 1][j]
if s2[j - 1] == s3[i + j - 1] {
s[i][j] = s[i][j] || s[i][j - 1]
}
}
}
// answer
return s[s1.count][s2.count]
}
}
extension ArraySlice where Element == Character {
var array: [Character] {
return Array(self)
}
}
|
mit
|
976665f9907517b1174a0e1726e74eb3
| 28.234483 | 126 | 0.535032 | 2.729556 | false | false | false | false |
emilletfr/domo-server-vapor
|
Sources/App/ViewModel/ThermostatViewModel.swift
|
2
|
10264
|
//
// ThermostatViewModel.swift
// VaporApp
//
// Created by Eric on 13/01/2017.
//
//
import RxSwift
import Foundation
final class ThermostatViewModel : ThermostatViewModelable
{
//MARK: Subscribers
let currentOutdoorTemperatureObserver = PublishSubject<Double>()
let currentIndoorHumidityObserver = PublishSubject<Double>()
let currentIndoorTemperatureObserver = PublishSubject<Double>()
let targetIndoorTemperatureObserver = PublishSubject<Double>()
let currentHeatingCoolingStateObserver = PublishSubject<HeatingCoolingState>()
let targetHeatingCoolingStateObserver = PublishSubject<HeatingCoolingState>()
let forcingWaterHeaterObserver = PublishSubject<Int>()
let boilerHeatingLevelObserver = PublishSubject<Double>()
//MARK: Actions
let targetTemperaturePublisher = PublishSubject<Double>()
let targetHeatingCoolingStatePublisher = PublishSubject<HeatingCoolingState>()
let forcingWaterHeaterPublisher = PublishSubject<Int>()
//MARK: Dependencies
let outdoorTempService : OutdoorTempServicable
let indoorTempService : IndoorTempServicable
let inBedService : InBedServicable
let boilerService : BoilerServicable
var boilerHeatingLevelMemorySpan = 3600.0*24.0
var noPicDetectionDelayForBoilerTemperature : Double = 60*60
//MARK: Dispatcher
required init(outdoorTempService:OutdoorTempServicable = OutdoorTempService(), indoorTempService:IndoorTempServicable = IndoorTempService(), inBedService:InBedServicable = InBedService(), boilerService:BoilerServicable = BoilerService())
{
self.outdoorTempService = outdoorTempService
self.indoorTempService = indoorTempService
self.inBedService = inBedService
self.boilerService = boilerService
self.reduce()
}
//MARK: Reducer
func reduce()
{
//MARK: Wrap Outdoor Temperature
_ = outdoorTempService.temperatureObserver
.map{Double($0 < 0 ? 0 : $0)} // HomeKit do not support temperature < 0°C from temperature sensors
.subscribe(self.currentOutdoorTemperatureObserver)
//MARK: Wrap Indoor temperature
_ = indoorTempService.temperatureObserver
.distinctUntilChanged().debug("computedIndoorTemperature")
.map{Double($0 < 0 ? 0 : $0)} // HomeKit do not support temperature < 0°C from temperature sensors
.subscribe(self.currentIndoorTemperatureObserver)
//MARK: Wrap Indoor Humidity
_ = indoorTempService.humidityObserver
.map{Double($0)}
.subscribe(self.currentIndoorHumidityObserver)
//MARK: Wrap Force Hot Water Observer
_ = forcingWaterHeaterPublisher.debug("forceHotWaterPublisher")
.subscribe(forcingWaterHeaterObserver)
// Compute target temp following isInBed, target cooling state
let computedTargetTemp = Observable<Double>.combineLatest(inBedService.isInBedObserver, targetTemperaturePublisher, targetHeatingCoolingStatePublisher, resultSelector: { (isInbed:Bool, targetTemp:Double, targetHeatingCoolingState:HeatingCoolingState) -> Double in
if isInbed == true {return targetTemp - 2}
if targetHeatingCoolingState == .OFF {return 7}
return targetTemp})
.distinctUntilChanged()
//MARK: Wrap Thermostat Temperature
_ = computedTargetTemp.debug("computedTargetTemperature")
.map {Double($0 < 10 ? 10 : $0)} // HomeKit do not support thermostat target temperature < 10
.subscribe(self.targetIndoorTemperatureObserver)
//MARK: Wrap Heater's Boiler
let computedBoilerHeating = Observable<Bool>.combineLatest(targetHeatingCoolingStatePublisher, outdoorTempService.temperatureObserver, computedTargetTemp, forcingWaterHeaterPublisher) { (targetHeatingCooling:HeatingCoolingState, outdoorTemp:Double, computedTargetTemp:Double, forcingWaterHeater:Int ) in
if forcingWaterHeater == 1 {return true}
else {return targetHeatingCooling != .OFF && outdoorTemp < Double(computedTargetTemp)}}
_ = computedBoilerHeating
.distinctUntilChanged()
.throttle(60, scheduler: ConcurrentDispatchQueueScheduler(qos: .default)).debug("heaterPublisher")
.subscribe(boilerService.heaterPublisher)
//MARK: Wrap Pomp's Boiler
let computedBoilerPomping = Observable<Bool>
.combineLatest(computedBoilerHeating, indoorTempService.temperatureObserver, computedTargetTemp)
{(computedBoilerHeating:Bool, computedIndoorTemp:Double, computedTargetTemp:Double) in
return computedIndoorTemp < Double(computedTargetTemp) && computedBoilerHeating == true
}.distinctUntilChanged()
_ = computedBoilerPomping
.throttle(60, scheduler: ConcurrentDispatchQueueScheduler(qos: .default)).debug("pompPublisher")
.subscribe(boilerService.pompPublisher)
//MARK: Wrap HomeKit Heating Cooling State
let computedHeatingCoolingState = Observable<HeatingCoolingState>
.combineLatest(computedBoilerHeating, computedBoilerPomping) {(computedBoilerHeating:Bool, computedBoilerPomping:Bool) in
return computedBoilerHeating == true ? ( computedBoilerPomping ? .HEAT : .COOL ) : .OFF
}
_ = computedHeatingCoolingState.subscribe(self.currentHeatingCoolingStateObserver)
_ = computedHeatingCoolingState.subscribe(self.targetHeatingCoolingStateObserver)
// MARK: Wrap Boiler Heating Level
// IndoorTemp (°C) > Boiler Heater Level (%) - 20.0°C = 0% - 20.4°C = 100%
// Collect max values when indoor temp > 20.0, target temp = 20 and boiler is heating
// Add timestamp to collected max values and calculate average max value since last 24h
let okToCaptureInTemp = Observable<Bool>.combineLatest(computedBoilerHeating, computedTargetTemp, resultSelector:{$0 == true && $1 == 20})
let indoorTempToMaxTemp = Observable<Double?>
.combineLatest(indoorTempService.temperatureObserver, okToCaptureInTemp) { (indoorTemperature:Double, authorized:Bool) -> Double? in
return authorized == true ? indoorTemperature : nil}
.filter{$0 != nil}
.map{$0!}
.scan((nil, nil)) { (maxTemp: (new:Double?, old:Double?), indoorTemperature:Double) -> (Double?, Double?) in
var localMaxTemp = maxTemp.new
if indoorTemperature >= 20.0
{
if localMaxTemp == nil {localMaxTemp = 0.0}
localMaxTemp = indoorTemperature > localMaxTemp! ? indoorTemperature : localMaxTemp!
}
else {localMaxTemp = nil}
return (localMaxTemp, maxTemp.new)}
.map({ (maxTemp: (new:Double?, old:Double?)) -> Double? in
if maxTemp.new == nil && maxTemp.old != nil {return maxTemp.old}
else {return nil}
})
// Regulate boiler temperature
var timeStampDate = Date()
var boilerCurrentTemperature = 75.0
_ = boilerService.temperatureObserver
.distinctUntilChanged()
.debug("boilerTemperatureObserver")
.subscribe(onNext: { (temperature:Double) in boilerCurrentTemperature = temperature})
var indoorCurrentTemperature = 20.0
_ = indoorTempService.temperatureObserver
.subscribe(onNext: { (temperature:Double) in indoorCurrentTemperature = temperature})
_ = indoorTempToMaxTemp.map({ (maxIndoorTemperature:Double?) -> Double? in
var localMaxIndoorTemperature : Double? = maxIndoorTemperature
if timeStampDate.timeIntervalSinceNow < -self.noPicDetectionDelayForBoilerTemperature
{
localMaxIndoorTemperature = indoorCurrentTemperature
timeStampDate = Date()
}
if let localMaxIndoorTemperature = localMaxIndoorTemperature
{
timeStampDate = Date()
let indoorTemperatureVsSetpointDelta = localMaxIndoorTemperature - 20.2 // 50% chauffe
let boilerTemperatureDelta = indoorTemperatureVsSetpointDelta * 10.0 // 0.1 -> 1° //0.5 -> 2.5° / 0.2 -> 1° / 0.4 -> 2°
var resultBoilerTemperature = boilerCurrentTemperature - boilerTemperatureDelta
if resultBoilerTemperature < 60.0 {resultBoilerTemperature = 60.0}
if resultBoilerTemperature > 90.0 {resultBoilerTemperature = 90.0}
return resultBoilerTemperature
}
else {return nil}})
.filter{$0 != nil}.map{$0!}.debug("boilerTemperaturePublisher").subscribe(self.boilerService.temperaturePublisher)
// Add timestamp to Max Temps
var datesForMaxTemperatures = [Date: Double]()
var totalAverage = 0
let filteredDateForMaxTemperatureToTotalAverage = indoorTempToMaxTemp.map({ (maxTemperature:Double?) -> Int? in
// Remove obsoletes ones in collection
for (date,_) in datesForMaxTemperatures {
if date.timeIntervalSinceNow < -self.boilerHeatingLevelMemorySpan {datesForMaxTemperatures.removeValue(forKey: date)}}
if let maxTemperature = maxTemperature {
// Add maxTemperature to timestamped collection
datesForMaxTemperatures[Date()] = maxTemperature
// Compute average
let total = datesForMaxTemperatures.values.reduce(0.0, +)
let average = total/Double(datesForMaxTemperatures.values.count)
totalAverage = Int(round((average-20)*100/0.4))
totalAverage = (totalAverage < 0 ? 0 : (totalAverage > 100 ? 100 : totalAverage))
}
if datesForMaxTemperatures.count == 0 {totalAverage = 0}
return totalAverage
})
_ = filteredDateForMaxTemperatureToTotalAverage.filter{$0 != nil}.map{Double($0!)}.distinctUntilChanged().subscribe(boilerHeatingLevelObserver)
}
}
|
mit
|
92f53e65c521059463d8122ff97f9d2d
| 53.839572 | 311 | 0.668942 | 4.561833 | false | false | false | false |
takev/DimensionsCAM
|
DimensionsCAM/Interval.swift
|
1
|
10644
|
// DimensionsCAM - A multi-axis tool path generator for a milling machine
// Copyright (C) 2015 Take Vos
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import simd
/// An Interval.
/// This object is inspired a lot by: INTERVAL ARITHMETIC USING SSE-2 (BRANIMIR LAMBOV)
///
/// The FPU and SSE-2 need to be configured to round to negative infinty when executing many operation.
/// - see: Interval.setRoundMode()
///
struct Interval: Equatable, Hashable, Comparable, CustomStringConvertible, IntegerLiteralConvertible, FloatLiteralConvertible, ArrayLiteralConvertible, NumericOperationsType, SqrtOperationsType {
typealias Element = Double
/// The Interval is stored with the lower bound stored in the first element and
/// the upper bound stored in the second element as a negated number.
let value: double2
var low: Double {
return value.x
}
var high: Double {
return -value.y
}
var size: Double {
let previous_rounding_mode = Interval.setRoundMode(FE_UPWARD)
defer { Interval.setRoundMode(previous_rounding_mode) }
return -value.y - value.x
}
init(_ low: Double, _ high: Double) {
value = double2(low, -high)
}
init(_ range: double2) {
value = double2(range.x, -range.y)
}
init(raw: double2) {
value = raw
}
init(_ value: Double) {
self.value = double2(value, -value)
}
init(integerLiteral value: IntegerLiteralType) {
self.value = double2(Double(value), -Double(value))
}
init(floatLiteral value: FloatLiteralType) {
self.value = double2(Double(value), -Double(value))
}
init(arrayLiteral elements: Element...) {
switch (elements.count) {
case 0:
value = double2(Double.infinity, Double.infinity)
case 1:
value = double2(elements[0], -elements[0])
case 2:
value = double2(elements[0], -elements[1])
default:
preconditionFailure("Expect 0, 1 or 2 elements in a Interval literal")
}
}
var isZero: Bool {
return self == 0.0
}
var isScalar: Bool {
return value.x == -value.y
}
var isNaN: Bool {
return value.x.isNaN || value.y.isNaN
}
var isEntire: Bool {
return (
value.x.isInfinite && value.x < 0.0 &&
value.y.isInfinite && value.y < 0.0
)
}
var isEmpty: Bool {
return value.x > -value.y
}
var description: String {
if isEmpty {
return "⟨empty⟩"
} else if isEntire {
return "⟨entire⟩"
} else if isNaN {
return "⟨NaN⟩"
} else if isScalar {
return "⟨\(value.x)⟩"
} else {
return "⟨\(value.x), \(-value.y)⟩"
}
}
var hashValue: Int {
if isEmpty {
return 0
} else {
return value.x.hashValue ^ value.y.hashValue
}
}
var square: Interval {
// In a square we can make the value positive.
// That means the multiplication becomes simple and only need a signchange for one of the numbers.
let left = abs(self).value
let right = double2(left.x, -left.y)
return Interval(raw:left * right)
}
/// When you use Interval arithmatic you should first use setRoundMode()
/// to force the FPU and SSE to round to negative infinity.
///
/// Example to use at the start of a function that uses Interval arithmatic:
/// ```swift
/// let previous_round_mode = Interval.setRoundMode()
/// defer { Interval.unsetRoundMode(previous_round_mode) }
/// ```
static func setRoundMode(mode: Int32 = FE_DOWNWARD) -> Int32 {
let round_mode = fegetround()
if round_mode != mode {
fesetround(mode)
}
return round_mode
}
static func unsetRoundMode(old_round_mode: Int32) {
if old_round_mode != fegetround() {
fesetround(old_round_mode)
}
}
static func isCorrectRoundMode() -> Bool {
return fegetround() == FE_DOWNWARD
}
static var entire: Interval {
return Interval(raw: double2(-Double.infinity, -Double.infinity))
}
static var empty: Interval {
return Interval(raw: double2(Double.infinity, Double.infinity))
}
static var NaN: Interval {
return Interval(raw: double2(Double.NaN, Double.NaN))
}
}
prefix func -(rhs: Interval) -> Interval {
return Interval(raw:rhs.value.yx)
}
func +(lhs: Interval, rhs: Interval) -> Interval {
assert(Interval.isCorrectRoundMode())
return Interval(raw:lhs.value + rhs.value)
}
func -(lhs: Interval, rhs: Interval) -> Interval {
assert(Interval.isCorrectRoundMode())
return lhs + -rhs
}
func *(lhs: Interval, rhs: Interval) -> Interval {
assert(Interval.isCorrectRoundMode())
let a = (lhs.value.x >= 0.0) ? rhs.value.x : -rhs.value.y
let b = (lhs.value.y <= 0.0) ? -rhs.value.x : rhs.value.y
let c = (lhs.value.y <= 0.0) ? -rhs.value.y : rhs.value.x
let d = (lhs.value.x >= 0.0) ? rhs.value.y : -rhs.value.x
let left = double2(a, c) * lhs.value
let right = double2(b, d) * lhs.value.yx
return Interval(raw:min(left, right))
}
func recip(rhs: Interval) -> Interval {
assert(Interval.isCorrectRoundMode())
return Interval(raw:double2(-1.0, -1.0) / rhs.value.yx)
}
func /(lhs: Interval, rhs: Interval) -> Interval {
assert(Interval.isCorrectRoundMode())
if (0.0 ∈ rhs) {
return Interval.entire
} else {
return lhs * recip(rhs)
}
}
func /(lhs: Double, rhs: Interval) -> Interval {
assert(Interval.isCorrectRoundMode())
if (0.0 ∈ rhs) {
return Interval.entire
} else if (lhs == 1.0) {
return recip(rhs)
} else {
return Interval(lhs) / rhs
}
}
func abs(rhs: Interval) -> Interval {
return Interval(raw:double2(
max(0.0, rhs.value.x, rhs.value.y),
-min(rhs.value.x, rhs.value.y)
))
}
/// Greatest lower bound.
func glb(lhs: Interval, rhs: Interval) -> Interval {
return Interval(raw:double2(
min(lhs.value.x, rhs.value.x),
max(lhs.value.y, rhs.value.y)
))
}
/// Least upper bound.
func lub(lhs: Interval, rhs: Interval) -> Interval {
return Interval(raw:double2(
max(lhs.value.x, rhs.value.x),
min(lhs.value.y, rhs.value.y)
))
}
/// Intersection.
/// - return:An Interval where both Intervals intersect with each other, or a empty Interval.
func ∩(lhs: Interval, rhs: Interval) -> Interval {
return Interval(raw: max(lhs.value, rhs.value))
}
/// Hull
/// - return:An Interval that includes both Intervals completely.
func ⩂(lhs: Interval, rhs: Interval) -> Interval {
return Interval(raw:min(lhs.value, rhs.value))
}
func ==(lhs: Interval, rhs: Interval) -> Bool {
return (
(lhs.value.x == rhs.value.x && lhs.value.y == rhs.value.y) ||
(lhs.isEmpty && rhs.isEmpty)
)
}
func ⊂(lhs: Interval, rhs: Interval) -> Bool {
return lhs.value.x > rhs.value.x && lhs.value.y > rhs.value.y
}
func ⊆(lhs: Interval, rhs: Interval) -> Bool {
return lhs.value.x >= rhs.value.x && lhs.value.y >= rhs.value.y
}
func ⊃(lhs: Interval, rhs: Interval) -> Bool {
return lhs.value.x < rhs.value.x && lhs.value.y < rhs.value.y
}
func ⊇(lhs: Interval, rhs: Interval) -> Bool {
return lhs.value.x <= rhs.value.x && lhs.value.y <= rhs.value.y
}
func <(lhs: Interval, rhs: Interval) -> Bool {
return -lhs.value.y < rhs.value.x
}
func <=(lhs: Interval, rhs: Interval) -> Bool {
return -lhs.value.y <= rhs.value.x
}
func ≺(lhs: Interval, rhs: Interval) -> Bool {
return lhs.value.y > rhs.value.y
}
func ≼(lhs: Interval, rhs: Interval) -> Bool {
return lhs.value.y >= rhs.value.y
}
func >(lhs: Interval, rhs: Interval) -> Bool {
return lhs.value.x > -rhs.value.y
}
func >=(lhs: Interval, rhs: Interval) -> Bool {
return lhs.value.x >= -rhs.value.y
}
func ≻(lhs: Interval, rhs: Interval) -> Bool {
return lhs.value.x > rhs.value.x
}
func ≽(lhs: Interval, rhs: Interval) -> Bool {
return lhs.value.x >= rhs.value.x
}
func sqrt(rhs: Interval) -> Interval {
if (rhs < 0.0) {
return Interval.NaN
} else {
assert(Interval.isCorrectRoundMode())
let low = sqrt(rhs.value.x)
Interval.setRoundMode(FE_UPWARD)
let high = sqrt(-rhs.value.y)
Interval.setRoundMode()
return Interval(raw:double2(low, -high))
}
}
prefix func √(rhs: Interval) -> Interval {
return sqrt(rhs)
}
func **(lhs: Interval, rhs: Double) -> Interval {
switch (rhs) {
case 2.0:
return lhs.square
default:
preconditionFailure("Power is only implemented for 2.0")
}
}
func **(lhs: Interval, rhs: Int) -> Interval {
switch (rhs) {
case 2:
return lhs.square
default:
preconditionFailure("Power is only implemented for 2")
}
}
func ∈(lhs: Double, rhs: Interval) -> Bool {
return rhs.value.x <= lhs && lhs <= -rhs.value.y
}
func ==(lhs: Interval, rhs: Double) -> Bool {
return lhs == Interval(rhs)
}
func <(lhs: Interval, rhs: Double) -> Bool {
return lhs < Interval(rhs)
}
func <=(lhs: Interval, rhs: Double) -> Bool {
return lhs <= Interval(rhs)
}
func >(lhs: Interval, rhs: Double) -> Bool {
return lhs > Interval(rhs)
}
func >=(lhs: Interval, rhs: Double) -> Bool {
return lhs >= Interval(rhs)
}
// MARK: Operations with Double.
func *(lhs: Double, rhs: Interval) -> Interval {
return Interval(lhs) * rhs
}
func *(lhs: Interval, rhs: Double) -> Interval {
return lhs * Interval(rhs)
}
func +(lhs: Double, rhs: Interval) -> Interval {
return Interval(lhs) * rhs
}
func +(lhs: Interval, rhs: Double) -> Interval {
return lhs * Interval(rhs)
}
func /(lhs: Interval, rhs: Double) -> Interval {
return lhs / Interval(rhs)
}
|
gpl-3.0
|
96cb760c3aad49db12c9c629486bfc06
| 24.718447 | 195 | 0.608437 | 3.475238 | false | false | false | false |
emenegro/space-cells-ios
|
SpaceCells/Sources/Module/Presentation/Visuals/VerticalPosterCell.swift
|
1
|
3929
|
import UIKit
class VerticalPosterCell: UITableViewCell {
static let cellFixedHeight: CGFloat = 200
fileprivate var viewModel: PosterCellViewModel?
lazy var posterImageView: UIImageView = {
let imageView = UIImageView(frame: CGRect.zero)
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
self.addSubview(imageView)
NSLayoutConstraint.activate([
imageView.leftAnchor.constraint(equalTo: self.leftAnchor),
imageView.topAnchor.constraint(equalTo: self.topAnchor),
imageView.rightAnchor.constraint(equalTo: self.rightAnchor),
imageView.heightAnchor.constraint(equalToConstant: 125)
])
return imageView
}()
lazy var titleLabel: UILabel = {
let label = UILabel(frame: CGRect.zero)
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont.systemFont(ofSize: 26)
label.textColor = AppColors.foreground
self.addSubview(label)
NSLayoutConstraint.activate([
label.topAnchor.constraint(equalTo: self.posterImageView.bottomAnchor, constant: 5),
label.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 10),
label.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -10)
])
return label
}()
lazy var subtitleLabel: UILabel = {
let label = UILabel(frame: CGRect.zero)
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = AppColors.foreground
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
self.addSubview(label)
NSLayoutConstraint.activate([
label.leftAnchor.constraint(equalTo: self.titleLabel.leftAnchor),
label.topAnchor.constraint(equalTo: self.titleLabel.bottomAnchor),
label.rightAnchor.constraint(equalTo: self.titleLabel.rightAnchor, constant: -50),
label.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -10)
])
return label
}()
lazy var button: UIButton = {
let button = UIButton(type: .infoDark)
button.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(button)
NSLayoutConstraint.activate([
button.centerYAnchor.constraint(equalTo: self.titleLabel.centerYAnchor),
button.rightAnchor.constraint(equalTo: self.titleLabel.rightAnchor)
])
return button
}()
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: .default, reuseIdentifier: reuseIdentifier)
button.addTarget(self, action: #selector(VerticalPosterCell.infoButtonTouchedUpInside), for: .touchUpInside)
backgroundColor = AppColors.background
tintColor = AppColors.tint
selectionStyle = .none
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension VerticalPosterCell {
override func prepareForReuse() {
configure(viewModel: nil)
}
@objc func infoButtonTouchedUpInside() {
viewModel?.infoButtonSelectionBlock()
}
}
extension VerticalPosterCell: CollectionableViewModelCellConfigurable {
func configure(viewModel: PosterCellViewModel?) {
self.viewModel = viewModel
titleLabel.text = viewModel?.title
subtitleLabel.text = viewModel?.subtitle
configureImage(imageName: viewModel?.imageName)
}
private func configureImage(imageName: String?) {
if let name = imageName {
posterImageView.image = UIImage(named: name)
} else {
posterImageView.image = nil
}
}
}
|
mit
|
d0450528e3fac3d2e8d5052510d825bf
| 36.066038 | 116 | 0.669891 | 5.389575 | false | false | false | false |
mperovic/my41
|
my41/Classes/Bus.swift
|
1
|
20402
|
//
// Bus.swift
// my41
//
// Created by Miroslav Perovic on 8/9/14.
// Copyright (c) 2014 iPera. All rights reserved.
//
import Foundation
protocol Peripheral {
func pluggedIntoBus(_ bus: Bus?)
func readFromRegister(_ param: Bits4)
func writeToRegister(_ param: Bits4)
func writeDataFrom(_ data: Digits14)
}
struct RomDesc {
var name: String
var slot: byte
var bank: byte
}
struct RamDesc {
var firstAddress: Bits12
var lastAddress: Bits12
var inC: Bool
var inCV: Bool
var inCX: Bool
var memModule1: Bool
var memModule2: Bool
var memModule3: Bool
var memModule4: Bool
var quad: Bool
var xMem: Bool
var xFunction: Bool
}
//let calculatorController = CalculatorController.sharedInstance
var builtinRomTable: [RomDesc] = [
RomDesc(name: "XNUT0", slot: 0, bank: 0),
RomDesc(name: "XNUT1", slot: 1, bank: 0),
RomDesc(name: "XNUT2", slot: 2, bank: 0),
RomDesc(name: "CXFUNS0", slot: 2, bank: 0),
RomDesc(name: "CXFUNS1", slot: 5, bank: 1),
RomDesc(name: "TIMER", slot: 5, bank: 0)
]
var builtinRamTable: [RamDesc] = [
RamDesc(
firstAddress: 0x0000,
lastAddress: 0x000F,
inC: true,
inCV: true,
inCX: true,
memModule1: false,
memModule2: false,
memModule3: false,
memModule4: false,
quad: false,
xMem: false,
xFunction: false
), // Base memory of all calculators
//0x0010 - 0x0030 nonexistent
RamDesc(
firstAddress: 0x0040,
lastAddress: 0x00BF,
inC: false,
inCV: false,
inCX: true,
memModule1: false,
memModule2: false,
memModule3: false,
memModule4: false,
quad: false,
xMem: false,
xFunction: true
), // X-func, X-mem
RamDesc(
firstAddress: 0x00C0,
lastAddress: 0x00FF,
inC: true,
inCV: true,
inCX: true,
memModule1: false,
memModule2: false,
memModule3: false,
memModule4: false,
quad: false,
xMem: false,
xFunction: false
), // 41C, CV CX Main memory
RamDesc(
firstAddress: 0x0100,
lastAddress: 0x013F,
inC: false,
inCV: true,
inCX: true,
memModule1: true,
memModule2: false,
memModule3: false,
memModule4: false,
quad: true,
xMem: false,
xFunction: false
), // CV, CX Mem module 1
RamDesc(
firstAddress: 0x0140,
lastAddress: 0x017F,
inC: false,
inCV: true,
inCX: true,
memModule1: false,
memModule2: true,
memModule3: false,
memModule4: false,
quad: true,
xMem: false,
xFunction: false
), // CV, CX Mem module 2
RamDesc(
firstAddress: 0x0180,
lastAddress: 0x01BF,
inC: false,
inCV: true,
inCX: true,
memModule1: false,
memModule2: false,
memModule3: true,
memModule4: false,
quad: true,
xMem: false,
xFunction: false
), // CV, CX Mem module 3
RamDesc(
firstAddress: 0x01C0,
lastAddress: 0x01FF,
inC: false,
inCV: true,
inCX: true,
memModule1: false,
memModule2: false,
memModule3: false,
memModule4: true,
quad: true,
xMem: false,
xFunction: false
), // CV, CX Mem module 4
// Hole at 0x200
RamDesc(
firstAddress: 0x0201,
lastAddress: 0x02EF,
inC: false,
inCV: false,
inCX: false,
memModule1: false,
memModule2: false,
memModule3: false,
memModule4: false,
quad: false,
xMem: true,
xFunction: false
), // Extended memory 1
// 0x02f0 nonexistent
RamDesc(
firstAddress: 0x0301,
lastAddress: 0x03EF,
inC: false,
inCV: false,
inCX: false,
memModule1: false,
memModule2: false,
memModule3: false,
memModule4: false,
quad: false,
xMem: true,
xFunction: false
) // Extended memory 2
//0x03f nonexistent
]
enum RamError: Error {
case invalidAddress
}
enum RomError: Error {
case invalidAddress
}
enum MODError: Error {
case freeSpace
}
final class Bus {
// Section defining what type of memory we have
var memoryModule1: Bool?
var memoryModule2: Bool?
var memoryModule3: Bool?
var memoryModule4: Bool?
var quadMemory: Bool?
var xMemory: Bool?
var xFunction: Bool?
var ram = [Digits14](repeating: Digits14(), count: MAX_RAM_SIZE)
var peripherals: [Peripheral?] = [Peripheral?](repeating: nil, count: 0x100)
// Peripherals
var display: Display?
var timer: Timer?
var memModules: byte = 0
var XMemModules: byte = 0
// ROM variables
var romChips = Array<Array<RomChip?>>()
var nextActualBankGroup: byte = 1 // counter for loading actual bank groups
var activeBank: [Int] = [Int](repeating: 1, count: 0x10)
static let sharedInstance = Bus()
init () {
// 16 pages of 4 banks
for page in 0...0xf {
romChips.append(Array(repeating: RomChip(), count: 4))
for bank in 1...4 {
romChips[page][bank - 1] = nil
}
}
ram = [Digits14](repeating: Digits14(), count: MAX_RAM_SIZE)
}
func installMod(_ mod: MOD) throws {
/*
these are arrays indexed on the page group number (1-8) (unique only within each mod file)
dual use: values are either a count stored as a negative number or a (positive) page number 1-f
*/
var lowerGroup: [Int8] = [0, 0, 0, 0, 0, 0, 0, 0] // <0, or =page # if lower page(s) go in group
var upperGroup: [Int8] = [0, 0, 0, 0, 0, 0, 0, 0] // <0, or =page # if upper page(s) go in group
var oddGroup: [Int8] = [0, 0, 0, 0, 0, 0, 0, 0] // <0, or =page # if odd page(s) go in group
var evenGroup: [Int8] = [0, 0, 0, 0, 0, 0, 0, 0] // <0, or =page # if even page(s) go in group
var orderedGroup: [Int8] = [0, 0, 0, 0, 0, 0, 0, 0] // <0, or =page # if ordered page(s) go in group
var page: byte = 0
var hepPage: byte = 0
var wwPage: byte = 0
// load ROM pages with three pass process
for pass in 1...3 {
for pageIndex in 0..<mod.moduleHeader.numPages {
let modulePage = mod.modulePages[Int(pageIndex)]
var load = false
switch pass {
case 1:
// pass 1: validate page variables, flag grouped pages
do {
try mod.checkPage(modulePage)
} catch CheckPageError.pageOutOfRange {
displayAlert("page: \(modulePage) is out of range")
} catch CheckPageError.pageGroupOutOfRange {
displayAlert("group pages cannot use non-grouped position codes")
} catch CheckPageError.bankOutOfRange {
displayAlert("bank: \(modulePage.bank) is out of range")
} catch CheckPageError.bankGroupOutOfRange {
displayAlert("bank group: \(modulePage.bankGroup) is out of range")
} catch CheckPageError.ramOutOfRange {
displayAlert("ram: \(modulePage.RAM) is out of range")
} catch CheckPageError.writeProtect {
displayAlert("wrong write protect value")
} catch CheckPageError.fatOutOfRange {
displayAlert("FAT: \(modulePage.FAT) is out of range")
} catch CheckPageError.nonGroupedPagesError {
displayAlert("non-grouped pages cannot use grouped position codes")
} catch {
}
if modulePage.pageGroup == 0 {
// if not grouped do nothing in this pass
break
}
// save the count of pages with each attribute as a negative number
if modulePage.page == Position.positionLower.rawValue {
lowerGroup[Int(modulePage.pageGroup) - 1] -= 1
} else if modulePage.page == Position.positionUpper.rawValue {
upperGroup[Int(modulePage.pageGroup) - 1] -= 1
} else if modulePage.page == Position.positionOdd.rawValue {
oddGroup[Int(modulePage.pageGroup) - 1] -= 1
} else if modulePage.page == Position.positionEven.rawValue {
evenGroup[Int(modulePage.pageGroup) - 1] -= 1
} else if modulePage.page == Position.positionOrdered.rawValue {
orderedGroup[Int(modulePage.pageGroup) - 1] -= 1
}
case 2:
// pass 2: find free location for grouped pages
if modulePage.pageGroup == 0 {
// if not grouped do nothing in this pass
break
}
// a matching page has already been loaded
if modulePage.page == Position.positionLower.rawValue && upperGroup[Int(modulePage.pageGroup) - 1] > 0 {
// this is the lower page and the upper page has already been loaded
page = byte(upperGroup[Int(modulePage.pageGroup - 1)] - 1)
} else if modulePage.page == Position.positionLower.rawValue && lowerGroup[Int(modulePage.pageGroup) - 1] > 0 {
// this is another lower page
page = byte(lowerGroup[Int(modulePage.pageGroup - 1)])
} else if modulePage.page == Position.positionUpper.rawValue && lowerGroup[Int(modulePage.pageGroup) - 1] > 0 {
// this is the upper page and the lower page has already been loaded
page = byte(lowerGroup[Int(modulePage.pageGroup - 1)] + 1)
} else if modulePage.page == Position.positionUpper.rawValue && upperGroup[Int(modulePage.pageGroup) - 1] > 0 {
// this is another upper page
page = byte(upperGroup[Int(modulePage.pageGroup - 1)])
} else if modulePage.page == Position.positionOdd.rawValue && evenGroup[Int(modulePage.pageGroup) - 1] > 0 {
page = byte(evenGroup[Int(modulePage.pageGroup - 1)] + 1)
} else if modulePage.page == Position.positionOdd.rawValue && oddGroup[Int(modulePage.pageGroup) - 1] > 0 {
page = byte(oddGroup[Int(modulePage.pageGroup) - 1])
} else if modulePage.page == Position.positionEven.rawValue && oddGroup[Int(modulePage.pageGroup) - 1] > 0 {
page = byte(oddGroup[Int(modulePage.pageGroup) - 1] - 1)
} else if modulePage.page == Position.positionEven.rawValue && evenGroup[Int(modulePage.pageGroup) - 1] > 0 {
page = byte(evenGroup[Int(modulePage.pageGroup) - 1])
} else if modulePage.page == Position.positionOrdered.rawValue && orderedGroup[Int(modulePage.pageGroup) - 1] > 0 {
// page = byte(++orderedGroup[Int(modulePage.pageGroup) - 1])
page = byte(1 + orderedGroup[Int(modulePage.pageGroup) - 1])
} else {
// find first page in group
// find free space depending on which combination of positions are specified
if lowerGroup[Int(modulePage.pageGroup) - 1] != 0 && upperGroup[Int(modulePage.pageGroup) - 1] != 0 {
// lower and upper
page = 8
while (page <= 0xe && (romChips[Int(page)][Int(modulePage.bank) - 1] != nil || romChips[Int(page) + 1][Int(modulePage.bank) - 1] != nil)) {
page += 1
}
} else if lowerGroup[Int(modulePage.pageGroup) - 1] != 0 {
// lower but no upper
page = 8
while (page <= 0xf && romChips[Int(page)][Int(modulePage.bank) - 1] != nil) {
page += 1
}
} else if upperGroup[Int(modulePage.pageGroup) - 1] != 0 {
// upper but no lower
page = 8
while (page <= 0xf && romChips[Int(page)][Int(modulePage.bank) - 1] != nil) {
page += 1
}
} else if evenGroup[Int(modulePage.pageGroup) - 1] != 0 && oddGroup[Int(modulePage.pageGroup) - 1] != 0 {
// even and odd
page = 8
while (page <= 0xe && (romChips[Int(page)][Int(modulePage.bank) - 1] != nil || romChips[Int(page) + 1][Int(modulePage.bank) - 1] != nil)) {
page += 2
}
} else if evenGroup[Int(modulePage.pageGroup) - 1] != 0 {
// even only
page = 8
while (page <= 0xe && romChips[Int(page)][Int(modulePage.bank) - 1] != nil) {
page += 2
}
} else if oddGroup[Int(modulePage.pageGroup) - 1] != 0 {
// odd only
page = 9
while (page <= 0xe && romChips[Int(page)][Int(modulePage.bank) - 1] != nil) {
page += 2
}
} else if orderedGroup[Int(modulePage.pageGroup) - 1] != 0 {
// a block
let count: Int8 = -1 * orderedGroup[Int(modulePage.pageGroup) - 1]
for page in 8..<0x10-count {
var nFree: Int8 = 0
for _ in page..<0x0f {
// count up free spaces
if romChips[Int(page)][Int(modulePage.bank) - 1] == nil {
nFree += 1
} else {
break
}
}
if count <= nFree {
// found a space
break
}
}
} else {
page = 8
while page <= 0xf && romChips[Int(page)][Int(modulePage.bank) - 1] != nil {
page += 1
}
}
// save the position that was found in the appropriate array
if modulePage.page == Position.positionLower.rawValue {
lowerGroup[Int(modulePage.pageGroup) - 1] = Int8(page)
} else if modulePage.page == Position.positionUpper.rawValue {
// found two positions - take the upper one
page += 1
upperGroup[Int(modulePage.pageGroup) - 1] = Int8(page)
} else if modulePage.page == Position.positionEven.rawValue {
evenGroup[Int(modulePage.pageGroup) - 1] = Int8(page)
} else if modulePage.page == Position.positionOdd.rawValue {
oddGroup[Int(modulePage.pageGroup) - 1] = Int8(page)
} else if modulePage.page == Position.positionOrdered.rawValue {
orderedGroup[Int(modulePage.pageGroup) - 1] = Int8(page)
}
}
load = true
case 3:
// pass 3 - find location for non-grouped pages
if Int(modulePage.pageGroup) == 1 {
break
}
if modulePage.page == Position.positionAny.rawValue {
// a single page that can be loaded anywhere 8-F
page = 8
while (page <= 0xf && romChips[Int(page)][Int(modulePage.bank) - 1] != nil) {
page += 1
}
} else {
// page number is hardcoded
page = modulePage.page
}
load = true
default:
break
}
if load {
if mod.moduleHeader.hardware == Hardware.hepax {
modulePage.HEPAX = 1
}
if mod.moduleHeader.hardware == Hardware.wwramBox {
modulePage.WWRAMBOX = 1
}
if modulePage.bankGroup != 0 {
// ensures each bank group has a number that is unique to the entire simulator
modulePage.actualBankGroup = modulePage.bankGroup + nextActualBankGroup * 8
} else {
modulePage.actualBankGroup = 0
}
// HEPAX special case
if hepPage != 0 && modulePage.HEPAX == 1 && modulePage.RAM == 1 {
// hepax was just loaded previously and this is the first RAM page after it
modulePage.actualPage = hepPage
let romChip = romChipInSlot(Bits4(hepPage), bank: Bits4(modulePage.bank))
// load this RAM into alternate page
romChip?.altPage = modulePage
} else if wwPage != 0 && modulePage.WWRAMBOX != 0 && modulePage.RAM != 0 {
// W&W code was just loaded previously and this is the first RAM page after it
modulePage.actualPage = wwPage
let romChip = romChipInSlot(Bits4(wwPage), bank: Bits4(modulePage.bank))
// load this RAM into alternate page
romChip?.altPage = modulePage
} else if page > 0xf || romChips[Int(page)][Int(modulePage.bank) - 1] != nil {
// there is no free space or some load conflict exists
throw MODError.freeSpace
} else {
// otherwise load into primary page
let romChip = RomChip(fromBIN: modulePage.image, actualBankGroup: modulePage.actualBankGroup)
romChip.HEPAX = modulePage.HEPAX
romChip.WWRAMBOX = modulePage.WWRAMBOX
romChip.RAM = modulePage.RAM
installRomChip(romChip, inSlot: page, andBank: modulePage.bank-1)
}
hepPage = 0
wwPage = 0
if modulePage.HEPAX == 1 && modulePage.RAM == 0 {
// detect HEPAX ROM
hepPage = page
}
if modulePage.HEPAX == 1 && modulePage.RAM == 0 {
// detect W&W RAMBOXII ROM
wwPage = page
}
}
}
}
nextActualBankGroup += 1
}
func installRomChip(_ chip: RomChip, inSlot slot: byte, andBank bank: byte) {
romChips[Int(slot)][Int(bank)] = chip
}
func readRamAddress(_ address: Bits12) throws -> Digits14 {
/*
Read specified location of specified chip.
If chip or location is nonexistent, set data to 0 and return false.
*/
if RAMExists(Int(address)) {
return ram[Int(address)]
} else {
throw RamError.invalidAddress
}
}
func writeRamAddress(_ address: Bits12, from data: Digits14) throws {
// Write to specified location of specified chip. If chip or location is nonexistent, do nothing and return false.
if RAMExists(Int(address)) {
ram[Int(address)] = data
} else {
throw RamError.invalidAddress
}
}
func removeAllRomChips() {
for page in 0...0xf {
for bank in 1...4 {
self.romChips[page][bank - 1] = nil
}
}
}
func readRomAddress(_ addr: Int) throws -> Int {
// Read ROM location at the given address and return true.
// If there is no ROM at that address, sets data to 0 and returns
let address = addr & 0xffff
let page = Int(address >> 12)
let bank = Int(activeBank[page])
let rom: RomChip? = romChips[page][bank - 1]
if let aRom = rom {
return Int(aRom[Int(address & 0xfff)])
} else {
throw RomError.invalidAddress
}
}
func romChipInSlot(_ slot: Bits4, bank: Bits4) -> RomChip? {
return romChips[Int(slot)][Int(bank) - 1]
}
func romChipInSlot(_ slot: Bits4) -> RomChip? {
let bank = activeBank[Int(slot)]
return romChips[Int(slot)][Int(bank) - 1]
}
func activeBankAtAddr(_ addr: Bits16) -> Bits4 {
let slot = addr >> 12
return Bits4(activeBank[Int(slot)])
}
func activeBankInSlot(_ slot: Bits4) -> Int {
return activeBank[Int(slot)]
}
func setActiveBankInSlot(_ slot: Bits4, bank: Int) {
activeBank[Int(slot)] = bank
}
func writeToRegister(_ register: Bits4, ofPeripheral slot: Bits8) {
if let peripheral = peripherals[Int(slot)] {
peripheral.writeToRegister(register)
}
}
func writeDataToPeripheral(slot aSlot: Bits8, from data: Digits14) {
if let peripheral: Peripheral = peripherals[Int(aSlot)] {
peripheral.writeDataFrom(data)
}
}
func readFromRegister(register reg: Bits4, ofPeripheral slot: Bits8) {
if let periph = peripherals[Int(slot)] {
periph.readFromRegister(reg)
}
}
func installPeripheral(_ peripheral: Peripheral, inSlot slot: Bits8) {
if let oldPeripheral = peripherals[Int(slot)] {
oldPeripheral.pluggedIntoBus(nil)
}
peripherals[Int(slot)] = peripheral
peripheral.pluggedIntoBus(self)
}
func abortInstruction(_ message: String) {
cpu.abortInstruction(message)
}
func checkAddress(_ address: Bits12, calculatorModHeader: ModuleFileHeader) -> Bool {
if address >= 0x000 && address <= 0x00f { // status registers
return true
}
if address >= 0x010 && address <= 0x03f { // void
return false
}
if address >= 0x040 && address <= 0x0bf { // extended functions - 128 regs
return calculatorModHeader.XMemModules >= 1
}
if address >= 0x0c0 && address <= 0x0ff { // main memory for C
return true
}
if address >= 0x100 && address <= 0x13f { // memory module 1
return calculatorModHeader.memModules >= 1
}
if address >= 0x140 && address <= 0x17f { // memory module 2
return calculatorModHeader.memModules >= 2
}
if address >= 0x180 && address <= 0x1bf { // memory module 3
return calculatorModHeader.memModules >= 3
}
if address >= 0x1c0 && address <= 0x1ff { // memory module 4
return calculatorModHeader.memModules >= 4
}
// void: 200
if address >= 0x201 && address <= 0x2ef { // extended memory 1 - 239 regs
return calculatorModHeader.XMemModules >= 2
}
// void: 2f0-300
if address >= 0x301 && address <= 0x3ef { // extended memory 2 - 239 regs
return calculatorModHeader.XMemModules >= 3
}
// void: 3f0-3ff
// end of memory: 3ff
return false
}
func RAMExists(_ address: Int) -> Bool {
if address >= 0x000 && address <= 0x00f { // status registers
return true
}
if address >= 0x010 && address <= 0x03f { // void
return false
}
if address >= 0x040 && address <= 0x0bf { // extended functions - 128 regs
return self.XMemModules >= 1
}
if address >= 0x0c0 && address <= 0x0ff { // main memory for C
return true
}
if address >= 0x100 && address <= 0x13f { // memory module 1
return self.memModules >= 1
}
if address >= 0x140 && address <= 0x17f { // memory module 2
return self.memModules >= 2
}
if address >= 0x180 && address <= 0x1bf { // memory module 3
return self.memModules >= 3
}
if address >= 0x1c0 && address <= 0x1ff { // memory module 4
return self.memModules >= 4
}
// void: 200
if address >= 0x201 && address <= 0x2ef { // extended memory 1 - 239 regs
return self.XMemModules >= 2
}
// void: 2f0-300
if address >= 0x301 && address <= 0x3ef { // extended memory 2 - 239 regs
return self.XMemModules >= 3
}
// void: 3f0-3ff
// end of memory: 3ff
return false
}
}
|
bsd-3-clause
|
3616a9e6bc8b3e18e4fa5c24be62df74
| 29.818731 | 146 | 0.636114 | 3.087937 | false | false | false | false |
Obisoft2017/BeautyTeamiOS
|
BeautyTeam/BeautyTeam/NoticeRightNavigationItemPopMenu.swift
|
1
|
3121
|
//
// NoticeRightNavigationItemPopMenu.swift
// BeautyTeam
//
// Created by Carl Lee on 4/21/16.
// Copyright © 2016 Shenyang Obisoft Technology Co.Ltd. All rights reserved.
//
import UIKit
class NoticeRightNavigationItemPopMenu: UITableView, UITableViewDataSource, UITableViewDelegate {
weak var jumpDelegate: NoticeVC?
var personalTaskCell: UITableViewCell?
var personalEventCell: UITableViewCell?
var importCell: UITableViewCell?
static var itemHeight: CGFloat = 60
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
// Drawing code
}
*/
override init(frame: CGRect, style: UITableViewStyle) {
super.init(frame: frame, style: style)
self.personalTaskCell = UITableViewCell(style: .Default, reuseIdentifier: nil)
self.personalTaskCell?.textLabel?.text = "Add Personal Task"
// personalTaskCell?.backgroundColor = UIColor.blackColor()
self.personalEventCell = UITableViewCell(style: .Default, reuseIdentifier: nil)
self.personalEventCell?.textLabel?.text = "Add Personal Event"
self.importCell = UITableViewCell(style: .Default, reuseIdentifier: nil)
self.importCell?.textLabel?.text = "Import"
// importCell?.backgroundColor = UIColor.blackColor()
self.contentSize.height = 0
self.separatorStyle = .None
self.dataSource = self
self.delegate = self
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch indexPath.row {
case 0:
return self.personalTaskCell!
case 1:
return self.personalEventCell!
case 2:
return self.importCell!
default:
break
}
return UITableViewCell()
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.deselectRowAtIndexPath(indexPath, animated: true)
switch indexPath.row {
case 0:
self.jumpDelegate?.navigationController?.pushViewController(AddPersonalTaskVC(style: .Grouped), animated: true)
case 1:
self.jumpDelegate?.navigationController?.pushViewController(AddPersonalEventVC(style: .Grouped), animated: true)
case 2:
self.jumpDelegate?.navigationController?.pushViewController(ImportVC(style: .Grouped), animated: true)
default:
break
}
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return NoticeRightNavigationItemPopMenu.itemHeight
}
}
|
apache-2.0
|
57e6f2f4fc4019e818baac41141ffc86
| 33.666667 | 124 | 0.668269 | 5.140033 | false | false | false | false |
MukeshKumarS/Swift
|
stdlib/public/SDK/Darwin/Darwin.swift
|
1
|
9270
|
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
@_exported import Darwin // Clang module
//===----------------------------------------------------------------------===//
// MacTypes.h
//===----------------------------------------------------------------------===//
public var noErr: OSStatus { return 0 }
/// The `Boolean` type declared in MacTypes.h and used throughout Core
/// Foundation.
///
/// The C type is a typedef for `unsigned char`.
public struct DarwinBoolean : BooleanType, BooleanLiteralConvertible {
var _value: UInt8
public init(_ value: Bool) {
self._value = value ? 1 : 0
}
/// The value of `self`, expressed as a `Bool`.
public var boolValue: Bool {
return _value != 0
}
/// Create an instance initialized to `value`.
@_transparent
public init(booleanLiteral value: Bool) {
self.init(value)
}
}
extension DarwinBoolean : _Reflectable {
/// Returns a mirror that reflects `self`.
public func _getMirror() -> _MirrorType {
return _reflect(boolValue)
}
}
extension DarwinBoolean : CustomStringConvertible {
/// A textual representation of `self`.
public var description: String {
return self.boolValue.description
}
}
extension DarwinBoolean : Equatable {}
@warn_unused_result
public func ==(lhs: DarwinBoolean, rhs: DarwinBoolean) -> Bool {
return lhs.boolValue == rhs.boolValue
}
@warn_unused_result
public // COMPILER_INTRINSIC
func _convertBoolToDarwinBoolean(x: Bool) -> DarwinBoolean {
return DarwinBoolean(x)
}
@warn_unused_result
public // COMPILER_INTRINSIC
func _convertDarwinBooleanToBool(x: DarwinBoolean) -> Bool {
return Bool(x)
}
// FIXME: We can't make the fully-generic versions @_transparent due to
// rdar://problem/19418937, so here are some @_transparent overloads
// for DarwinBoolean.
@_transparent
@warn_unused_result
public func && <T : BooleanType>(
lhs: T,
@autoclosure rhs: () -> DarwinBoolean
) -> Bool {
return lhs.boolValue ? rhs().boolValue : false
}
@_transparent
@warn_unused_result
public func || <T : BooleanType>(
lhs: T,
@autoclosure rhs: () -> DarwinBoolean
) -> Bool {
return lhs.boolValue ? true : rhs().boolValue
}
//===----------------------------------------------------------------------===//
// sys/errno.h
//===----------------------------------------------------------------------===//
public var errno : Int32 {
get {
return __error().memory
}
set {
__error().memory = newValue
}
}
//===----------------------------------------------------------------------===//
// stdio.h
//===----------------------------------------------------------------------===//
public var stdin : UnsafeMutablePointer<FILE> {
get {
return __stdinp
}
set {
__stdinp = newValue
}
}
public var stdout : UnsafeMutablePointer<FILE> {
get {
return __stdoutp
}
set {
__stdoutp = newValue
}
}
public var stderr : UnsafeMutablePointer<FILE> {
get {
return __stderrp
}
set {
__stderrp = newValue
}
}
//===----------------------------------------------------------------------===//
// fcntl.h
//===----------------------------------------------------------------------===//
@warn_unused_result
@_silgen_name("_swift_Darwin_open")
func _swift_Darwin_open(
path: UnsafePointer<CChar>,
_ oflag: CInt,
_ mode: mode_t
) -> CInt
@warn_unused_result
@_silgen_name("_swift_Darwin_openat")
func _swift_Darwin_openat(fd: CInt,
_ path: UnsafePointer<CChar>,
_ oflag: CInt,
_ mode: mode_t
) -> CInt
@warn_unused_result
public func open(
path: UnsafePointer<CChar>,
_ oflag: CInt
) -> CInt {
return _swift_Darwin_open(path, oflag, 0)
}
@warn_unused_result
public func open(
path: UnsafePointer<CChar>,
_ oflag: CInt,
_ mode: mode_t
) -> CInt {
return _swift_Darwin_open(path, oflag, mode)
}
@warn_unused_result
public func openat(
fd: CInt,
_ path: UnsafePointer<CChar>,
_ oflag: CInt
) -> CInt {
return _swift_Darwin_openat(fd, path, oflag, 0)
}
@warn_unused_result
public func openat(
fd: CInt,
_ path: UnsafePointer<CChar>,
_ oflag: CInt,
_ mode: mode_t
) -> CInt {
return _swift_Darwin_openat(fd, path, oflag, mode)
}
@warn_unused_result
@_silgen_name("_swift_Darwin_fcntl")
internal func _swift_Darwin_fcntl(
fd: CInt,
_ cmd: CInt,
_ value: CInt
) -> CInt
@warn_unused_result
@_silgen_name("_swift_Darwin_fcntlPtr")
internal func _swift_Darwin_fcntlPtr(
fd: CInt,
_ cmd: CInt,
_ ptr: UnsafeMutablePointer<Void>
) -> CInt
@warn_unused_result
public func fcntl(
fd: CInt,
_ cmd: CInt
) -> CInt {
return _swift_Darwin_fcntl(fd, cmd, 0)
}
@warn_unused_result
public func fcntl(
fd: CInt,
_ cmd: CInt,
_ value: CInt
) -> CInt {
return _swift_Darwin_fcntl(fd, cmd, value)
}
@warn_unused_result
public func fcntl(
fd: CInt,
_ cmd: CInt,
_ ptr: UnsafeMutablePointer<Void>
) -> CInt {
return _swift_Darwin_fcntlPtr(fd, cmd, ptr)
}
public var S_IFMT: mode_t { return mode_t(0o170000) }
public var S_IFIFO: mode_t { return mode_t(0o010000) }
public var S_IFCHR: mode_t { return mode_t(0o020000) }
public var S_IFDIR: mode_t { return mode_t(0o040000) }
public var S_IFBLK: mode_t { return mode_t(0o060000) }
public var S_IFREG: mode_t { return mode_t(0o100000) }
public var S_IFLNK: mode_t { return mode_t(0o120000) }
public var S_IFSOCK: mode_t { return mode_t(0o140000) }
public var S_IFWHT: mode_t { return mode_t(0o160000) }
public var S_IRWXU: mode_t { return mode_t(0o000700) }
public var S_IRUSR: mode_t { return mode_t(0o000400) }
public var S_IWUSR: mode_t { return mode_t(0o000200) }
public var S_IXUSR: mode_t { return mode_t(0o000100) }
public var S_IRWXG: mode_t { return mode_t(0o000070) }
public var S_IRGRP: mode_t { return mode_t(0o000040) }
public var S_IWGRP: mode_t { return mode_t(0o000020) }
public var S_IXGRP: mode_t { return mode_t(0o000010) }
public var S_IRWXO: mode_t { return mode_t(0o000007) }
public var S_IROTH: mode_t { return mode_t(0o000004) }
public var S_IWOTH: mode_t { return mode_t(0o000002) }
public var S_IXOTH: mode_t { return mode_t(0o000001) }
public var S_ISUID: mode_t { return mode_t(0o004000) }
public var S_ISGID: mode_t { return mode_t(0o002000) }
public var S_ISVTX: mode_t { return mode_t(0o001000) }
public var S_ISTXT: mode_t { return S_ISVTX }
public var S_IREAD: mode_t { return S_IRUSR }
public var S_IWRITE: mode_t { return S_IWUSR }
public var S_IEXEC: mode_t { return S_IXUSR }
//===----------------------------------------------------------------------===//
// unistd.h
//===----------------------------------------------------------------------===//
@available(*, unavailable, message="Please use threads or posix_spawn*()")
public func fork() -> Int32 {
fatalError("unavailable function can't be called")
}
@available(*, unavailable, message="Please use threads or posix_spawn*()")
public func vfork() -> Int32 {
fatalError("unavailable function can't be called")
}
//===----------------------------------------------------------------------===//
// signal.h
//===----------------------------------------------------------------------===//
#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
public var SIG_DFL: sig_t? { return nil }
public var SIG_IGN: sig_t { return unsafeBitCast(1, sig_t.self) }
public var SIG_ERR: sig_t { return unsafeBitCast(-1, sig_t.self) }
public var SIG_HOLD: sig_t { return unsafeBitCast(5, sig_t.self) }
#else
internal var _ignore = _UnsupportedPlatformError()
#endif
//===----------------------------------------------------------------------===//
// semaphore.h
//===----------------------------------------------------------------------===//
/// The value returned by `sem_open()` in the case of failure.
public var SEM_FAILED: UnsafeMutablePointer<sem_t> {
#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
// The value is ABI. Value verified to be correct for OS X, iOS, watchOS, tvOS.
return UnsafeMutablePointer<sem_t>(bitPattern: -1)
#else
_UnsupportedPlatformError()
#endif
}
@warn_unused_result
@_silgen_name("_swift_Darwin_sem_open2")
internal func _swift_Darwin_sem_open2(
name: UnsafePointer<CChar>,
_ oflag: CInt
) -> UnsafeMutablePointer<sem_t>
@warn_unused_result
@_silgen_name("_swift_Darwin_sem_open4")
internal func _swift_Darwin_sem_open4(
name: UnsafePointer<CChar>,
_ oflag: CInt,
_ mode: mode_t,
_ value: CUnsignedInt
) -> UnsafeMutablePointer<sem_t>
@warn_unused_result
public func sem_open(
name: UnsafePointer<CChar>,
_ oflag: CInt
) -> UnsafeMutablePointer<sem_t> {
return _swift_Darwin_sem_open2(name, oflag)
}
@warn_unused_result
public func sem_open(
name: UnsafePointer<CChar>,
_ oflag: CInt,
_ mode: mode_t,
_ value: CUnsignedInt
) -> UnsafeMutablePointer<sem_t> {
return _swift_Darwin_sem_open4(name, oflag, mode, value)
}
|
apache-2.0
|
d0715c072dc60d64ba882cf69f92715a
| 25.485714 | 82 | 0.586624 | 3.573631 | false | false | false | false |
Ossus/eponyms-2
|
Sources/ViewController/UserViewController.swift
|
1
|
2812
|
//
// UserViewController.swift
// eponyms-2
//
// Created by Pascal Pfiffner on 4/1/16.
// Copyright © 2016 Ossus. All rights reserved.
//
import UIKit
open class UserViewController: UITableViewController {
var user: User?
// MARK: - View Tasks
open override func viewDidLoad() {
super.viewDidLoad()
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "User")
tableView.register(LoginButtonCell.self, forCellReuseIdentifier: "Login")
}
// MARK: - Login / Logout
func login() {
guard nil == user else {
return
}
let usr = User()
usr.name = "firstuser"
usr.password = "passs"
usr.login()
user = usr
tableView.reloadData()
}
func logout() {
guard let user = user else {
return
}
user.logout()
self.user = nil
tableView.reloadData()
}
// MARK: - Table View Data Source
open override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
open override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if 0 == section {
return 3
}
return 1
}
open override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// user details
if 0 == (indexPath as NSIndexPath).section {
let cell = tableView.dequeueReusableCell(withIdentifier: "User", for: indexPath)
if nil != user {
cell.textLabel?.textColor = UIColor.black
}
else {
cell.textLabel?.textColor = UIColor.gray
}
if 0 == (indexPath as NSIndexPath).row {
cell.textLabel?.text = user?.name ?? "Name"
}
else if 1 == (indexPath as NSIndexPath).row {
cell.textLabel?.text = user?.email ?? "Email"
}
else if 2 == (indexPath as NSIndexPath).row {
cell.textLabel?.text = user?.password ?? "Password"
}
return cell
}
// login button
let cell = tableView.dequeueReusableCell(withIdentifier: "Login", for: indexPath) as! LoginButtonCell
cell.textLabel?.text = (nil == user) ? "Login" : "Logout"
return cell
}
// MARK: - Table View Delegate
open override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 1 == (indexPath as NSIndexPath).section {
if nil == user {
login()
}
else {
logout()
}
}
}
// MARK: - Cells
class LoginButtonCell: UITableViewCell {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.textLabel?.textColor = UIColor.red
self.textLabel?.textAlignment = .center
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
}
}
// MARK: -
open class DismissFromModalSegue: UIStoryboardSegue {
open override func perform() {
source.dismiss(animated: true, completion: nil)
}
}
|
apache-2.0
|
5c773081157966dc62cab5375a8ef9d0
| 19.977612 | 111 | 0.666667 | 3.664928 | false | false | false | false |
sareninden/DataSourceFramework
|
DataSourceFrameworkDemo/DataSourceFrameworkDemo/StringsTableViewController.swift
|
1
|
1855
|
import Foundation
import UIKit
import DataSourceFramework
class StringsTableViewController : BaseTableViewController {
override init() {
super.init()
title = "Simple strings list"
tableController.interactionDelegate = self
tableController.cellReuseIdentifier = TABLE_CELL_DEFAULT_IDENTIFIER
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func loadData() {
for sectionIndex in 0..<3 {
let section = sectionWithHeaderTitle("Section \(sectionIndex)")
for row in 0...15 {
section.addItem("Row \(row)")
}
tableController.addSection(section)
}
}
}
extension StringsTableViewController : TableControllerInteractionInterface {
func tableController(tableController : TableController, tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath) {
}
func tableController(tableController : TableController, tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
let item = tableController.itemAtIndexPath(indexPath) as! String
let alertController = UIAlertController(title: "Item Selected", message: "Selected item: \(item)", preferredStyle: .Alert)
alertController.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
presentViewController(alertController, animated: true, completion: nil)
}
func tableController(tableController : TableController, tableView: UITableView, didHighlightRowAtIndexPath indexPath: NSIndexPath) {
}
}
|
gpl-3.0
|
85ada7481f8714a4c96481b348fc6342
| 31.54386 | 150 | 0.660377 | 6.288136 | false | false | false | false |
tecgirl/firefox-ios
|
Client/Frontend/Settings/AppSettingsOptions.swift
|
1
|
44217
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import Foundation
import Shared
import Account
import SwiftKeychainWrapper
import LocalAuthentication
// This file contains all of the settings available in the main settings screen of the app.
private var ShowDebugSettings: Bool = false
private var DebugSettingsClickCount: Int = 0
// For great debugging!
class HiddenSetting: Setting {
unowned let settings: SettingsTableViewController
init(settings: SettingsTableViewController) {
self.settings = settings
super.init(title: nil)
}
override var hidden: Bool {
return !ShowDebugSettings
}
}
// Sync setting for connecting a Firefox Account. Shown when we don't have an account.
class ConnectSetting: WithoutAccountSetting {
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var title: NSAttributedString? {
return NSAttributedString(string: Strings.FxASignInToSync, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override var accessibilityIdentifier: String? { return "SignInToSync" }
override func onClick(_ navigationController: UINavigationController?) {
let fxaParams = FxALaunchParams(query: ["entrypoint": "preferences"])
let viewController = FxAContentViewController(profile: profile, fxaOptions: fxaParams)
viewController.delegate = self
viewController.url = settings.profile.accountConfiguration.signInURL
navigationController?.pushViewController(viewController, animated: true)
}
override func onConfigureCell(_ cell: UITableViewCell) {
super.onConfigureCell(cell)
cell.imageView?.image = UIImage.templateImageNamed("FxA-Default")
cell.imageView?.tintColor = UIColor.theme.tableView.disabledRowText
cell.imageView?.layer.cornerRadius = (cell.imageView?.frame.size.width)! / 2
cell.imageView?.layer.masksToBounds = true
}
}
class SyncNowSetting: WithAccountSetting {
let imageView = UIImageView(frame: CGRect(width: 30, height: 30))
let syncIconWrapper = UIImage.createWithColor(CGSize(width: 30, height: 30), color: UIColor.clear)
let syncBlueIcon = UIImage(named: "FxA-Sync-Blue")?.createScaled(CGSize(width: 20, height: 20))
let syncIcon = UIImage(named: "FxA-Sync")?.createScaled(CGSize(width: 20, height: 20))
// Animation used to rotate the Sync icon 360 degrees while syncing is in progress.
let continuousRotateAnimation = CABasicAnimation(keyPath: "transform.rotation")
override init(settings: SettingsTableViewController) {
super.init(settings: settings)
NotificationCenter.default.addObserver(self, selector: #selector(stopRotateSyncIcon), name: .ProfileDidFinishSyncing, object: nil)
}
fileprivate lazy var timestampFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
return formatter
}()
fileprivate var syncNowTitle: NSAttributedString {
if !DeviceInfo.hasConnectivity() {
return NSAttributedString(
string: Strings.FxANoInternetConnection,
attributes: [
NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.errorText,
NSAttributedStringKey.font: DynamicFontHelper.defaultHelper.DefaultMediumFont
]
)
}
return NSAttributedString(
string: NSLocalizedString("Sync Now", comment: "Sync Firefox Account"),
attributes: [
NSAttributedStringKey.foregroundColor: self.enabled ? UIColor.theme.tableView.syncText : UIColor.theme.tableView.headerTextLight,
NSAttributedStringKey.font: DynamicFontHelper.defaultHelper.DefaultStandardFont
]
)
}
fileprivate let syncingTitle = NSAttributedString(string: Strings.SyncingMessageWithEllipsis, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.syncText, NSAttributedStringKey.font: UIFont.systemFont(ofSize: DynamicFontHelper.defaultHelper.DefaultStandardFontSize, weight: UIFont.Weight.regular)])
func startRotateSyncIcon() {
DispatchQueue.main.async {
self.imageView.layer.add(self.continuousRotateAnimation, forKey: "rotateKey")
}
}
@objc func stopRotateSyncIcon() {
DispatchQueue.main.async {
self.imageView.layer.removeAllAnimations()
}
}
override var accessoryType: UITableViewCellAccessoryType { return .none }
override var style: UITableViewCellStyle { return .value1 }
override var image: UIImage? {
guard let syncStatus = profile.syncManager.syncDisplayState else {
return syncIcon
}
switch syncStatus {
case .inProgress:
return syncBlueIcon
default:
return syncIcon
}
}
override var title: NSAttributedString? {
guard let syncStatus = profile.syncManager.syncDisplayState else {
return syncNowTitle
}
switch syncStatus {
case .bad(let message):
guard let message = message else { return syncNowTitle }
return NSAttributedString(string: message, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.errorText, NSAttributedStringKey.font: DynamicFontHelper.defaultHelper.DefaultStandardFont])
case .warning(let message):
return NSAttributedString(string: message, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.warningText, NSAttributedStringKey.font: DynamicFontHelper.defaultHelper.DefaultStandardFont])
case .inProgress:
return syncingTitle
default:
return syncNowTitle
}
}
override var status: NSAttributedString? {
guard let timestamp = profile.syncManager.lastSyncFinishTime else {
return nil
}
let formattedLabel = timestampFormatter.string(from: Date.fromTimestamp(timestamp))
let attributedString = NSMutableAttributedString(string: formattedLabel)
let attributes = [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.headerTextLight, NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12, weight: UIFont.Weight.regular)]
let range = NSRange(location: 0, length: attributedString.length)
attributedString.setAttributes(attributes, range: range)
return attributedString
}
override var enabled: Bool {
if !DeviceInfo.hasConnectivity() {
return false
}
return profile.hasSyncableAccount()
}
fileprivate lazy var troubleshootButton: UIButton = {
let troubleshootButton = UIButton(type: .roundedRect)
troubleshootButton.setTitle(Strings.FirefoxSyncTroubleshootTitle, for: .normal)
troubleshootButton.addTarget(self, action: #selector(self.troubleshoot), for: .touchUpInside)
troubleshootButton.tintColor = UIColor.theme.tableView.rowActionAccessory
troubleshootButton.titleLabel?.font = DynamicFontHelper.defaultHelper.DefaultSmallFont
troubleshootButton.sizeToFit()
return troubleshootButton
}()
fileprivate lazy var warningIcon: UIImageView = {
let imageView = UIImageView(image: UIImage(named: "AmberCaution"))
imageView.sizeToFit()
return imageView
}()
fileprivate lazy var errorIcon: UIImageView = {
let imageView = UIImageView(image: UIImage(named: "RedCaution"))
imageView.sizeToFit()
return imageView
}()
fileprivate let syncSUMOURL = SupportUtils.URLForTopic("sync-status-ios")
@objc fileprivate func troubleshoot() {
let viewController = SettingsContentViewController()
viewController.url = syncSUMOURL
settings.navigationController?.pushViewController(viewController, animated: true)
}
override func onConfigureCell(_ cell: UITableViewCell) {
cell.textLabel?.attributedText = title
cell.textLabel?.numberOfLines = 0
cell.textLabel?.lineBreakMode = .byWordWrapping
if let syncStatus = profile.syncManager.syncDisplayState {
switch syncStatus {
case .bad(let message):
if let _ = message {
// add the red warning symbol
// add a link to the MANA page
cell.detailTextLabel?.attributedText = nil
cell.accessoryView = troubleshootButton
addIcon(errorIcon, toCell: cell)
} else {
cell.detailTextLabel?.attributedText = status
cell.accessoryView = nil
}
case .warning(_):
// add the amber warning symbol
// add a link to the MANA page
cell.detailTextLabel?.attributedText = nil
cell.accessoryView = troubleshootButton
addIcon(warningIcon, toCell: cell)
case .good:
cell.detailTextLabel?.attributedText = status
fallthrough
default:
cell.accessoryView = nil
}
} else {
cell.accessoryView = nil
}
cell.accessoryType = accessoryType
cell.isUserInteractionEnabled = !profile.syncManager.isSyncing && DeviceInfo.hasConnectivity()
// Animation that loops continously until stopped
continuousRotateAnimation.fromValue = 0.0
continuousRotateAnimation.toValue = CGFloat(Double.pi)
continuousRotateAnimation.isRemovedOnCompletion = true
continuousRotateAnimation.duration = 0.5
continuousRotateAnimation.repeatCount = .infinity
// To ensure sync icon is aligned properly with user's avatar, an image is created with proper
// dimensions and color, then the scaled sync icon is added as a subview.
imageView.contentMode = .center
imageView.image = image
cell.imageView?.subviews.forEach({ $0.removeFromSuperview() })
cell.imageView?.image = syncIconWrapper
cell.imageView?.addSubview(imageView)
if let syncStatus = profile.syncManager.syncDisplayState {
switch syncStatus {
case .inProgress:
self.startRotateSyncIcon()
default:
self.stopRotateSyncIcon()
}
}
}
fileprivate func addIcon(_ image: UIImageView, toCell cell: UITableViewCell) {
cell.contentView.addSubview(image)
cell.textLabel?.snp.updateConstraints { make in
make.leading.equalTo(image.snp.trailing).offset(5)
make.trailing.lessThanOrEqualTo(cell.contentView)
make.centerY.equalTo(cell.contentView)
}
image.snp.makeConstraints { make in
make.leading.equalTo(cell.contentView).offset(17)
make.top.equalTo(cell.textLabel!).offset(2)
}
}
override func onClick(_ navigationController: UINavigationController?) {
if !DeviceInfo.hasConnectivity() {
return
}
NotificationCenter.default.post(name: .UserInitiatedSyncManually, object: nil)
profile.syncManager.syncEverything(why: .syncNow)
}
}
// Sync setting that shows the current Firefox Account status.
class AccountStatusSetting: WithAccountSetting {
override init(settings: SettingsTableViewController) {
super.init(settings: settings)
NotificationCenter.default.addObserver(self, selector: #selector(updateAccount), name: .FirefoxAccountProfileChanged, object: nil)
}
@objc func updateAccount(notification: Notification) {
DispatchQueue.main.async {
self.settings.tableView.reloadData()
}
}
override var image: UIImage? {
if let image = profile.getAccount()?.fxaProfile?.avatar.image {
return image.createScaled(CGSize(width: 30, height: 30))
}
let image = UIImage(named: "placeholder-avatar")
return image?.createScaled(CGSize(width: 30, height: 30))
}
override var accessoryType: UITableViewCellAccessoryType {
if let account = profile.getAccount() {
switch account.actionNeeded {
case .needsVerification:
// We link to the resend verification email page.
return .disclosureIndicator
case .needsPassword:
// We link to the re-enter password page.
return .disclosureIndicator
case .none:
// We link to FxA web /settings.
return .disclosureIndicator
case .needsUpgrade:
// In future, we'll want to link to an upgrade page.
return .none
}
}
return .disclosureIndicator
}
override var title: NSAttributedString? {
if let account = profile.getAccount() {
if let displayName = account.fxaProfile?.displayName {
return NSAttributedString(string: displayName, attributes: [NSAttributedStringKey.font: DynamicFontHelper.defaultHelper.DefaultStandardFontBold, NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.syncText])
}
if let email = account.fxaProfile?.email {
return NSAttributedString(string: email, attributes: [NSAttributedStringKey.font: DynamicFontHelper.defaultHelper.DefaultStandardFontBold, NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.syncText])
}
return NSAttributedString(string: account.email, attributes: [NSAttributedStringKey.font: DynamicFontHelper.defaultHelper.DefaultStandardFontBold, NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.syncText])
}
return nil
}
override var status: NSAttributedString? {
if let account = profile.getAccount() {
var string: String
switch account.actionNeeded {
case .none:
return nil
case .needsVerification:
string = Strings.FxAAccountVerifyEmail
break
case .needsPassword:
string = Strings.FxAAccountVerifyPassword
break
case .needsUpgrade:
string = Strings.FxAAccountUpgradeFirefox
break
}
let orange = UIColor.theme.tableView.warningText
let range = NSRange(location: 0, length: string.count)
let attrs = [NSAttributedStringKey.foregroundColor: orange]
let res = NSMutableAttributedString(string: string)
res.setAttributes(attrs, range: range)
return res
}
return nil
}
override func onClick(_ navigationController: UINavigationController?) {
let fxaParams = FxALaunchParams(query: ["entrypoint": "preferences"])
let viewController = FxAContentViewController(profile: profile, fxaOptions: fxaParams)
viewController.delegate = self
if let account = profile.getAccount() {
switch account.actionNeeded {
case .none:
let viewController = SyncContentSettingsViewController()
viewController.profile = profile
navigationController?.pushViewController(viewController, animated: true)
return
case .needsVerification:
var cs = URLComponents(url: account.configuration.settingsURL, resolvingAgainstBaseURL: false)
cs?.queryItems?.append(URLQueryItem(name: "email", value: account.email))
if let url = try? cs?.asURL() {
viewController.url = url
}
case .needsPassword:
var cs = URLComponents(url: account.configuration.forceAuthURL, resolvingAgainstBaseURL: false)
cs?.queryItems?.append(URLQueryItem(name: "email", value: account.email))
if let url = try? cs?.asURL() {
viewController.url = url
}
case .needsUpgrade:
// In future, we'll want to link to an upgrade page.
return
}
}
navigationController?.pushViewController(viewController, animated: true)
}
override func onConfigureCell(_ cell: UITableViewCell) {
super.onConfigureCell(cell)
if let imageView = cell.imageView {
imageView.subviews.forEach({ $0.removeFromSuperview() })
imageView.frame = CGRect(width: 30, height: 30)
imageView.layer.cornerRadius = (imageView.frame.height) / 2
imageView.layer.masksToBounds = true
imageView.image = image
}
}
}
// For great debugging!
class RequirePasswordDebugSetting: WithAccountSetting {
override var hidden: Bool {
if !ShowDebugSettings {
return true
}
if let account = profile.getAccount(), account.actionNeeded != FxAActionNeeded.needsPassword {
return false
}
return true
}
override var title: NSAttributedString? {
return NSAttributedString(string: NSLocalizedString("Debug: require password", comment: "Debug option"), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override func onClick(_ navigationController: UINavigationController?) {
profile.getAccount()?.makeSeparated()
settings.tableView.reloadData()
}
}
// For great debugging!
class RequireUpgradeDebugSetting: WithAccountSetting {
override var hidden: Bool {
if !ShowDebugSettings {
return true
}
if let account = profile.getAccount(), account.actionNeeded != FxAActionNeeded.needsUpgrade {
return false
}
return true
}
override var title: NSAttributedString? {
return NSAttributedString(string: NSLocalizedString("Debug: require upgrade", comment: "Debug option"), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override func onClick(_ navigationController: UINavigationController?) {
profile.getAccount()?.makeDoghouse()
settings.tableView.reloadData()
}
}
// For great debugging!
class ForgetSyncAuthStateDebugSetting: WithAccountSetting {
override var hidden: Bool {
if !ShowDebugSettings {
return true
}
if let _ = profile.getAccount() {
return false
}
return true
}
override var title: NSAttributedString? {
return NSAttributedString(string: NSLocalizedString("Debug: forget Sync auth state", comment: "Debug option"), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override func onClick(_ navigationController: UINavigationController?) {
profile.getAccount()?.syncAuthState.invalidate()
settings.tableView.reloadData()
}
}
class DeleteExportedDataSetting: HiddenSetting {
override var title: NSAttributedString? {
// Not localized for now.
return NSAttributedString(string: "Debug: delete exported databases", attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override func onClick(_ navigationController: UINavigationController?) {
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let fileManager = FileManager.default
do {
let files = try fileManager.contentsOfDirectory(atPath: documentsPath)
for file in files {
if file.hasPrefix("browser.") || file.hasPrefix("logins.") {
try fileManager.removeItemInDirectory(documentsPath, named: file)
}
}
} catch {
print("Couldn't delete exported data: \(error).")
}
}
}
class ExportBrowserDataSetting: HiddenSetting {
override var title: NSAttributedString? {
// Not localized for now.
return NSAttributedString(string: "Debug: copy databases to app container", attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override func onClick(_ navigationController: UINavigationController?) {
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
do {
let log = Logger.syncLogger
try self.settings.profile.files.copyMatching(fromRelativeDirectory: "", toAbsoluteDirectory: documentsPath) { file in
log.debug("Matcher: \(file)")
return file.hasPrefix("browser.") || file.hasPrefix("logins.") || file.hasPrefix("metadata.")
}
} catch {
print("Couldn't export browser data: \(error).")
}
}
}
/*
FeatureSwitchSetting is a boolean switch for features that are enabled via a FeatureSwitch.
These are usually features behind a partial release and not features released to the entire population.
*/
class FeatureSwitchSetting: BoolSetting {
let featureSwitch: FeatureSwitch
let prefs: Prefs
init(prefs: Prefs, featureSwitch: FeatureSwitch, with title: NSAttributedString) {
self.featureSwitch = featureSwitch
self.prefs = prefs
super.init(prefs: prefs, defaultValue: featureSwitch.isMember(prefs), attributedTitleText: title)
}
override var hidden: Bool {
return !ShowDebugSettings
}
override func displayBool(_ control: UISwitch) {
control.isOn = featureSwitch.isMember(prefs)
}
override func writeBool(_ control: UISwitch) {
self.featureSwitch.setMembership(control.isOn, for: self.prefs)
}
}
class EnableBookmarkMergingSetting: HiddenSetting {
override var title: NSAttributedString? {
// Not localized for now.
return NSAttributedString(string: "Enable Bidirectional Bookmark Sync ", attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override func onClick(_ navigationController: UINavigationController?) {
AppConstants.shouldMergeBookmarks = true
}
}
class ForceCrashSetting: HiddenSetting {
override var title: NSAttributedString? {
return NSAttributedString(string: "Debug: Force Crash", attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override func onClick(_ navigationController: UINavigationController?) {
Sentry.shared.crash()
}
}
// Show the current version of Firefox
class VersionSetting: Setting {
unowned let settings: SettingsTableViewController
override var accessibilityIdentifier: String? { return "FxVersion" }
init(settings: SettingsTableViewController) {
self.settings = settings
super.init(title: nil)
}
override var title: NSAttributedString? {
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
let buildNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String
return NSAttributedString(string: String(format: NSLocalizedString("Version %@ (%@)", comment: "Version number of Firefox shown in settings"), appVersion, buildNumber), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override func onConfigureCell(_ cell: UITableViewCell) {
super.onConfigureCell(cell)
cell.selectionStyle = .none
}
override func onClick(_ navigationController: UINavigationController?) {
DebugSettingsClickCount += 1
if DebugSettingsClickCount >= 5 {
DebugSettingsClickCount = 0
ShowDebugSettings = !ShowDebugSettings
settings.tableView.reloadData()
}
}
}
// Opens the the license page in a new tab
class LicenseAndAcknowledgementsSetting: Setting {
override var title: NSAttributedString? {
return NSAttributedString(string: NSLocalizedString("Licenses", comment: "Settings item that opens a tab containing the licenses. See http://mzl.la/1NSAWCG"), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override var url: URL? {
return URL(string: WebServer.sharedInstance.URLForResource("license", module: "about"))
}
override func onClick(_ navigationController: UINavigationController?) {
setUpAndPushSettingsContentViewController(navigationController)
}
}
// Opens about:rights page in the content view controller
class YourRightsSetting: Setting {
override var title: NSAttributedString? {
return NSAttributedString(string: NSLocalizedString("Your Rights", comment: "Your Rights settings section title"), attributes:
[NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override var url: URL? {
return URL(string: "https://www.mozilla.org/about/legal/terms/firefox/")
}
override func onClick(_ navigationController: UINavigationController?) {
setUpAndPushSettingsContentViewController(navigationController)
}
}
// Opens the on-boarding screen again
class ShowIntroductionSetting: Setting {
let profile: Profile
override var accessibilityIdentifier: String? { return "ShowTour" }
init(settings: SettingsTableViewController) {
self.profile = settings.profile
super.init(title: NSAttributedString(string: NSLocalizedString("Show Tour", comment: "Show the on-boarding screen again from the settings"), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]))
}
override func onClick(_ navigationController: UINavigationController?) {
navigationController?.dismiss(animated: true, completion: {
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
appDelegate.browserViewController.presentIntroViewController(true)
}
})
}
}
class SendFeedbackSetting: Setting {
override var title: NSAttributedString? {
return NSAttributedString(string: NSLocalizedString("Send Feedback", comment: "Menu item in settings used to open input.mozilla.org where people can submit feedback"), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override var url: URL? {
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
return URL(string: "https://input.mozilla.org/feedback/fxios/\(appVersion)")
}
override func onClick(_ navigationController: UINavigationController?) {
setUpAndPushSettingsContentViewController(navigationController)
}
}
class SendAnonymousUsageDataSetting: BoolSetting {
init(prefs: Prefs, delegate: SettingsDelegate?) {
let statusText = NSMutableAttributedString()
statusText.append(NSAttributedString(string: Strings.SendUsageSettingMessage, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.headerTextLight]))
statusText.append(NSAttributedString(string: " "))
statusText.append(NSAttributedString(string: Strings.SendUsageSettingLink, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.general.highlightBlue]))
super.init(
prefs: prefs, prefKey: AppConstants.PrefSendUsageData, defaultValue: true,
attributedTitleText: NSAttributedString(string: Strings.SendUsageSettingTitle),
attributedStatusText: statusText,
settingDidChange: {
AdjustIntegration.setEnabled($0)
LeanPlumClient.shared.set(attributes: [LPAttributeKey.telemetryOptIn: $0])
LeanPlumClient.shared.set(enabled: $0)
}
)
}
override var url: URL? {
return SupportUtils.URLForTopic("adjust")
}
override func onClick(_ navigationController: UINavigationController?) {
setUpAndPushSettingsContentViewController(navigationController)
}
}
// Opens the the SUMO page in a new tab
class OpenSupportPageSetting: Setting {
init(delegate: SettingsDelegate?) {
super.init(title: NSAttributedString(string: NSLocalizedString("Help", comment: "Show the SUMO support page from the Support section in the settings. see http://mzl.la/1dmM8tZ"), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]),
delegate: delegate)
}
override func onClick(_ navigationController: UINavigationController?) {
navigationController?.dismiss(animated: true) {
if let url = URL(string: "https://support.mozilla.org/products/ios") {
self.delegate?.settingsOpenURLInNewTab(url)
}
}
}
}
// Opens the search settings pane
class SearchSetting: Setting {
let profile: Profile
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var style: UITableViewCellStyle { return .value1 }
override var status: NSAttributedString { return NSAttributedString(string: profile.searchEngines.defaultEngine.shortName) }
override var accessibilityIdentifier: String? { return "Search" }
init(settings: SettingsTableViewController) {
self.profile = settings.profile
super.init(title: NSAttributedString(string: NSLocalizedString("Search", comment: "Open search section of settings"), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]))
}
override func onClick(_ navigationController: UINavigationController?) {
let viewController = SearchSettingsTableViewController()
viewController.model = profile.searchEngines
viewController.profile = profile
navigationController?.pushViewController(viewController, animated: true)
}
}
class LoginsSetting: Setting {
let profile: Profile
var tabManager: TabManager!
weak var navigationController: UINavigationController?
weak var settings: AppSettingsTableViewController?
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var accessibilityIdentifier: String? { return "Logins" }
init(settings: SettingsTableViewController, delegate: SettingsDelegate?) {
self.profile = settings.profile
self.tabManager = settings.tabManager
self.navigationController = settings.navigationController
self.settings = settings as? AppSettingsTableViewController
let loginsTitle = NSLocalizedString("Logins", comment: "Label used as an item in Settings. When touched, the user will be navigated to the Logins/Password manager.")
super.init(title: NSAttributedString(string: loginsTitle, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]),
delegate: delegate)
}
func deselectRow () {
if let selectedRow = self.settings?.tableView.indexPathForSelectedRow {
self.settings?.tableView.deselectRow(at: selectedRow, animated: true)
}
}
override func onClick(_: UINavigationController?) {
guard let authInfo = KeychainWrapper.sharedAppContainerKeychain.authenticationInfo() else {
settings?.navigateToLoginsList()
LeanPlumClient.shared.track(event: .openedLogins)
return
}
if authInfo.requiresValidation() {
AppAuthenticator.presentAuthenticationUsingInfo(authInfo,
touchIDReason: AuthenticationStrings.loginsTouchReason,
success: {
self.settings?.navigateToLoginsList()
LeanPlumClient.shared.track(event: .openedLogins)
},
cancel: {
self.deselectRow()
},
fallback: {
AppAuthenticator.presentPasscodeAuthentication(self.navigationController, delegate: self.settings)
self.deselectRow()
})
} else {
settings?.navigateToLoginsList()
LeanPlumClient.shared.track(event: .openedLogins)
}
}
}
class TouchIDPasscodeSetting: Setting {
let profile: Profile
var tabManager: TabManager!
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var accessibilityIdentifier: String? { return "TouchIDPasscode" }
init(settings: SettingsTableViewController, delegate: SettingsDelegate? = nil) {
self.profile = settings.profile
self.tabManager = settings.tabManager
let localAuthContext = LAContext()
let title: String
if localAuthContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) {
if #available(iOS 11.0, *), localAuthContext.biometryType == .faceID {
title = AuthenticationStrings.faceIDPasscodeSetting
} else {
title = AuthenticationStrings.touchIDPasscodeSetting
}
} else {
title = AuthenticationStrings.passcode
}
super.init(title: NSAttributedString(string: title, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]),
delegate: delegate)
}
override func onClick(_ navigationController: UINavigationController?) {
let viewController = AuthenticationSettingsViewController()
viewController.profile = profile
navigationController?.pushViewController(viewController, animated: true)
}
}
@available(iOS 11, *)
class ContentBlockerSetting: Setting {
let profile: Profile
var tabManager: TabManager!
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var accessibilityIdentifier: String? { return "TrackingProtection" }
init(settings: SettingsTableViewController) {
self.profile = settings.profile
self.tabManager = settings.tabManager
super.init(title: NSAttributedString(string: Strings.SettingsTrackingProtectionSectionName, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]))
}
override func onClick(_ navigationController: UINavigationController?) {
let viewController = ContentBlockerSettingViewController(prefs: profile.prefs)
viewController.profile = profile
viewController.tabManager = tabManager
navigationController?.pushViewController(viewController, animated: true)
}
}
class ClearPrivateDataSetting: Setting {
let profile: Profile
var tabManager: TabManager!
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var accessibilityIdentifier: String? { return "ClearPrivateData" }
init(settings: SettingsTableViewController) {
self.profile = settings.profile
self.tabManager = settings.tabManager
let clearTitle = Strings.SettingsClearPrivateDataSectionName
super.init(title: NSAttributedString(string: clearTitle, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]))
}
override func onClick(_ navigationController: UINavigationController?) {
let viewController = ClearPrivateDataTableViewController()
viewController.profile = profile
viewController.tabManager = tabManager
navigationController?.pushViewController(viewController, animated: true)
}
}
class PrivacyPolicySetting: Setting {
override var title: NSAttributedString? {
return NSAttributedString(string: NSLocalizedString("Privacy Policy", comment: "Show Firefox Browser Privacy Policy page from the Privacy section in the settings. See https://www.mozilla.org/privacy/firefox/"), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override var url: URL? {
return URL(string: "https://www.mozilla.org/privacy/firefox/")
}
override func onClick(_ navigationController: UINavigationController?) {
setUpAndPushSettingsContentViewController(navigationController)
}
}
class ChinaSyncServiceSetting: WithoutAccountSetting {
override var accessoryType: UITableViewCellAccessoryType { return .none }
var prefs: Prefs { return settings.profile.prefs }
let prefKey = "useChinaSyncService"
override var title: NSAttributedString? {
return NSAttributedString(string: "本地同步服务", attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override var status: NSAttributedString? {
return NSAttributedString(string: "禁用后使用全球服务同步数据", attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.headerTextLight])
}
override func onConfigureCell(_ cell: UITableViewCell) {
super.onConfigureCell(cell)
let control = UISwitch()
control.onTintColor = UIColor.theme.tableView.controlTint
control.addTarget(self, action: #selector(switchValueChanged), for: .valueChanged)
control.isOn = prefs.boolForKey(prefKey) ?? self.profile.isChinaEdition
cell.accessoryView = control
cell.selectionStyle = .none
}
@objc func switchValueChanged(_ toggle: UISwitch) {
prefs.setObject(toggle.isOn, forKey: prefKey)
}
}
class StageSyncServiceDebugSetting: WithoutAccountSetting {
override var accessoryType: UITableViewCellAccessoryType { return .none }
var prefs: Prefs { return settings.profile.prefs }
var prefKey: String = "useStageSyncService"
override var accessibilityIdentifier: String? { return "DebugStageSync" }
override var hidden: Bool {
if !ShowDebugSettings {
return true
}
if let _ = profile.getAccount() {
return true
}
return false
}
override var title: NSAttributedString? {
return NSAttributedString(string: NSLocalizedString("Debug: use stage servers", comment: "Debug option"), attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override var status: NSAttributedString? {
// Derive the configuration we display from the profile. Currently, this could be either a custom
// FxA server or FxA stage servers.
let isOn = prefs.boolForKey(prefKey) ?? false
let isCustomSync = prefs.boolForKey(PrefsKeys.KeyUseCustomSyncService) ?? false
var configurationURL = ProductionFirefoxAccountConfiguration().authEndpointURL
if isCustomSync {
configurationURL = CustomFirefoxAccountConfiguration(prefs: profile.prefs).authEndpointURL
} else if isOn {
configurationURL = StageFirefoxAccountConfiguration().authEndpointURL
}
return NSAttributedString(string: configurationURL.absoluteString, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.headerTextLight])
}
override func onConfigureCell(_ cell: UITableViewCell) {
super.onConfigureCell(cell)
let control = UISwitch()
control.onTintColor = UIColor.theme.tableView.controlTint
control.addTarget(self, action: #selector(switchValueChanged), for: .valueChanged)
control.isOn = prefs.boolForKey(prefKey) ?? false
cell.accessoryView = control
cell.selectionStyle = .none
}
@objc func switchValueChanged(_ toggle: UISwitch) {
prefs.setObject(toggle.isOn, forKey: prefKey)
settings.tableView.reloadData()
}
}
class HomePageSetting: Setting {
let profile: Profile
var tabManager: TabManager!
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var accessibilityIdentifier: String? { return "Homepage" }
init(settings: SettingsTableViewController) {
self.profile = settings.profile
self.tabManager = settings.tabManager
super.init(title: NSAttributedString(string: Strings.SettingsHomePageSectionName, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]))
}
override func onClick(_ navigationController: UINavigationController?) {
let viewController = HomePageSettingsViewController()
viewController.profile = profile
viewController.tabManager = tabManager
navigationController?.pushViewController(viewController, animated: true)
}
}
class NewTabPageSetting: Setting {
let profile: Profile
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var accessibilityIdentifier: String? { return "NewTab" }
init(settings: SettingsTableViewController) {
self.profile = settings.profile
super.init(title: NSAttributedString(string: Strings.SettingsNewTabSectionName, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]))
}
override func onClick(_ navigationController: UINavigationController?) {
let viewController = NewTabContentSettingsViewController(prefs: profile.prefs)
viewController.profile = profile
navigationController?.pushViewController(viewController, animated: true)
}
}
class OpenWithSetting: Setting {
let profile: Profile
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var accessibilityIdentifier: String? { return "OpenWith.Setting" }
init(settings: SettingsTableViewController) {
self.profile = settings.profile
super.init(title: NSAttributedString(string: Strings.SettingsOpenWithSectionName, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]))
}
override func onClick(_ navigationController: UINavigationController?) {
let viewController = OpenWithSettingsViewController(prefs: profile.prefs)
navigationController?.pushViewController(viewController, animated: true)
}
}
class AdvanceAccountSetting: HiddenSetting {
let profile: Profile
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var accessibilityIdentifier: String? { return "AdvanceAccount.Setting" }
override var title: NSAttributedString? {
return NSAttributedString(string: Strings.SettingsAdvanceAccountTitle, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText])
}
override init(settings: SettingsTableViewController) {
self.profile = settings.profile
super.init(settings: settings)
}
override func onClick(_ navigationController: UINavigationController?) {
let viewController = AdvanceAccountSettingViewController()
viewController.profile = profile
navigationController?.pushViewController(viewController, animated: true)
}
override var hidden: Bool {
return !ShowDebugSettings || profile.hasAccount()
}
}
class ThemeSetting: Setting {
let profile: Profile
override var accessoryType: UITableViewCellAccessoryType { return .disclosureIndicator }
override var style: UITableViewCellStyle { return .value1 }
override var accessibilityIdentifier: String? { return "DisplayThemeOption" }
init(settings: SettingsTableViewController) {
self.profile = settings.profile
super.init(title: NSAttributedString(string: Strings.SettingsDisplayThemeTitle, attributes: [NSAttributedStringKey.foregroundColor: UIColor.theme.tableView.rowText]))
}
override func onClick(_ navigationController: UINavigationController?) {
navigationController?.pushViewController(ThemeSettingsController(), animated: true)
}
}
|
mpl-2.0
|
ff552155d4b0d4e01d513e05b11ae2c5
| 40.288785 | 327 | 0.695421 | 5.775033 | false | false | false | false |
tiagomartinho/webhose-cocoa
|
webhose-cocoa/Webhose/WebhoseClient.swift
|
1
|
1326
|
open class WebhoseClient {
open weak var delegate: WebhoseClientDelegate?
public typealias WebhoseResponseCallback = (WebhoseResponse) -> Void
let key: String
let service: Service
public init(key: String) {
self.key = key
self.service = AlamofireService()
}
open func search(_ query: WebhoseQuery, callback: WebhoseResponseCallback? = nil) {
let endpoint = WebhoseEndpoint.buildWithKey(key, AndQuery: query)
service(endpoint, callback: callback)
}
open func search(_ query: String, callback: WebhoseResponseCallback? = nil) {
let endpoint = WebhoseEndpoint.buildWithKey(key, AndQuery: query)
service(endpoint, callback: callback)
}
open func more(_ response: WebhoseResponse, callback: WebhoseResponseCallback? = nil) {
let endpoint = response.next
service(endpoint, callback: callback)
}
fileprivate func service(_ endpoint: String, callback: WebhoseResponseCallback?) {
service.get(endpoint) { [unowned self] data in
guard let data = data else { return }
let response = WebhoseResponse(data: data)
self.delegate?.didEndSearchWithResponse(response)
if let callback = callback {
callback(response)
}
}
}
}
|
mit
|
e4bcd5d9eca45feda9bf4f466790bd9c
| 32.15 | 91 | 0.651584 | 4.636364 | false | false | false | false |
YunsChou/LovePlay
|
LovePlay-Swift3/LovePlay/Class/Zone/View/DiscussDetailPostCell.swift
|
1
|
4511
|
//
// DiscussDetailPostCell.swift
// LovePlay
//
// Created by Yuns on 2017/6/11.
// Copyright © 2017年 yuns. All rights reserved.
//
import UIKit
class DiscussDetailPostCell: UITableViewCell {
var post : DiscussDetailPost?
var floor : Int?
class func cellWithTableView(tableView : UITableView) -> DiscussDetailPostCell {
let ID = NSStringFromClass(self)
var cell : DiscussDetailPostCell? = tableView.dequeueReusableCell(withIdentifier: ID) as? DiscussDetailPostCell
if cell == nil {
cell = DiscussDetailPostCell(style: .default, reuseIdentifier: ID)
}
return cell!
}
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
self.addSubViews()
self.snp_subViews()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - private
private func addSubViews() {
self.contentView.addSubview(self.imgView)
self.contentView.addSubview(self.nameTextLabel)
self.contentView.addSubview(self.timeTextLabel)
self.contentView.addSubview(self.floorTextLabel)
self.contentView.addSubview(self.contentTextLabel)
self.contentView.addSubview(self.underLineView)
}
private func snp_subViews() {
self.imgView.snp.makeConstraints { (make) in
make.width.height.equalTo(30)
make.top.left.equalToSuperview().offset(10)
}
self.nameTextLabel.snp.makeConstraints { (make) in
make.left.equalTo(self.imgView.snp.right).offset(10)
make.centerY.equalTo(self.imgView)
}
self.timeTextLabel.snp.makeConstraints { (make) in
make.left.equalTo(self.nameTextLabel.snp.right).offset(10).priority(.medium)
make.right.equalTo(self.floorTextLabel.snp.left).offset(-10).priority(.low)
make.centerY.equalTo(self.imgView)
}
self.floorTextLabel.snp.makeConstraints { (make) in
make.right.equalToSuperview().offset(-10)
make.centerY.equalTo(self.imgView)
}
self.contentTextLabel.snp.makeConstraints { (make) in
make.top.equalTo(self.imgView.snp.bottom).offset(10)
make.left.equalToSuperview().offset(10)
make.right.equalToSuperview().offset(-10)
}
self.underLineView.snp.makeConstraints { (make) in
make.height.equalTo(0.5)
make.top.equalTo(self.contentTextLabel.snp.bottom).offset(10)
make.left.bottom.right.equalToSuperview()
}
}
// MARK: - publick
public func setupDiscussDetailComment(post : DiscussDetailPost, floor : Int) {
self.post = post
self.floor = floor
self.nameTextLabel.text = post.author
self.timeTextLabel.text = post.dateline?.replacingOccurrences(of: " ", with: "")
self.floorTextLabel.text = "\(floor)#"
self.contentTextLabel.text = post.message
}
// MARK: - setter / getter
lazy var imgView : UIImageView = {
let imgView : UIImageView = UIImageView()
imgView.image = UIImage(named: "defult_pho")
return imgView
}()
lazy var nameTextLabel : UILabel = {
let label : UILabel = UILabel()
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = RGB(r: 186, g: 177, b: 161)
return label
}()
lazy var timeTextLabel : UILabel = {
let label : UILabel = UILabel()
label.font = UIFont.systemFont(ofSize: 12)
label.textColor = RGB(r: 163, g: 163, b: 163)
return label
}()
lazy var floorTextLabel : UILabel = {
let label : UILabel = UILabel()
label.font = UIFont.systemFont(ofSize: 12)
label.textColor = RGB(r: 163, g: 163, b: 163)
return label
}()
lazy var contentTextLabel : UILabel = {
let label : UILabel = UILabel()
label.numberOfLines = 0
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = RGB(r: 50, g: 50, b: 50)
return label
}()
lazy var underLineView : UIView = {
let lineView : UIView = UIView()
lineView.backgroundColor = RGB(r: 222, g: 222, b: 222)
return lineView
}()
}
|
mit
|
8d8c90928bedfc8bf9d07825afa0e22b
| 32.392593 | 119 | 0.612023 | 4.301527 | false | false | false | false |
tassiahmed/SplitScreen
|
OSX/SplitScreen/SnapPoint.swift
|
1
|
5712
|
//
// SnapPoint.swift
// SplitScreen
//
// Created by Evan Thompson on 3/4/16.
// Copyright © 2016 SplitScreen. All rights reserved.
//
import Foundation
import AppKit
class SnapPoint {
fileprivate var snap_areas: [( (Int, Int), (Int, Int) )]
fileprivate var screen_dimensions, snap_dimensions, snap_location: (Int, Int)
/**
Initializes the SnapPoint
- Parameter screen_dim: The dimensions for the `Screen` the `SnapPoint` belongs to
- Parameter snap_dim: The dimensions of the window when snapping from this `SnapPoint`
- Parameter snap_loc: The location of the window upon snapping
*/
init(screen_dim: (Int, Int), snap_dim: (Int, Int), snap_loc: (Int, Int)) {
snap_areas = []
screen_dimensions = screen_dim
snap_dimensions = snap_dim
snap_location = snap_loc
}
/**
Adds a new area for the SnapPoint to trigger
NOTE: At least 1 value in both `first` and `second` must be `0`
- Parameter first: top left corner of the area
- Parameter second: bottom right corner of the area
*/
func add_snap_point(first: (Int, Int), second: (Int, Int)) {
if first.0 > second.0 || first.1 > second.1 {
return
}
snap_areas.append( (first, second) )
}
/**
Checks to see if the point falls under any of the snap areas
- Parameter x: `x` coordinate of the point
- Parameter y: `y` coordinate of the point
- Returns: `true` if the point `(x, y)` falls in any snap_area; `false` otherwise
*/
func check_point(x: Int, y: Int) -> Bool {
let (width_factor, height_factor) = get_scale_factors()
for snap_area in snap_areas {
if x < snap_area.0.0 * width_factor || x > snap_area.1.0 * width_factor {
continue
}
if y < snap_area.0.1 * height_factor || y > snap_area.1.1 * height_factor {
continue
}
return true
}
return false
}
/**
- Returns: `tuple` of `(Int, Int)` of the scaled top-left corner of `SnapPoint`
*/
func get_snap_location() -> (Int, Int) {
let (width_factor, height_factor) = get_scale_factors()
return ( snap_location.0 * width_factor, snap_location.1 * height_factor )
}
/**
- Returns: `tuple` of `(Int, Int)` of the scaled dimensions of `SnapPoint`
*/
func get_snap_dimensions() -> (Int, Int) {
let (width_factor, height_factor) = get_scale_factors()
return ( snap_dimensions.0 * width_factor, snap_dimensions.1 * height_factor )
}
/**
- Returns: `tuple` of `(Int, Int)` SnapPoint's corresponding `Screen` resolution
*/
func get_orig_screen_resolution() -> (Int, Int) {
return screen_dimensions
}
/**
- Returns: `String` representation of the `SnapPoint`
*/
func to_string() -> String {
var result: String = String()
result += get_string_scalar_rep(scalar: snap_dimensions.0,
original: screen_dimensions.0,
original_string: "WIDTH")
result.append(",")
result += get_string_scalar_rep(scalar: snap_dimensions.1,
original: screen_dimensions.1,
original_string: "HEIGHT")
result.append(",")
result += get_string_scalar_rep(scalar: snap_location.0,
original: screen_dimensions.0,
original_string: "WIDTH")
result.append(",")
result += get_string_scalar_rep(scalar: snap_location.1,
original: screen_dimensions.1,
original_string: "HEIGHT")
for snap_area in snap_areas {
result.append(",")
result += get_string_point(point: snap_area.0)
result.append(":")
result += get_string_point(point: snap_area.1)
}
result.append("\n" as Character)
return result
}
//*************************************************
// Private Functions
//*************************************************
/**
- Returns: `tuple` of `(Int, Int)` of sacle factors for resolution adjustments
*/
fileprivate func get_scale_factors() -> (Int, Int) {
let width_factor = CGFloat(screen_dimensions.0)/(NSScreen.main?.frame.width)!
let height_factor = CGFloat(screen_dimensions.1)/(NSScreen.main?.frame.height)!
return (Int(width_factor), Int(height_factor))
}
/**
Returns the scalar's `String` representation of the value relative the value of `original`
- Parameter scalar: `Int` that is a variable value of the SnapPoint
- Parameter original: `Int` that corresponds to either the screen's width or height
- Parameter original_string: `String` representation of the `original` value; either WIDTH or HEIGHT
- Returns: `String` that represents the scalar in terms of its relationship to `original`
*/
fileprivate func get_string_scalar_rep(scalar: Int, original: Int, original_string: String) -> String {
if scalar == 0 {
return "0"
} else if (scalar + 1) == original {
return "\(original_string)-1"
} else if original == scalar {
return "\(original_string)"
}
let scale = Int(float_t(original)/float_t(scalar))
return "\(original_string)/\(scale)"
}
/**
Returns a `String` that stands for the snap locations of the `SnapPoint`
- Parameter point: `tuple` that corresponds to a snap coordinate
- Returns: `String` that represents the snap location
*/
fileprivate func get_string_point(point: (Int, Int)) -> String {
let scalar_x = get_string_scalar_rep(scalar: point.0,
original: screen_dimensions.0,
original_string: "WIDTH")
let scalar_y = get_string_scalar_rep(scalar: point.1,
original: screen_dimensions.1,
original_string: "HEIGHT")
return "(\(scalar_x);\(scalar_y))"
}
}
|
apache-2.0
|
a5094e93160e8f94c8a5809e75ffdced
| 29.216931 | 104 | 0.616179 | 3.484442 | false | false | false | false |
wireapp/wire-ios
|
Wire-iOS Tests/ConversationMessageCell/ConversationImageMessageTests.swift
|
1
|
2374
|
//
// Wire
// Copyright (C) 2018 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
import XCTest
@testable import Wire
final class ConversationImageMessageTests: ZMSnapshotTestCase {
var image: UIImage!
var message: MockMessage!
override func setUp() {
super.setUp()
UIColor.setAccentOverride(.vividRed)
}
override func tearDown() {
image = nil
message = nil
MediaAssetCache.defaultImageCache.cache.removeAllObjects()
super.tearDown()
}
private func createSut(imageName: String) {
image = image(inTestBundleNamed: imageName)
message = MockMessageFactory.imageMessage(with: image)
let sender = MockUserType.createDefaultOtherUser()
message.senderUser = sender
}
func testTransparentImage() {
// GIVEN
createSut(imageName: "transparent.png")
// THEN
verify(message: message, waitForImagesToLoad: true)
}
func testOpaqueImage() {
// GIVEN
createSut(imageName: "unsplash_matterhorn.jpg")
// THEN
verify(message: message, waitForImagesToLoad: true)
}
func testNotDownloadedImage() {
// GIVEN
createSut(imageName: "unsplash_matterhorn.jpg")
// THEN
verify(message: message)
}
func testObfuscatedImage() {
// GIVEN
createSut(imageName: "unsplash_matterhorn.jpg")
message.isObfuscated = true
// THEN
verify(message: message)
}
// MARK: - Receiving restrictions
func testRestrictionMessageCell() {
createSut(imageName: "unsplash_matterhorn.jpg")
message.backingIsRestricted = true
verify(message: message, allColorSchemes: true)
}
}
|
gpl-3.0
|
6b237355b3050561afb966dbbd48f4db
| 25.377778 | 71 | 0.663437 | 4.618677 | false | true | false | false |
ikuehne/Papaya
|
Sources/Algorithms.swift
|
1
|
9044
|
/**
A file for basic graph algorithms, such as BFS, DFS, matchings, etc.
*/
/**
An array extension to pop the last element from an array.
*/
private extension Array {
mutating func pop() -> Element {
let element = self[self.count-1]
self.removeAtIndex(self.count-1)
return element
}
}
/**
A basic queue structure used by BFS algorithm.
*/
private struct Queue<Element> {
var items = [Element]()
mutating func enqueue(item: Element) {
items.insert(item, atIndex: 0)
}
mutating func dequeue() -> Element {
/*
let element = items[items.count-1]
items.removeAtIndex(items.count-1)
return element
*/
return items.pop()
}
var isEmpty : Bool {
return items.count == 0
}
}
/**
Creates a dictionary of successors in a graph, using the BFS algorithm and
starting at a given vertex.
- parameter graph: The graph to search in.
- parameter start: The vertex from which to begin the BFS.
- returns: A dictionary of each vertex's parent, or the vertex visited just
before the vertex.
*/
private func buildBFSParentDict<G: Graph, V: Hashable where V == G.Vertex>(
graph: G, start: V) -> [V: V] {
var queue = Queue<V>()
var visited = Set<V>()
var current: V
var result = [V: V]()
queue.enqueue(start)
visited.insert(start)
result[start] = start
while !queue.isEmpty {
current = queue.dequeue()
let neighbors = try! graph.neighbors(current)
for neighbor in neighbors {
if !visited.contains(neighbor) {
queue.enqueue(neighbor)
result[neighbor] = current
visited.insert(neighbor)
}
}
}
return result
}
/**
Gives the shortest path from one vertex to another in an unweighted graph.
- parameter graph: The graph in which to search.
- parameter start: The vertex from which to start the BFS.
- parameter end: The destination vertex.
- returns: An optional array that gives the shortest path from start to end.
returns nil if no such path exists.
*/
public func breadthFirstPath<G: Graph, V: Hashable where V == G.Vertex>(
graph: G, start: V, end: V) -> [V]? {
let parentsDictionary = buildBFSParentDict(graph, start: start)
var result: [V] = [end]
if end == start {
return result
}
if let first = parentsDictionary[end] {
var current = first
while current != start {
result.insert(current, atIndex: 0)
current = parentsDictionary[current]!
}
} else {
return nil
}
result.insert(start, atIndex: 0)
return result
}
// Idea- When lots of shortest paths queries are expected, there should be a
// way to store the parentsDictionary so it's only computed once.
/**
A structure describing a weighted edge. Prim's algorithm priority queue
holds these.
*/
private struct WeightedEdge<Vertex> {
let from: Vertex
let to: Vertex
let weight: Double
}
/**
Runs Prim's algorithm on a weighted undirected graph.
- parameter graph: A weighted undirected graph for which to create a minimum
spanning tree.
- returns: A minimum spanning tree of the input graph.
*/
public func primsSpanningTree<G: WeightedGraph where G.Vertex: Hashable>(
graph: G) -> G {
var tree = G()
var addedVerts = Set<G.Vertex>()
var queue = PriorityHeap<WeightedEdge<G.Vertex>>()
{ $0.weight < $1.weight }
let firstVertex = graph.vertices[0]
try! tree.addVertex(firstVertex)
addedVerts.insert(firstVertex)
for neighbor in try! graph.neighbors(firstVertex) {
let weight = try! graph.weight(firstVertex, to: neighbor)!
queue.insert(WeightedEdge<G.Vertex>(from: firstVertex, to: neighbor,
weight: weight))
}
var currentEdge: WeightedEdge<G.Vertex>
let target = graph.vertices.count
// currently, vertices is computed many times for each graph.
// trade some space for time and store sets of vertices?
while addedVerts.count < target {
repeat {
currentEdge = queue.extract()!
} while addedVerts.contains(currentEdge.to)
// can cause infinite loop?
// can cause unwrapping of nil?
try! tree.addVertex(currentEdge.to)
try! tree.addEdge(currentEdge.from, to: currentEdge.to,
weight: currentEdge.weight)
addedVerts.insert(currentEdge.to)
for neighbor in try! graph.neighbors(currentEdge.to) {
let weight = try! graph.weight(currentEdge.to, to: neighbor)
queue.insert(WeightedEdge<G.Vertex>(from: currentEdge.to,
to: neighbor, weight: weight!))
}
}
return tree
}
/*
/**
A structure used for storing shortest-path estimates for vertices in a graph.
*/
private struct WeightedVertex<V: Hashable>: Hashable {
let vertex: V
// The path weight bound and parent may be updated, or 'relaxed'
var bound: Double
var parent: V?
var hashValue : Int {
return vertex.hashValue
}
/*func ==(lhs: Self, rhs: Self) -> Bool {
return lhs.vertex == rhs.vertex
}*/
}
private func ==<V: Hashable>(lhs: WeightedVertex<V>,
rhs: WeightedVertex<V>) -> Bool {
return lhs.vertex == rhs.vertex
}
*/
/**
A class for running Dijkstra's algorithm on weighted graphs.
It stores the .d and .pi attributes for the graph's vertices, as described in
CLRS, and handles procedures such as initialize single source and relax.
Note that Dijkstra assumes a positive-weight graph.
*/
private class DijkstraController<G: WeightedGraph,
V: Hashable where G.Vertex == V> {
var distances = [V: Double]()
var parents = [V: V]()
var graph: G
var start: V
/**
Initialize single source (see CLRS) - gives each vertex a distance
estimate of infinity (greater than the total weight of all edges in the
graph), and a parent value of nil (not in the dictionary).
- parameter g: A weighted graph on which we will be searching for shortest
paths.
- parameter start: the vertex to start from - this will get a distance
estimate of 0.
*/
init(g: G, s: V) {
graph = g
start = s
let totalweights = g.totalWeight + 1.0
for vertex in g.vertices {
distances[vertex] = totalweights
}
distances[start] = 0
}
/**
Relaxes the distance estimate of the second given vertex by way of the
first given vertex.
- parameter from: The vertex from which we relax the distance estimate.
- parameter to: the vertex for which we relax the distance estimate.
Note, this assumes that the edge and both vertices exist in the graph.
*/
func relax(from: V, to: V) {
let weight = try! graph.weight(from, to: to)!
if distances[to]! > distances[from]! + weight {
distances[to] = distances[from]! + weight
parents[to] = from
}
}
/**
Runs dijkstra's algorithm on the graph, as described in CLRS.
Just sets up the parent and distance bound dictionaries, does not return
any paths - that method is different.
*/
func dijkstra() {
var finished = Set<V>()
var queue = PriorityHeap<V>(items: graph.vertices) {
self.distances[$0]! <= self.distances[$1]!
}
while queue.peek() != nil {
let vertex = queue.extract()!
finished.insert(vertex)
for neighbor in try! graph.neighbors(vertex) {
relax(vertex, to: neighbor)
try! queue.increasePriorityMatching(neighbor,
matchingPredicate: { $0 == neighbor })
// this maintains the heap property - we may decrease the key
// of the neighbor
}
}
}
/**
Gives the shortest path to the given vertex.
- parameter to: The destination vertex of the path to find.
- returns: an array of vertices representing the shortest path, or nil if
no path exists in the graph.
*/
func dijkstraPath(to: V) -> [V]? {
if parents[to] == nil {
return nil
}
var result = [V]()
var current: V? = to
repeat {
result.insert(current!, atIndex: 0)
current = parents[current!]
} while current != nil && current != start
result.insert(start, atIndex: 0)
return result
}
}
public func dijkstraShortestPath<G: WeightedGraph,
V: Hashable where G.Vertex == V>(graph: G, start: V, end: V) -> [V]? {
let controller = DijkstraController<G, V>(g: graph, s: start)
controller.dijkstra()
return controller.dijkstraPath(end)
}
|
mit
|
eb137c496d988dad73d75344a36d0748
| 28.174194 | 79 | 0.605705 | 4.218284 | false | false | false | false |
stefanomondino/Raccoon
|
Example/Raccoon/ListViewController.swift
|
1
|
2775
|
//
// ViewController.swift
// Raccoon
//
// Created by Stefano Mondino on 03/31/2016.
// Copyright (c) 2016 Stefano Mondino. All rights reserved.
//
import UIKit
import Raccoon
import ReactiveCocoa
import Result
class ListViewController: UIViewController, UICollectionViewDelegateFlowLayout {
var viewModel:ListViewModel!
@IBOutlet weak var collectionView: UICollectionView!
@IBOutlet weak var lbl_loading: UILabel!
@IBOutlet weak var searchBar: UITextField?
override func viewDidLoad() {
super.viewDidLoad()
self.bindViewModel(ListViewModel())
self.title = "Raccoon"
//self.bindViewModelToCollectionView(viewModel, collectionView: collectionView)
self.collectionView.delegate = self
self.collectionView.contentInset = UIEdgeInsets(top: 60, left: 0, bottom: 0, right: 0)
self.viewModel.searchString.producer
.skipRepeats{$0 == $1}
.startWithNext{[unowned self] in self.searchBar!.text = $0}
self.viewModel.searchString <~ self.searchBar!.rac_textSignal()
.toSignalProducer()
.flatMapError({ (error) -> SignalProducer<AnyObject?, NoError> in return .empty })
.map{$0 as? String}
.skipRepeats{$0 == $1}
viewModel?.hasResults.producer.skip(0).startWithNext({[unowned self] (visible) in
self.collectionView.backgroundColor = visible == false ? UIColor.redColor():UIColor.clearColor()
})
self.viewModel.nextAction.values.observeNext{[unowned self] (segueParameters:SegueParameters!) in
self.performSegueWithIdentifier(segueParameters.segueIdentifier, viewModel:segueParameters.viewModel )
}
self.viewWillAppearSignalProducer().startWithNext{print($0)}
self.viewDidAppearSignalProducer().startWithNext{print($0)}
}
override func bindViewModel(viewModel: ViewModel?) {
super.bindViewModel(viewModel)
self.viewModel = viewModel as? ListViewModel
self.collectionView.bindViewModel(viewModel)
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return self.viewModel.autoSizeForItemAtIndexPath(indexPath, width: self.view.frame.size.width-40)
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
//print("click")
self.viewModel.nextAction.apply(indexPath).start()
}
override func showLoader() {
self.lbl_loading.hidden = false;
}
override func hideLoader() {
self.lbl_loading.hidden = true;
}
}
|
mit
|
c9776f62571300baed26e25bec764995
| 38.084507 | 169 | 0.681441 | 5 | false | false | false | false |
Monnoroch/Cuckoo
|
Generator/Dependencies/SourceKitten/Source/SourceKittenFramework/SyntaxToken.swift
|
1
|
1672
|
//
// SyntaxToken.swift
// SourceKitten
//
// Created by JP Simard on 2015-01-03.
// Copyright (c) 2015 SourceKitten. All rights reserved.
//
/// Represents a single Swift syntax token.
public struct SyntaxToken {
/// Token type. See SyntaxKind.
public let type: String
/// Token offset.
public let offset: Int
/// Token length.
public let length: Int
/// Dictionary representation of SyntaxToken. Useful for NSJSONSerialization.
public var dictionaryValue: [String: Any] {
return ["type": type, "offset": offset, "length": length]
}
/**
Create a SyntaxToken by directly passing in its property values.
- parameter type: Token type. See SyntaxKind.
- parameter offset: Token offset.
- parameter length: Token length.
*/
public init(type: String, offset: Int, length: Int) {
self.type = SyntaxKind(rawValue: type)?.rawValue ?? type
self.offset = offset
self.length = length
}
}
// MARK: Equatable
extension SyntaxToken: Equatable {}
/**
Returns true if `lhs` SyntaxToken is equal to `rhs` SyntaxToken.
- parameter lhs: SyntaxToken to compare to `rhs`.
- parameter rhs: SyntaxToken to compare to `lhs`.
- returns: True if `lhs` SyntaxToken is equal to `rhs` SyntaxToken.
*/
public func ==(lhs: SyntaxToken, rhs: SyntaxToken) -> Bool {
return (lhs.type == rhs.type) && (lhs.offset == rhs.offset) && (lhs.length == rhs.length)
}
// MARK: CustomStringConvertible
extension SyntaxToken: CustomStringConvertible {
/// A textual JSON representation of `SyntaxToken`.
public var description: String { return toJSON(dictionaryValue as NSDictionary) }
}
|
mit
|
e03e58fdaa0728819533a544d7735e81
| 27.827586 | 93 | 0.677033 | 4.098039 | false | false | false | false |
developerY/Active-Learning-Swift-2.0_OLD
|
ActiveLearningSwift2.playground/Pages/Optianal Chaining.xcplaygroundpage/Contents.swift
|
3
|
3602
|
//: [Previous](@previous)
// ------------------------------------------------------------------------------------------------
// Things to know:
//
// * Optional Chaining is the process of safely referencing a series of optionals (which contain
// optionals, which contain optionals, etc.) without having to perform the optional unwrapping
// checks at each step along the way.
// ------------------------------------------------------------------------------------------------
// Consider a case of forced unwrapping like "someOptional!.someProperty". We already know that
// this is only safe if we know that the optional will never be nil. For times that we don't know
// this, we must check the optional before we can reference it. This can become cumbersome for
// situations where many optionals are chained together as properties of properties. Let's create
// a series of optionals to show this:
class Artist
{
let name: String
init(name: String) { self.name = name }
}
class Song
{
let name: String
var artist: Artist?
init(name: String, artist: Artist?)
{
self.name = name
self.artist = artist
}
}
class MusicPreferences
{
var favoriteSong: Song?
init(favoriteSong: Song?) { self.favoriteSong = favoriteSong }
}
class Person
{
let name: String
var musicPreferences: MusicPreferences?
init (name: String, musicPreferences: MusicPreferences?)
{
self.name = name
self.musicPreferences = musicPreferences
}
}
// Here, we'll create a working chain:
var someArtist: Artist? = Artist(name: "Somebody with talent")
var favSong: Song? = Song(name: "Something with a beat", artist: someArtist)
var musicPrefs: MusicPreferences? = MusicPreferences(favoriteSong: favSong)
var person: Person? = Person(name: "Bill", musicPreferences: musicPrefs)
// We can access this chain with forced unwrapping. In this controlled environment, this will work
// but it's probably not advisable in a real world situation unless you're sure that each member
// of the chain is sure to never be nil.
person!.musicPreferences!.favoriteSong!.artist!
// Let's break the chain, removing the user's music preferences:
if var p = person
{
p.musicPreferences = nil
}
// With a broken chain, if we try to reference the arist like before, we will get a runtime error.
//
// The following line will compile, but will crash:
//
// person!.musicPreferences!.favoriteSong!.artist!
//
// The solusion here is to use optional chaining, which replaces the forced unwrapping "!" with
// a "?" character. If at any point along this chain, any optional is nil, evaluation is aborted
// and the entire result becomes nil.
//
// Let's see this entire chain, one step at a time working backwards. This let's us see exactly
// where the optional chain becomes a valid value:
person?.musicPreferences?.favoriteSong?.artist
person?.musicPreferences?.favoriteSong
person?.musicPreferences
person
// Optional chaining can be mixed with non-optionals as well as forced unwrapping and other
// contexts (subcripts, function calls, return values, etc.) We won't bother to create the
// series of classes and instances for the following example, but it should serve as a valid
// example of how to use optional chaining syntax in various situations. Given the proper context
// this line of code would compile and run as expected.
//
// person?.musicPreferences?[2].getFavoriteSong()?.artist?.name
//
// This line could be read as: optional person's second optional music preference's favorite song's
// optional artist's name.
//: [Next](@next)
|
apache-2.0
|
8e700d02da15ba0a0e3c6e6e1d5ad77e
| 37.319149 | 99 | 0.694892 | 4.371359 | false | false | false | false |
tnantoka/edhita
|
Edhita/Models/FinderList.swift
|
1
|
5135
|
//
// FinderList.swift
// Edhita
//
// Created by Tatsuya Tobioka on 2022/07/25.
//
import Foundation
import UIKit
class FinderList: ObservableObject {
let url: URL
@Published var items: [FinderItem] = []
var relativePath: String {
FinderList.relativePath(for: url)
}
init(url: URL) {
self.url = url
refresh()
}
func refresh() {
items = FinderList.items(for: url)
}
}
extension FinderList {
static var rootURL: URL {
guard
let documentDirectory = try? FileManager.default.url(
for: .documentDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: false
)
else { fatalError() }
return documentDirectory
}
static func items(for url: URL) -> [FinderItem] {
guard
let urls = try? FileManager.default.contentsOfDirectory(
at: url,
includingPropertiesForKeys: [.contentModificationDateKey, .isDirectoryKey]
)
else { fatalError() }
return urls.map { FinderItem(url: $0) }.sorted {
$0.contentModificationDate > $1.contentModificationDate
}
}
static func relativePath(for url: URL) -> String {
let path = url.path.replacingOccurrences(of: rootURL.path, with: "")
return path.isEmpty ? "/" : path
}
static func createExamples() {
let root = FinderList(url: rootURL)
let examplesURL = rootURL.appendingPathComponent("examples")
if FileManager.default.fileExists(atPath: examplesURL.path) {
return
}
root.addItem(name: "examples", isDirectory: true)
let examples = FinderList(url: examplesURL)
try? UIImage(named: "AppIcon60x60")?.pngData()?.write(
to: examplesURL.appendingPathComponent("logo.png"))
examples.addItem(name: "index.html", isDirectory: false)
examples.addItem(name: "index.md", isDirectory: false)
examples.addItem(name: "style.css", isDirectory: false)
examples.addItem(name: "script.js", isDirectory: false)
examples.refresh()
let items = examples.items
items.first { $0.filename == "index.md" }?.update(
content: """
# Edhita
---
Fully open source text editor for iOS written in SwiftUI.
https://edhita.bornneet.com/

"""
)
items.first { $0.filename == "script.js" }?.update(
content: """
document.querySelector('button').addEventListener('click', () => {
document.querySelector('input').value = new Date();
});
"""
)
items.first { $0.filename == "style.css" }?.update(
content: """
body {
background: #f9f9f9;
}
"""
)
items.first { $0.filename == "index.html" }?.update(
content: """
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<h1>Hello, world!</h1>
<p>
<button>Hello</button><br>
<input type="text">
</p>
<script src="script.js"></script>
</body>
</html>
"""
)
}
}
extension FinderList {
func deleteItem(item: FinderItem?) {
guard let item = item else { return }
if let index = items.firstIndex(of: item) {
items.remove(at: index)
}
item.destroy()
}
func duplicateItem(item: FinderItem?) {
guard let item = item else { return }
item.duplicate()
refresh()
}
func renameItem(item: FinderItem?, name: String) {
guard let item = item else { return }
item.rename(name: name)
refresh()
}
func moveItem(item: FinderItem?, url: URL) {
guard let item = item else { return }
item.move(directory: url)
refresh()
}
func addItem(name: String, isDirectory: Bool) {
let url = self.url.appendingPathComponent(name)
if isDirectory {
try? FileManager.default.createDirectory(at: url, withIntermediateDirectories: false)
} else {
try? "".write(to: url, atomically: true, encoding: .utf8)
}
refresh()
}
func downloadItem(urlString: String) {
guard let url = URL(string: urlString) else { return }
if let data = try? Data(contentsOf: url) {
try? data.write(to: self.url.appendingPathComponent(url.lastPathComponent))
}
refresh()
}
}
|
mit
|
a4005745aa0671e082b4c62317db6eef
| 27.370166 | 97 | 0.518403 | 4.580731 | false | false | false | false |
ninewine/SaturnTimer
|
SaturnTimer/View/AnimatableTag/Saturn/Saturn.swift
|
1
|
3130
|
//
// Saturn.swift
// SaturnTimer
//
// Created by Tidy Nine on 2/17/16.
// Copyright © 2016 Tidy Nine. All rights reserved.
//
import UIKit
import pop
class Saturn: AnimatableTag {
fileprivate let _planet: CAShapeLayer = CAShapeLayer()
fileprivate let _ring: CAShapeLayer = CAShapeLayer()
fileprivate let _light1: CAShapeLayer = CAShapeLayer()
fileprivate let _light2: CAShapeLayer = CAShapeLayer()
fileprivate let _duration: CFTimeInterval = 1.0
override func viewConfig() {
_fixedSize = CGSize(width: 30, height: 24)
super.viewConfig()
_planet.path = _SaturnLayerPath.planetPath.cgPath
_ring.path = _SaturnLayerPath.ringPath.cgPath
_light1.path = _SaturnLayerPath.light1.cgPath
_light2.path = _SaturnLayerPath.light2.cgPath
let layersStroke = [_planet, _ring, _light1, _light2]
for layer in layersStroke {
layer.isOpaque = true
layer.lineCap = kCALineCapRound
layer.lineWidth = 1.5
layer.miterLimit = 1.5
layer.strokeStart = 0.0
layer.strokeEnd = 0.0
layer.strokeColor = currentAppearenceColor()
layer.fillColor = UIColor.clear.cgColor
_contentView.layer.addSublayer(layer)
}
enterAnimation()
}
override func layersNeedToBeHighlighted() -> [CAShapeLayer]? {
return [_planet, _ring, _light1, _light2]
}
override func startAnimation() {
_pausing = false
ringHeadAnimation()
}
override func stopAnimation() {
_pausing = true
_ring.removeAllAnimations()
_ring.strokeStart = 0.0
_ring.strokeEnd = 0.0
}
// Enter Animation
func enterAnimation () {
//Planet
_planet.pathStokeAnimationFrom(0.0, to: 1.0, duration: _duration, type: .end) {[weak self] () -> Void in
guard let _self = self else {return}
_self._light1.pathStokeAnimationFrom(0.0, to: 1.0, duration: _self._duration * 0.5, type: .end, completion: {[weak self] () -> Void in
guard let _self = self else {return}
_self._light2.pathStokeAnimationFrom(0.0, to: 1.0, duration: _self._duration * 0.5, type: .end, completion: {[weak self] () -> Void in
guard let _self = self else {return}
_self.startAnimation()
})
})
}
}
//Ring Animation
func ringHeadAnimation () {
if _pausing {
return
}
_ring.removeFromSuperlayer()
_ring.setValueWithoutImplicitAnimation(0.0, forKey: "strokeStart")
_ring.setValueWithoutImplicitAnimation(0.0, forKey: "strokeEnd")
_contentView.layer.addSublayer(_ring)
_ring.pathStokeAnimationFrom(0.0, to: 1.0, duration: _duration * 0.5, type: .end) {[weak self] () -> Void in
guard let _self = self else {return}
_self.ringTailAnimation()
}
}
func ringTailAnimation () {
if _pausing {
return
}
_ring.pathStokeAnimationFrom(0.0, to: 1.0, duration: _duration * 0.5, type: .start)
{() -> Void in
let dispatchTime: DispatchTime = DispatchTime.now() + Double(Int64(1.0 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
DispatchQueue.main.asyncAfter(deadline: dispatchTime, execute: {[weak self] () -> Void in
guard let _self = self else {return}
_self.ringHeadAnimation()
})
}
}
}
|
mit
|
f3cad4185b6e0584b790810adc9bee54
| 24.647541 | 138 | 0.667625 | 3.339381 | false | false | false | false |
andyshep/GROCloudStore
|
Sources/Operations/VerifySubscriptionOperation.swift
|
1
|
3107
|
//
// VerifySubscriptionOperation.swift
// GROCloudStore
//
// Created by Andrew Shepard on 2/17/16.
// Copyright © 2016 Andrew Shepard. All rights reserved.
//
import CoreData
import CloudKit
final internal class VerifySubscriptionOperation: AsyncOperation {
private let context: NSManagedObjectContext
private let dataSource: CloudDataSource
private let configuration: Configuration
init(context: NSManagedObjectContext, dataSource: CloudDataSource, configuration: Configuration) {
self.context = context
self.dataSource = dataSource
self.configuration = configuration
super.init()
}
override func main() {
var shouldCreateSubscription = true
self.context.performAndWait {
do {
let request = NSFetchRequest<GROSubscription>(entityName: GROSubscription.entityName)
let results = try self.context.fetch(request)
if let _ = results.first {
shouldCreateSubscription = false
}
} catch {
//
}
}
if shouldCreateSubscription {
dataSource.verifySubscriptions(completion: didFetch)
} else {
print("subscription verified, skipping creation")
finish()
}
}
private func createSubscriptions() {
let configuration = dataSource.configuration
let subscriptions = configuration.subscriptions.all
dataSource.createSubscriptions(subscriptions: subscriptions, completion: didCreate)
}
private func didFetch(subscriptions: [CKSubscription]?, error: Error?) {
guard error == nil else {
attemptCloudKitRecoveryFrom(error: error! as NSError); return
}
// FIXME: should handle more than one subscription
var foundSubscription = false
let defaultSubscription = self.configuration.subscriptions.all.first!
if let subscriptions = subscriptions {
if subscriptions.contains(defaultSubscription) {
foundSubscription = true
}
}
if foundSubscription {
self.save(subscription: defaultSubscription, in: context)
} else {
createSubscriptions()
}
}
private func didCreate(subscription: CKSubscription?, error: Error?) {
if let error = error {
print("error: \(error)")
}
if let subscription = subscription {
print("successfully created subscription: \(subscription)")
}
finish()
}
private func save(subscription: CKSubscription, in context: NSManagedObjectContext) {
context.perform {
guard let savedSubscription = GROSubscription.newObject(in: context) as? GROSubscription else { return }
savedSubscription.content = NSKeyedArchiver.archivedData(withRootObject: subscription)
context.saveOrLogError()
}
}
}
|
mit
|
5971666b7082c163d2501559525a1359
| 31.020619 | 116 | 0.611075 | 5.860377 | false | true | false | false |
loganSims/wsdot-ios-app
|
wsdot/TollRatesViewController.swift
|
1
|
1942
|
//
// TollRatesViewController.swift
// WSDOT
//
// Copyright (c) 2018 Washington State Department of Transportation
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
//
import Foundation
import UIKit
import SafariServices
class TollRatesViewController: UIViewController{
@IBOutlet weak var TollTabBarContainerView: UIView!
let goodToGoUrlString = "https://mygoodtogo.com/olcsc/"
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
@IBAction func MyGoodToGoLinkTap(_ sender: UIBarButtonItem) {
MyAnalytics.screenView(screenName: "MyGoodToGo.com")
MyAnalytics.event(category: "Tolling", action: "open_link", label: "tolling_good_to_go")
let config = SFSafariViewController.Configuration()
config.entersReaderIfAvailable = true
let svc = SFSafariViewController(url: URL(string: self.goodToGoUrlString)!, configuration: config)
if #available(iOS 10.0, *) {
svc.preferredControlTintColor = ThemeManager.currentTheme().secondaryColor
svc.preferredBarTintColor = ThemeManager.currentTheme().mainColor
} else {
svc.view.tintColor = ThemeManager.currentTheme().mainColor
}
self.present(svc, animated: true, completion: nil)
}
}
|
gpl-3.0
|
f20d18b1165c044626fa032de425c7ed
| 35.641509 | 106 | 0.702884 | 4.49537 | false | true | false | false |
google/promises
|
Sources/Promises/Promise+Recover.swift
|
1
|
2699
|
// Copyright 2018 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import Foundation
public extension Promise {
/// Provides a new promise to recover in case `self` gets rejected.
/// - parameters:
/// - queue: A queue to execute `recovery` block on.
/// - recovery: A block to handle the error that `self` was rejected with.
/// - returns: A new pending promise to use instead of the rejected one that gets resolved with
/// the same resolution as the promise returned from `recovery` block.
@discardableResult
func recover(
on queue: DispatchQueue = .promises,
_ recovery: @escaping (Error) throws -> Promise
) -> Promise {
let promise = Promise(objCPromise.__onQueue(queue, recover: {
do {
// Convert `NSError` to `PromiseError`, if applicable.
let error = PromiseError($0) ?? $0
return try recovery(error).objCPromise
} catch let error {
return error as NSError
}
}))
// Keep Swift wrapper alive for chained promise until `ObjCPromise` counterpart is resolved.
objCPromise.__addPendingObject(promise)
return promise
}
/// Provides a new promise to recover in case `self` gets rejected.
/// - parameters:
/// - queue: A queue to execute `recovery` block on.
/// - recovery: A block to handle the error that `self` was rejected with.
/// - returns: A new pending promise to use instead of the rejected one that gets resolved with
/// the value returned from `recovery` block.
@discardableResult
func recover(
on queue: DispatchQueue = .promises,
_ recovery: @escaping (Error) throws -> Value
) -> Promise {
let promise = Promise(objCPromise.__onQueue(queue, recover: {
do {
// Convert `NSError` to `PromiseError`, if applicable.
let error = PromiseError($0) ?? $0
return Promise<Value>.asAnyObject(try recovery(error)) as Any
} catch let error {
return error as NSError
}
}))
// Keep Swift wrapper alive for chained promise until `ObjCPromise` counterpart is resolved.
objCPromise.__addPendingObject(promise)
return promise
}
}
|
apache-2.0
|
59a1606dc42d4d1d5bcd634381fa754b
| 38.691176 | 97 | 0.677658 | 4.402936 | false | false | false | false |
daher-alfawares/iBeacon
|
Beacon/Beacon/ViewController.swift
|
1
|
1847
|
//
// ViewController.swift
// Beacon
//
// Created by Daher Alfawares on 1/19/15.
// Copyright (c) 2015 Daher Alfawares. All rights reserved.
//
import UIKit
class ViewController: UITableViewController {
let beacons = BeaconDataSource()
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self;
self.tableView.dataSource = self;
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.beacons.count()
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// View
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
// Model
let beaconInfo = self.beacons.beaconInfoAtIndex(indexPath.row)
// Control
cell.textLabel?.text = beaconInfo.name
cell.detailTextLabel?.text = beaconInfo.uuid
return cell;
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// View
let beaconViewController = segue.destinationViewController as BeaconViewController
// Model
let tableView = self.tableView;
let index = tableView.indexPathForCell(sender as UITableViewCell)
let row = index?.row
let beacon = self.beacons.beaconInfoAtIndex (row!) as BeaconInfo
beaconViewController.beaconName = beacon.name
beaconViewController.beaconUUID = beacon.uuid
beaconViewController.beaconImageName = beacon.image
beaconViewController.beaconMajor = beacon.major
beaconViewController.beaconMinor = beacon.minor
}
}
|
apache-2.0
|
faadb1b1d0cb47914902c7e294e5729d
| 29.783333 | 118 | 0.64104 | 5.369186 | false | false | false | false |
LoopKit/LoopKit
|
LoopKit Example/MasterViewController.swift
|
1
|
16024
|
//
// MasterViewController.swift
// LoopKit Example
//
// Created by Nathan Racklyeft on 2/24/16.
// Copyright © 2016 Nathan Racklyeft. All rights reserved.
//
import UIKit
import LoopKit
import LoopKitUI
import HealthKit
class MasterViewController: UITableViewController {
private var dataManager: DeviceDataManager? = DeviceDataManager()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
guard let dataManager = dataManager else {
return
}
let sampleTypes = Set([
dataManager.glucoseStore.sampleType,
dataManager.carbStore.sampleType,
dataManager.doseStore.sampleType,
].compactMap { $0 })
if dataManager.glucoseStore.authorizationRequired ||
dataManager.carbStore.authorizationRequired ||
dataManager.doseStore.authorizationRequired
{
dataManager.carbStore.healthStore.requestAuthorization(toShare: sampleTypes, read: sampleTypes) { (success, error) in
if success {
// Call the individual authorization methods to trigger query creation
dataManager.carbStore.authorize({ _ in })
dataManager.doseStore.insulinDeliveryStore.authorize(toShare: true, { _ in })
dataManager.glucoseStore.authorize({ _ in })
}
}
}
}
// MARK: - Data Source
private enum Section: Int, CaseIterable {
case data
case configuration
}
private enum DataRow: Int, CaseIterable {
case carbs = 0
case reservoir
case diagnostic
case generate
case reset
}
private enum ConfigurationRow: Int, CaseIterable {
case basalRate
case carbRatio
case correctionRange
case insulinSensitivity
case pumpID
}
// MARK: UITableViewDataSource
override func numberOfSections(in tableView: UITableView) -> Int {
return Section.allCases.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch Section(rawValue: section)! {
case .configuration:
return ConfigurationRow.allCases.count
case .data:
return DataRow.allCases.count
}
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
switch Section(rawValue: indexPath.section)! {
case .configuration:
switch ConfigurationRow(rawValue: indexPath.row)! {
case .basalRate:
cell.textLabel?.text = LocalizedString("Basal Rates", comment: "The title text for the basal rate schedule")
case .carbRatio:
cell.textLabel?.text = LocalizedString("Carb Ratios", comment: "The title of the carb ratios schedule screen")
case .correctionRange:
cell.textLabel?.text = LocalizedString("Correction Range", comment: "The title text for the glucose correction range schedule")
case .insulinSensitivity:
cell.textLabel?.text = LocalizedString("Insulin Sensitivity", comment: "The title text for the insulin sensitivity schedule")
case .pumpID:
cell.textLabel?.text = LocalizedString("Pump ID", comment: "The title text for the pump ID")
}
case .data:
switch DataRow(rawValue: indexPath.row)! {
case .carbs:
cell.textLabel?.text = LocalizedString("Carbs", comment: "The title for the cell navigating to the carbs screen")
case .reservoir:
cell.textLabel?.text = LocalizedString("Reservoir", comment: "The title for the cell navigating to the reservoir screen")
case .diagnostic:
cell.textLabel?.text = LocalizedString("Diagnostic", comment: "The title for the cell displaying diagnostic data")
case .generate:
cell.textLabel?.text = LocalizedString("Generate Data", comment: "The title for the cell displaying data generation")
case .reset:
cell.textLabel?.text = LocalizedString("Reset", comment: "Title for the cell resetting the data manager")
}
}
return cell
}
// MARK: - UITableViewDelegate
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let sender = tableView.cellForRow(at: indexPath)
switch Section(rawValue: indexPath.section)! {
case .configuration:
let row = ConfigurationRow(rawValue: indexPath.row)!
switch row {
// case .basalRate:
//
// // x22 with max basal rate of 5U/hr
// let pulsesPerUnit = 20
// let basalRates = (1...100).map { Double($0) / Double(pulsesPerUnit) }
//
// // full x23 rates
// let rateGroup1 = ((1...39).map { Double($0) / Double(40) })
// let rateGroup2 = ((20...199).map { Double($0) / Double(20) })
// let rateGroup3 = ((100...350).map { Double($0) / Double(10) })
// let basalRates = rateGroup1 + rateGroup2 + rateGroup3
// let scheduleVC = BasalScheduleTableViewController(allowedBasalRates: basalRates, maximumScheduleItemCount: 5, minimumTimeInterval: .minutes(30))
//
// if let profile = dataManager?.basalRateSchedule {
// scheduleVC.timeZone = profile.timeZone
//
//
// scheduleVC.scheduleItems = profile.items
// }
// scheduleVC.delegate = self
// scheduleVC.title = sender?.textLabel?.text
// scheduleVC.syncSource = self
//
// show(scheduleVC, sender: sender)
case .carbRatio:
let scheduleVC = DailyQuantityScheduleTableViewController()
scheduleVC.delegate = self
scheduleVC.title = NSLocalizedString("Carb Ratios", comment: "The title of the carb ratios schedule screen")
scheduleVC.unit = .gram()
if let schedule = dataManager?.carbRatioSchedule {
scheduleVC.timeZone = schedule.timeZone
scheduleVC.scheduleItems = schedule.items
scheduleVC.unit = schedule.unit
}
show(scheduleVC, sender: sender)
case .correctionRange:
var therapySettings = TherapySettings()
therapySettings.glucoseTargetRangeSchedule = self.dataManager?.glucoseTargetRangeSchedule
let therapySettingsViewModel = TherapySettingsViewModel(therapySettings: therapySettings)
let view = CorrectionRangeScheduleEditor(mode: .settings, therapySettingsViewModel: therapySettingsViewModel, didSave: {
self.dataManager?.glucoseTargetRangeSchedule = therapySettingsViewModel.therapySettings.glucoseTargetRangeSchedule
self.navigationController?.popToViewController(self, animated: true)
})
.environmentObject(DisplayGlucoseUnitObservable(displayGlucoseUnit: .milligramsPerDeciliter))
let scheduleVC = DismissibleHostingController(rootView: view, dismissalMode: .pop(to: type(of: self)), isModalInPresentation: false)
show(scheduleVC, sender: sender)
case .insulinSensitivity:
let unit = dataManager?.insulinSensitivitySchedule?.unit ?? dataManager?.glucoseStore.preferredUnit ?? HKUnit.milligramsPerDeciliter
let scheduleVC = InsulinSensitivityScheduleViewController(allowedValues: unit.allowedSensitivityValues, unit: unit)
scheduleVC.unit = unit
scheduleVC.delegate = self
scheduleVC.insulinSensitivityScheduleStorageDelegate = self
scheduleVC.schedule = dataManager?.insulinSensitivitySchedule
scheduleVC.title = NSLocalizedString("Insulin Sensitivity", comment: "The title of the insulin sensitivity schedule screen")
show(scheduleVC, sender: sender)
case .pumpID:
let textFieldVC = TextFieldTableViewController()
// textFieldVC.delegate = self
textFieldVC.title = sender?.textLabel?.text
textFieldVC.placeholder = LocalizedString("Enter the 6-digit pump ID", comment: "The placeholder text instructing users how to enter a pump ID")
textFieldVC.value = dataManager?.pumpID
textFieldVC.keyboardType = .numberPad
textFieldVC.contextHelp = LocalizedString("The pump ID can be found printed on the back, or near the bottom of the STATUS/Esc screen. It is the strictly numerical portion of the serial number (shown as SN or S/N).", comment: "Instructions on where to find the pump ID on a Minimed pump")
show(textFieldVC, sender: sender)
default:
break
}
case .data:
switch DataRow(rawValue: indexPath.row)! {
case .carbs:
performSegue(withIdentifier: CarbEntryTableViewController.className, sender: sender)
case .reservoir:
performSegue(withIdentifier: LegacyInsulinDeliveryTableViewController.className, sender: sender)
case .diagnostic:
let vc = CommandResponseViewController(command: { [weak self] (completionHandler) -> String in
let group = DispatchGroup()
guard let dataManager = self?.dataManager else {
completionHandler("")
return "nil"
}
var doseStoreResponse = ""
group.enter()
dataManager.doseStore.generateDiagnosticReport { (report) in
doseStoreResponse = report
group.leave()
}
var carbStoreResponse = ""
if let carbStore = dataManager.carbStore {
group.enter()
carbStore.generateDiagnosticReport { (report) in
carbStoreResponse = report
group.leave()
}
}
var glucoseStoreResponse = ""
group.enter()
dataManager.glucoseStore.generateDiagnosticReport { (report) in
glucoseStoreResponse = report
group.leave()
}
group.notify(queue: DispatchQueue.main) {
completionHandler([
doseStoreResponse,
carbStoreResponse,
glucoseStoreResponse
].joined(separator: "\n\n"))
}
return "…"
})
vc.title = "Diagnostic"
show(vc, sender: sender)
case .generate:
let vc = CommandResponseViewController(command: { [weak self] (completionHandler) -> String in
guard let dataManager = self?.dataManager else {
completionHandler("")
return "dataManager is nil"
}
let group = DispatchGroup()
var unitVolume = 150.0
reservoir: for index in sequence(first: TimeInterval(hours: -6), next: { $0 + .minutes(5) }) {
guard index < 0 else {
break reservoir
}
unitVolume -= (drand48() * 2.0)
group.enter()
dataManager.doseStore.addReservoirValue(unitVolume, at: Date(timeIntervalSinceNow: index)) { (_, _, _, error) in
group.leave()
}
}
group.enter()
dataManager.glucoseStore.addGlucoseSamples([NewGlucoseSample(date: Date(), quantity: HKQuantity(unit: .milligramsPerDeciliter, doubleValue: 101), condition: nil, trend: nil, trendRate: nil, isDisplayOnly: false, wasUserEntered: false, syncIdentifier: UUID().uuidString)], completion: { (result) in
group.leave()
})
group.notify(queue: .main) {
completionHandler("Completed")
}
return "Generating…"
})
vc.title = sender?.textLabel?.text
show(vc, sender: sender)
case .reset:
dataManager = nil
tableView.reloadData()
}
}
}
// MARK: - Segues
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: sender)
var targetViewController = segue.destination
if let navVC = targetViewController as? UINavigationController, let topViewController = navVC.topViewController {
targetViewController = topViewController
}
switch targetViewController {
case let vc as CarbEntryTableViewController:
vc.carbStore = dataManager?.carbStore
case let vc as CarbEntryEditViewController:
if let carbStore = dataManager?.carbStore {
vc.defaultAbsorptionTimes = carbStore.defaultAbsorptionTimes
vc.preferredUnit = carbStore.preferredUnit
}
case let vc as LegacyInsulinDeliveryTableViewController:
vc.doseStore = dataManager?.doseStore
default:
break
}
}
}
extension MasterViewController: DailyValueScheduleTableViewControllerDelegate {
func dailyValueScheduleTableViewControllerWillFinishUpdating(_ controller: DailyValueScheduleTableViewController) {
if let indexPath = tableView.indexPathForSelectedRow {
switch Section(rawValue: indexPath.section)! {
case .configuration:
switch ConfigurationRow(rawValue: indexPath.row)! {
// case .basalRate:
// if let controller = controller as? BasalScheduleTableViewController {
// dataManager?.basalRateSchedule = BasalRateSchedule(dailyItems: controller.scheduleItems, timeZone: controller.timeZone)
// }
default:
break
}
tableView.reloadRows(at: [indexPath], with: .none)
default:
break
}
}
}
}
extension MasterViewController: InsulinSensitivityScheduleStorageDelegate {
func saveSchedule(_ schedule: InsulinSensitivitySchedule, for viewController: InsulinSensitivityScheduleViewController, completion: @escaping (SaveInsulinSensitivityScheduleResult) -> Void) {
self.dataManager?.insulinSensitivitySchedule = schedule
completion(.success)
}
}
private extension HKUnit {
var allowedSensitivityValues: [Double] {
if self == HKUnit.milligramsPerDeciliter {
return (10...500).map { Double($0) }
}
if self == HKUnit.millimolesPerLiter {
return (6...270).map { Double($0) / 10.0 }
}
return []
}
var allowedCorrectionRangeValues: [Double] {
if self == HKUnit.milligramsPerDeciliter {
return (60...180).map { Double($0) }
}
if self == HKUnit.millimolesPerLiter {
return (33...100).map { Double($0) / 10.0 }
}
return []
}
}
|
mit
|
16ce44d4b85818901f8089b3c306fe2f
| 40.716146 | 317 | 0.58312 | 5.700712 | false | false | false | false |
SASAbus/SASAbus-ios
|
SASAbus/Controller/Departure/Map/BusStopMapViewController.swift
|
1
|
3939
|
//
// BusStopMapViewController.swift
// SASAbus
//
// Copyright (C) 2011-2015 Raiffeisen Online GmbH (Norman Marmsoler, Jürgen Sprenger, Aaron Falk) <[email protected]>
//
// This file is part of SASAbus.
//
// SASAbus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// SASAbus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SASAbus. If not, see <http://www.gnu.org/licenses/>.
//
import UIKit
import CoreLocation
import MapKit
import RealmSwift
class BusStopMapViewController: UIViewController, MKMapViewDelegate {
@IBOutlet weak var mapView: MKMapView!
var realm = Realm.busStops()
init() {
super.init(nibName: "BusStopMapViewController", bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
self.title = L10n.Departures.Map.title
mapView.delegate = self
mapView.mapType = MapUtils.getMapType()
mapView.setRegion(MapUtils.getRegion(), animated: false)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
parseData()
}
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
return nil
}
var pinView = mapView.dequeueReusableAnnotationView(withIdentifier: "pin") as? MKPinAnnotationView
if pinView == nil {
let calloutButton = UIButton(type: .detailDisclosure)
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "pin")
pinView!.canShowCallout = true
pinView!.rightCalloutAccessoryView = calloutButton
pinView!.sizeToFit()
} else {
pinView!.annotation = annotation
}
return pinView
}
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
let annotation = view.annotation as! BusStopAnnotation
let id = annotation.busStop.id
if control == view.rightCalloutAccessoryView {
Log.warning("Clicked on \(id)")
var viewController: BusStopViewController!
if (self.navigationController?.viewControllers.count)! > 1 {
viewController = self.navigationController?
.viewControllers[(self.navigationController?
.viewControllers.index(of: self))! - 1] as? BusStopViewController
viewController!.setBusStop(annotation.busStop)
self.navigationController?.popViewController(animated: true)
} else {
viewController = BusStopViewController(busStop: annotation.busStop)
(UIApplication.shared.delegate as! AppDelegate).navigateTo(viewController!)
}
}
}
func parseData() {
let busStops = BusStopRealmHelper.all()
for busStop in busStops {
let annotation = BusStopAnnotation(
title: busStop.name(locale: Locales.get()),
subtitle: busStop.munic(locale: Locales.get()),
coordinate: CLLocationCoordinate2D(latitude: Double(busStop.lat), longitude: Double(busStop.lng)),
busStop: BBusStop(fromRealm: busStop)
)
mapView.addAnnotation(annotation)
}
}
}
|
gpl-3.0
|
fe4363a19f2101031091734fa547d6bd
| 31.545455 | 129 | 0.649568 | 5.094437 | false | false | false | false |
kuzmir/kazimir-ios
|
kazimir-ios/Data/DataSynchronizer.swift
|
1
|
1683
|
//
// DataSynchronizer.swift
// kazimir-ios
//
// Created by Krzysztof Cieplucha on 14/05/15.
// Copyright (c) 2015 Kazimir. All rights reserved.
//
import UIKit
import CoreData
protocol DataSynchronizerDelegate {
func dataSynchronizer(dataSynchronizer: DataSynchronizer, didStartSynchronizationLocally locally: Bool)
func dataSynchronizer(dataSynchronizer: DataSynchronizer, didFinishSynchronizationLocally locally: Bool, error: NSError?)
}
class DataSynchronizer {
static let sharedInstance = DataSynchronizer()
var isSynchronizationInProgress = false
var delegate: DataSynchronizerDelegate?
private init() {}
func startSynchronization(#locally: Bool) {
if (!isSynchronizationInProgress) {
isSynchronizationInProgress = true
delegate?.dataSynchronizer(self, didStartSynchronizationLocally: locally)
let writeContext = Storage.sharedInstance.getWriteManagedObjectContext()
writeContext.performBlock({ () -> Void in
var error: NSError? = nil
error = DataLoader.sharedInstance.loadDataIntoContext(writeContext, locally: locally, progress: { () -> Bool in
writeContext.save(&error)
error = error ?? Storage.sharedInstance.save()
return error == nil
})
dispatch_sync(dispatch_get_main_queue(), { () -> Void in
self.isSynchronizationInProgress = false
self.delegate?.dataSynchronizer(self, didFinishSynchronizationLocally: locally, error: error)
})
})
}
}
}
|
apache-2.0
|
194039388b23fc0a76c757da8c2d6930
| 34.0625 | 127 | 0.644682 | 5.210526 | false | false | false | false |
PhilJay/SugarRecord
|
library/CoreData/Base/NSManagedObject+SugarRecord.swift
|
2
|
8179
|
//
// NSManagedObject+SugarRecord.swift
// SugarRecord
//
// Created by Pedro Piñera Buendia on 07/09/14.
// Copyright (c) 2014 SugarRecord. All rights reserved.
//
import Foundation
import CoreData
extension NSManagedObject
{
typealias SugarRecordObjectType = NSManagedObject
//MARK: - Custom Getter
/**
Returns the context where this object is alive
:returns: SugarRecord context
*/
public func context() -> SugarRecordContext
{
return SugarRecordCDContext(context: self.managedObjectContext!)
}
/**
Returns the class entity name
:returns: String with the entity name
*/
public class func modelName() -> String
{
return NSStringFromClass(self).componentsSeparatedByString(".").last!
}
/**
Returns the stack type compatible with this object
:returns: SugarRecordEngine with the type
*/
public class func stackType() -> SugarRecordEngine
{
return SugarRecordEngine.SugarRecordEngineCoreData
}
//MARK: - Filtering
/**
Returns a SugarRecord finder with the predicate set
:param: predicate NSPredicate to be set to the finder
:returns: SugarRecord finder with the predicate set
*/
public class func by(predicate: NSPredicate) -> SugarRecordFinder
{
var finder: SugarRecordFinder = SugarRecordFinder(predicate: predicate)
finder.objectClass = self
finder.stackType = stackType()
return finder
}
/**
Returns a SugarRecord finder with the predicate set
:param: predicateString Predicate in String format
:returns: SugarRecord finder with the predicate set
*/
public class func by(predicateString: NSString) -> SugarRecordFinder
{
var finder: SugarRecordFinder = SugarRecordFinder()
finder.setPredicate(predicateString)
finder.objectClass = self
finder.stackType = stackType()
return finder
}
/**
Returns a SugarRecord finder with the predicate set
:param: key Key of the predicate to be filtered
:param: value Value of the predicate to be filtered
:returns: SugarRecord finder with the predicate set
*/
public class func by<T: Printable, R: Printable>(key: T, equalTo value: R) -> SugarRecordFinder
{
var finder: SugarRecordFinder = SugarRecordFinder()
finder.setPredicate(byKey: "\(key)", andValue: "\(value)")
finder.objectClass = self
finder.stackType = stackType()
return finder
}
//MARK: - Sorting
/**
Returns a SugarRecord finder with the sort descriptor set
:param: sortingKey Sorting key
:param: ascending Sorting ascending value
:returns: SugarRecord finder with the predicate set
*/
public class func sorted<T: Printable>(by sortingKey: T, ascending: Bool) -> SugarRecordFinder
{
var finder: SugarRecordFinder = SugarRecordFinder()
finder.addSortDescriptor(byKey: "\(sortingKey)", ascending: ascending)
finder.objectClass = self
finder.stackType = stackType()
return finder
}
/**
Returns a SugarRecord finder with the sort descriptor set
:param: sortDescriptor NSSortDescriptor to be set to the SugarRecord finder
:returns: SugarRecord finder with the predicate set
*/
public class func sorted(by sortDescriptor: NSSortDescriptor) -> SugarRecordFinder
{
var finder: SugarRecordFinder = SugarRecordFinder()
finder.addSortDescriptor(sortDescriptor)
finder.objectClass = self
finder.stackType = stackType()
return finder
}
/**
Returns a SugarRecord finder with the sort descriptor set
:param: sortDescriptors Array with NSSortDescriptors
:returns: SugarRecord finder with the predicate set
*/
public class func sorted(by sortDescriptors: [NSSortDescriptor]) -> SugarRecordFinder
{
var finder: SugarRecordFinder = SugarRecordFinder()
finder.setSortDescriptors(sortDescriptors)
finder.objectClass = self
finder.stackType = stackType()
return finder
}
//MARK: - All
/**
Returns a SugarRecord finder with .all elements enabled
:returns: SugarRecord finder
*/
public class func all() -> SugarRecordFinder
{
var finder: SugarRecordFinder = SugarRecordFinder()
finder.all()
finder.objectClass = self
finder.stackType = stackType()
return finder
}
//MARK: - Count
/**
Returns a the count of elements of this type
:returns: Int
*/
public class func count() -> Int
{
return all().count()
}
//MARK: - Deletion
/**
* Deletes the object
*/
public func delete() -> SugarRecordContext
{
SugarRecordLogger.logLevelVerbose.log("Object \(self) deleted in its context")
return self.context().deleteObject(self)
}
//MARK: - Creation
/**
Creates a new object without inserting it in the context
:returns: Created database object
*/
public class func create() -> AnyObject
{
SugarRecordLogger.logLevelVerbose.log("Object created")
var object: AnyObject?
SugarRecord.operation(NSManagedObject.stackType(), closure: { (context) -> () in
object = context.createObject(self)
})
return object!
}
/**
Create a new object without inserting it in the passed context
:param: context Context where the object is going to be created
:returns: Created database object
*/
public class func create(inContext context: SugarRecordContext) -> AnyObject
{
SugarRecordLogger.logLevelVerbose.log("Object created")
return context.createObject(self)!
}
//MARK: - Saving
/**
Saves the object in the object context
:returns: Bool indicating if the object has been properly saved
*/
public func save () -> Bool
{
SugarRecordLogger.logLevelVerbose.log("Object saved in context")
var saved: Bool = false
self.save(false, completion: { (error) -> () in
saved = error == nil
})
return saved
}
/**
Saves the object in the object context asynchronously (or not) passing a completion closure
:param: asynchronously Bool indicating if the saving process is asynchronous or not
:param: completion Closure called when the saving operation has been completed
*/
public func save (asynchronously: Bool, completion: CompletionClosure)
{
SugarRecordLogger.logLevelVerbose.log("Saving \(self) in context")
let context: SugarRecordContext = self.context()
if asynchronously {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), { () -> Void in
context.endWriting()
dispatch_async(dispatch_get_main_queue(), { () -> Void in
completion(error: nil)
})
})
}
else {
context.endWriting()
completion(error: nil)
}
}
//MARK: - beginWriting
/**
Needed to be called when the object is going to be edited
:returns: returns the current object
*/
public func beginWriting() -> NSManagedObject
{
SugarRecordLogger.logLevelVerbose.log("Object did begin writing")
self.context().beginWriting()
return self
}
/**
Needed to be called when the edition/deletion has finished
*/
public func endWriting()
{
SugarRecordLogger.logLevelVerbose.log("Object did end writing")
self.context().endWriting()
}
/**
* Asks the context for writing cancellation
*/
public func cancelWriting()
{
SugarRecordLogger.logLevelVerbose.log("Object did end writing")
self.context().cancelWriting()
}
}
|
mit
|
a72ee52367f6a9dc3f5538a002261d5c
| 26.631757 | 108 | 0.629249 | 5.282946 | false | false | false | false |
grandiere/box
|
box/Model/Help/Energy/MHelpEnergyAids.swift
|
1
|
1353
|
import UIKit
class MHelpEnergyAids:MHelpProtocol
{
private let attributedString:NSAttributedString
init()
{
let attributesTitle:[String:AnyObject] = [
NSFontAttributeName:UIFont.bold(size:20),
NSForegroundColorAttributeName:UIColor.white]
let attributesDescription:[String:AnyObject] = [
NSFontAttributeName:UIFont.regular(size:18),
NSForegroundColorAttributeName:UIColor(white:1, alpha:0.8)]
let stringTitle:NSAttributedString = NSAttributedString(
string:NSLocalizedString("MHelpEnergyAids_title", comment:""),
attributes:attributesTitle)
let stringDescription:NSAttributedString = NSAttributedString(
string:NSLocalizedString("MHelpEnergyAids_description", comment:""),
attributes:attributesDescription)
let mutableString:NSMutableAttributedString = NSMutableAttributedString()
mutableString.append(stringTitle)
mutableString.append(stringDescription)
attributedString = mutableString
}
var message:NSAttributedString
{
get
{
return attributedString
}
}
var image:UIImage
{
get
{
return #imageLiteral(resourceName: "assetHelpEnergyAids")
}
}
}
|
mit
|
8976eafc3ed29395e979c396961ae6c0
| 29.75 | 81 | 0.648928 | 5.908297 | false | false | false | false |
harryworld/CocoaSwiftPlayer
|
CocoaSwiftPlayer/Helpers/EventMonitor.swift
|
1
|
743
|
//
// EventMonitor.swift
// CocoaSwiftPlayer
//
// Created by Harry Ng on 17/2/2016.
// Copyright © 2016 STAY REAL. All rights reserved.
//
import Cocoa
final public class EventMonitor {
private var monitor: AnyObject?
private let mask: NSEventMask
private let handler: NSEvent? -> ()
public init(mask: NSEventMask, handler: NSEvent? -> ()) {
self.mask = mask
self.handler = handler
}
deinit {
stop()
}
public func start() {
monitor = NSEvent.addGlobalMonitorForEventsMatchingMask(mask, handler: handler)
}
public func stop() {
if monitor != nil {
NSEvent.removeMonitor(monitor!)
monitor = nil
}
}
}
|
mit
|
1b736aca1e17a76c25fd10be26923f10
| 20.2 | 87 | 0.587601 | 4.24 | false | false | false | false |
aotian16/SwiftJsonToObj
|
SwiftJsonToObj/NSObject_Extension.swift
|
1
|
455
|
//
// NSObject_Extension.swift
//
// Created by 童进 on 15/12/21.
// Copyright © 2015年 qefee. All rights reserved.
//
import Foundation
extension NSObject {
class func pluginDidLoad(bundle: NSBundle) {
let appName = NSBundle.mainBundle().infoDictionary?["CFBundleName"] as? NSString
if appName == "Xcode" {
if sharedPlugin == nil {
sharedPlugin = SwiftJsonToObj(bundle: bundle)
}
}
}
}
|
mit
|
12810b5906e20246c6766daf48d06eb2
| 22.631579 | 88 | 0.622768 | 3.82906 | false | false | false | false |
varshylmobile/RateMyApp
|
RateMyApp.swift
|
1
|
10313
|
//
// RateMyApp.swift
// RateMyApp
//
// Created by Jimmy Jose on 08/09/14.
//
// 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 UIKit
class RateMyApp : UIViewController,UIAlertViewDelegate{
fileprivate let kTrackingAppVersion = "kRateMyApp_TrackingAppVersion"
fileprivate let kFirstUseDate = "kRateMyApp_FirstUseDate"
fileprivate let kAppUseCount = "kRateMyApp_AppUseCount"
fileprivate let kSpecialEventCount = "kRateMyApp_SpecialEventCount"
fileprivate let kDidRateVersion = "kRateMyApp_DidRateVersion"
fileprivate let kDeclinedToRate = "kRateMyApp_DeclinedToRate"
fileprivate let kRemindLater = "kRateMyApp_RemindLater"
fileprivate let kRemindLaterPressedDate = "kRateMyApp_RemindLaterPressedDate"
fileprivate var reviewURL = "itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id="
fileprivate var reviewURLiOS7 = "itms-apps://itunes.apple.com/app/id"
var promptAfterDays:Double = 30
var promptAfterUses = 10
var promptAfterCustomEventsCount = 10
var daysBeforeReminding:Double = 1
var alertTitle = NSLocalizedString("Rate the app", comment: "RateMyApp")
var alertMessage = ""
var alertOKTitle = NSLocalizedString("Rate it now", comment: "RateMyApp")
var alertCancelTitle = NSLocalizedString("Don't bother me again", comment: "RateMyApp")
var alertRemindLaterTitle = NSLocalizedString("Remind me later", comment: "RateMyApp")
var appID = ""
var debug = false
class var sharedInstance : RateMyApp {
struct Static {
static let instance : RateMyApp = RateMyApp()
}
return Static.instance
}
// private override init(){
//
// super.init()
//
// }
internal required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
fileprivate override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
fileprivate func initAllSettings(){
let prefs = UserDefaults.standard
prefs.set(getCurrentAppVersion(), forKey: kTrackingAppVersion)
prefs.set(Date(), forKey: kFirstUseDate)
prefs.set(1, forKey: kAppUseCount)
prefs.set(0, forKey: kSpecialEventCount)
prefs.set(false, forKey: kDidRateVersion)
prefs.set(false, forKey: kDeclinedToRate)
prefs.set(false, forKey: kRemindLater)
}
func trackEventUsage(){
incrementValueForKey(name: kSpecialEventCount)
}
func trackAppUsage(){
incrementValueForKey(name: kAppUseCount)
}
fileprivate func isFirstTime()->Bool{
let prefs = UserDefaults.standard
let trackingAppVersion = prefs.object(forKey: kTrackingAppVersion) as? NSString
if((trackingAppVersion == nil) || !(getCurrentAppVersion().isEqual(to: trackingAppVersion! as String)))
{
return true
}
return false
}
fileprivate func incrementValueForKey(name:String){
if(appID.count == 0)
{
fatalError("Set iTunes connect appID to proceed, you may enter some random string for testing purpose. See line number 59")
}
if(isFirstTime())
{
initAllSettings()
}
else
{
let prefs = UserDefaults.standard
let currentCount = prefs.integer(forKey: name)
prefs.set(currentCount+1, forKey: name)
}
if(shouldShowAlert())
{
showRatingAlert()
}
}
fileprivate func shouldShowAlert() -> Bool{
if debug {
return true
}
let prefs = UserDefaults.standard
let usageCount = prefs.integer(forKey: kAppUseCount)
let eventsCount = prefs.integer(forKey: kSpecialEventCount)
let firstUse = prefs.object(forKey: kFirstUseDate) as! Date
let timeInterval = Date().timeIntervalSince(firstUse)
let daysCount = ((timeInterval / 3600) / 24)
let hasRatedCurrentVersion = prefs.bool(forKey: kDidRateVersion)
let hasDeclinedToRate = prefs.bool(forKey: kDeclinedToRate)
let hasChosenRemindLater = prefs.bool(forKey: kRemindLater)
if(hasDeclinedToRate)
{
return false
}
if(hasRatedCurrentVersion)
{
return false
}
if(hasChosenRemindLater)
{
let remindLaterDate = prefs.object(forKey: kRemindLaterPressedDate) as! Date
let timeInterval = Date().timeIntervalSince(remindLaterDate)
let remindLaterDaysCount = ((timeInterval / 3600) / 24)
return (remindLaterDaysCount >= daysBeforeReminding)
}
if(usageCount >= promptAfterUses)
{
return true
}
if(daysCount >= promptAfterDays)
{
return true
}
if(eventsCount >= promptAfterCustomEventsCount)
{
return true
}
return false
}
fileprivate func showRatingAlert(){
let infoDocs : NSDictionary = Bundle.main.infoDictionary! as NSDictionary
let appname : NSString = infoDocs.object(forKey: "CFBundleName") as! NSString
var message = NSLocalizedString("If you found %@ useful, please take a moment to rate it", comment: "RateMyApp")
message = String(format:message, appname)
if(alertMessage.count == 0)
{
alertMessage = message
}
if #available(iOS 8.0, *) {
let alert = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: alertOKTitle, style:.destructive, handler: { alertAction in
self.okButtonPressed()
alert.dismiss(animated: true, completion: nil)
}))
alert.addAction(UIAlertAction(title: alertCancelTitle, style:.cancel, handler:{ alertAction in
self.cancelButtonPressed()
alert.dismiss(animated: true, completion: nil)
}))
alert.addAction(UIAlertAction(title: alertRemindLaterTitle, style:.default, handler: { alertAction in
self.remindLaterButtonPressed()
alert.dismiss(animated: true, completion: nil)
}))
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let controller = appDelegate.window?.rootViewController
controller?.present(alert, animated: true, completion: nil)
} else {
let alert = UIAlertView()
alert.title = alertTitle
alert.message = alertMessage
alert.addButton(withTitle: alertCancelTitle)
alert.addButton(withTitle: alertRemindLaterTitle)
alert.addButton(withTitle: alertOKTitle)
alert.delegate = self
alert.show()
}
}
internal func alertView(_ alertView: UIAlertView, clickedButtonAt buttonIndex: Int){
if(buttonIndex == 0)
{
cancelButtonPressed()
}
else if(buttonIndex == 1)
{
remindLaterButtonPressed()
}
else if(buttonIndex == 2)
{
okButtonPressed()
}
alertView.dismiss(withClickedButtonIndex: buttonIndex, animated: true)
}
fileprivate func deviceOSVersion() -> Float{
let device : UIDevice = UIDevice.current;
let systemVersion = device.systemVersion;
let iOSVerion : Float = (systemVersion as NSString).floatValue
return iOSVerion
}
fileprivate func hasOS8()->Bool{
if(deviceOSVersion() < 8.0)
{
return false
}
return true
}
fileprivate func okButtonPressed(){
UserDefaults.standard.set(true, forKey: kDidRateVersion)
let appStoreURL = URL(string:reviewURLiOS7+appID)
UIApplication.shared.openURL(appStoreURL!)
}
fileprivate func cancelButtonPressed(){
UserDefaults.standard.set(true, forKey: kDeclinedToRate)
}
fileprivate func remindLaterButtonPressed(){
UserDefaults.standard.set(true, forKey: kRemindLater)
UserDefaults.standard.set(Date(), forKey: kRemindLaterPressedDate)
}
fileprivate func getCurrentAppVersion()->NSString{
return (Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! NSString)
}
}
|
mit
|
9c187fa9238f3d27a892eae3b4ef8316
| 30.1571 | 140 | 0.606031 | 5.1565 | false | false | false | false |
lady12/firefox-ios
|
Client/Frontend/Home/HistoryPanel.swift
|
9
|
18563
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import UIKit
import Shared
import Storage
import XCGLogger
private let log = Logger.browserLogger
private func getDate(dayOffset dayOffset: Int) -> NSDate {
let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
let nowComponents = calendar.components([NSCalendarUnit.Year, NSCalendarUnit.Month, NSCalendarUnit.Day], fromDate: NSDate())
let today = calendar.dateFromComponents(nowComponents)!
return calendar.dateByAddingUnit(NSCalendarUnit.Day, value: dayOffset, toDate: today, options: [])!
}
private typealias SectionNumber = Int
private typealias CategoryNumber = Int
private typealias CategorySpec = (section: SectionNumber?, rows: Int, offset: Int)
private struct HistoryPanelUX {
static let WelcomeScreenPadding: CGFloat = 15
static let WelcomeScreenItemFont = UIFont.systemFontOfSize(UIConstants.DeviceFontSize, weight: UIFontWeightLight) // Changes font size based on device.
static let WelcomeScreenItemTextColor = UIColor.grayColor()
static let WelcomeScreenItemWidth = 170
}
class HistoryPanel: SiteTableViewController, HomePanel {
weak var homePanelDelegate: HomePanelDelegate? = nil
private lazy var emptyStateOverlayView: UIView = self.createEmptyStateOverview()
private let QueryLimit = 100
private let NumSections = 4
private let Today = getDate(dayOffset: 0)
private let Yesterday = getDate(dayOffset: -1)
private let ThisWeek = getDate(dayOffset: -7)
// Category number (index) -> (UI section, row count, cursor offset).
private var categories: [CategorySpec] = [CategorySpec]()
// Reverse lookup from UI section to data category.
private var sectionLookup = [SectionNumber: CategoryNumber]()
private lazy var defaultIcon: UIImage = {
return UIImage(named: "defaultFavicon")!
}()
var refreshControl: UIRefreshControl?
init() {
super.init(nibName: nil, bundle: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "notificationReceived:", name: NotificationFirefoxAccountChanged, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "notificationReceived:", name: NotificationPrivateDataCleared, object: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.accessibilityIdentifier = "History List"
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Add a refresh control if the user is logged in and the control was not added before. If the user is not
// logged in, remove any existing control but only when it is not currently refreshing. Otherwise, wait for
// the refresh to finish before removing the control.
if profile.hasSyncableAccount() && self.refreshControl == nil {
addRefreshControl()
} else if self.refreshControl?.refreshing == false {
removeRefreshControl()
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
deinit {
NSNotificationCenter.defaultCenter().removeObserver(self, name: NotificationFirefoxAccountChanged, object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self, name: NotificationPrivateDataCleared, object: nil)
}
func notificationReceived(notification: NSNotification) {
switch notification.name {
case NotificationFirefoxAccountChanged, NotificationPrivateDataCleared:
resyncHistory()
break
default:
// no need to do anything at all
log.warning("Received unexpected notification \(notification.name)")
break
}
}
func addRefreshControl() {
let refresh = UIRefreshControl()
refresh.addTarget(self, action: "refresh", forControlEvents: UIControlEvents.ValueChanged)
self.refreshControl = refresh
self.tableView.addSubview(refresh)
}
func removeRefreshControl() {
self.refreshControl?.removeFromSuperview()
self.refreshControl = nil
}
func endRefreshing() {
// Always end refreshing, even if we failed!
self.refreshControl?.endRefreshing()
// Remove the refresh control if the user has logged out in the meantime
if !self.profile.hasSyncableAccount() {
self.removeRefreshControl()
}
}
/**
* sync history with the server and ensure that we update our view afterwards
**/
func resyncHistory() {
profile.syncManager.syncHistory().uponQueue(dispatch_get_main_queue()) { result in
if result.isSuccess {
self.reloadData()
} else {
self.endRefreshing()
}
}
}
/**
* called by the table view pull to refresh
**/
@objc func refresh() {
self.refreshControl?.beginRefreshing()
resyncHistory()
}
/**
* fetch from the profile
**/
private func fetchData() -> Deferred<Maybe<Cursor<Site>>> {
return profile.history.getSitesByLastVisit(QueryLimit)
}
private func setData(data: Cursor<Site>) {
self.data = data
self.computeSectionOffsets()
}
/**
* Update our view after a data refresh
**/
override func reloadData() {
self.fetchData().uponQueue(dispatch_get_main_queue()) { result in
if let data = result.successValue {
self.setData(data)
self.tableView.reloadData()
self.updateEmptyPanelState()
}
self.endRefreshing()
// TODO: error handling.
}
}
private func updateEmptyPanelState() {
if data.count == 0 {
if self.emptyStateOverlayView.superview == nil {
self.tableView.addSubview(self.emptyStateOverlayView)
self.emptyStateOverlayView.snp_makeConstraints { make -> Void in
make.edges.equalTo(self.tableView)
make.size.equalTo(self.view)
}
}
} else {
self.emptyStateOverlayView.removeFromSuperview()
}
}
private func createEmptyStateOverview() -> UIView {
let overlayView = UIView()
overlayView.backgroundColor = UIColor.whiteColor()
let logoImageView = UIImageView(image: UIImage(named: "emptyHistory"))
overlayView.addSubview(logoImageView)
logoImageView.snp_makeConstraints { make in
make.centerX.equalTo(overlayView)
// Sets proper top constraint for iPhone 6 in portait and for iPad.
make.centerY.equalTo(overlayView.snp_centerY).offset(-160).priorityMedium()
// Sets proper top constraint for iPhone 4, 5 in portrait.
make.top.greaterThanOrEqualTo(overlayView.snp_top).offset(50).priorityHigh()
}
let welcomeLabel = UILabel()
overlayView.addSubview(welcomeLabel)
welcomeLabel.text = NSLocalizedString("Pages you have visited recently will show up here.", comment: "See http://bit.ly/1I7Do4b")
welcomeLabel.textAlignment = NSTextAlignment.Center
welcomeLabel.font = HistoryPanelUX.WelcomeScreenItemFont
welcomeLabel.textColor = HistoryPanelUX.WelcomeScreenItemTextColor
welcomeLabel.numberOfLines = 2
welcomeLabel.adjustsFontSizeToFitWidth = true
welcomeLabel.snp_makeConstraints { make in
make.centerX.equalTo(overlayView)
make.top.equalTo(logoImageView.snp_bottom).offset(HistoryPanelUX.WelcomeScreenPadding)
make.width.equalTo(HistoryPanelUX.WelcomeScreenItemWidth)
}
return overlayView
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = super.tableView(tableView, cellForRowAtIndexPath: indexPath)
let category = self.categories[indexPath.section]
if let site = data[indexPath.row + category.offset] {
if let cell = cell as? TwoLineTableViewCell {
cell.setLines(site.title, detailText: site.url)
cell.imageView?.setIcon(site.icon, withPlaceholder: self.defaultIcon)
}
}
return cell
}
private func siteForIndexPath(indexPath: NSIndexPath) -> Site? {
let offset = self.categories[sectionLookup[indexPath.section]!].offset
return data[indexPath.row + offset]
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if let site = self.siteForIndexPath(indexPath),
let url = NSURL(string: site.url) {
let visitType = VisitType.Typed // Means History, too.
homePanelDelegate?.homePanel(self, didSelectURL: url, visitType: visitType)
return
}
log.warning("No site or no URL when selecting row.")
}
// Functions that deal with showing header rows.
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
var count = 0
for category in self.categories {
if category.rows > 0 {
count++
}
}
return count
}
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
var title = String()
switch sectionLookup[section]! {
case 0: title = NSLocalizedString("Today", comment: "History tableview section header")
case 1: title = NSLocalizedString("Yesterday", comment: "History tableview section header")
case 2: title = NSLocalizedString("Last week", comment: "History tableview section header")
case 3: title = NSLocalizedString("Last month", comment: "History tableview section header")
default:
assertionFailure("Invalid history section \(section)")
}
return title
}
func categoryForDate(date: MicrosecondTimestamp) -> Int {
let date = Double(date)
if date > (1000000 * Today.timeIntervalSince1970) {
return 0
}
if date > (1000000 * Yesterday.timeIntervalSince1970) {
return 1
}
if date > (1000000 * ThisWeek.timeIntervalSince1970) {
return 2
}
return 3
}
private func isInCategory(date: MicrosecondTimestamp, category: Int) -> Bool {
return self.categoryForDate(date) == category
}
func computeSectionOffsets() {
var counts = [Int](count: NumSections, repeatedValue: 0)
// Loop over all the data. Record the start of each "section" of our list.
for i in 0..<data.count {
if let site = data[i] {
counts[categoryForDate(site.latestVisit!.date)]++
}
}
var section = 0
var offset = 0
self.categories = [CategorySpec]()
for i in 0..<NumSections {
let count = counts[i]
if count > 0 {
log.debug("Category \(i) has \(count) rows, and thus is section \(section).")
self.categories.append((section: section, rows: count, offset: offset))
sectionLookup[section] = i
offset += count
section++
} else {
log.debug("Category \(i) has 0 rows, and thus has no section.")
self.categories.append((section: nil, rows: 0, offset: offset))
}
}
}
// UI sections disappear as categories empty. We need to translate back and forth.
private func uiSectionToCategory(section: SectionNumber) -> CategoryNumber {
for i in 0..<self.categories.count {
if let s = self.categories[i].section where s == section {
return i
}
}
return 0
}
private func categoryToUISection(category: CategoryNumber) -> SectionNumber? {
return self.categories[category].section
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.categories[uiSectionToCategory(section)].rows
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
// Intentionally blank. Required to use UITableViewRowActions
}
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
let title = NSLocalizedString("Remove", tableName: "HistoryPanel", comment: "Action button for deleting history entries in the history panel.")
let delete = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: title, handler: { (action, indexPath) in
if let site = self.siteForIndexPath(indexPath) {
// Why the dispatches? Because we call success and failure on the DB
// queue, and so calling anything else that calls through to the DB will
// deadlock. This problem will go away when the history API switches to
// Deferred instead of using callbacks.
self.profile.history.removeHistoryForURL(site.url)
.upon { res in
self.fetchData().uponQueue(dispatch_get_main_queue()) { result in
// If a section will be empty after removal, we must remove the section itself.
if let data = result.successValue {
let oldCategories = self.categories
self.data = data
self.computeSectionOffsets()
let sectionsToDelete = NSMutableIndexSet()
var rowsToDelete = [NSIndexPath]()
let sectionsToAdd = NSMutableIndexSet()
var rowsToAdd = [NSIndexPath]()
for (index, category) in self.categories.enumerate() {
let oldCategory = oldCategories[index]
// don't bother if we're not displaying this category
if oldCategory.section == nil && category.section == nil {
continue
}
// 1. add a new section if the section didn't previously exist
if oldCategory.section == nil && category.section != oldCategory.section {
log.debug("adding section \(category.section)")
sectionsToAdd.addIndex(category.section!)
}
// 2. add a new row if there are more rows now than there were before
if oldCategory.rows < category.rows {
log.debug("adding row to \(category.section) at \(category.rows-1)")
rowsToAdd.append(NSIndexPath(forRow: category.rows-1, inSection: category.section!))
}
// if we're dealing with the section where the row was deleted:
// 1. if the category no longer has a section, then we need to delete the entire section
// 2. delete a row if the number of rows has been reduced
// 3. delete the selected row and add a new one on the bottom of the section if the number of rows has stayed the same
if oldCategory.section == indexPath.section {
if category.section == nil {
log.debug("deleting section \(indexPath.section)")
sectionsToDelete.addIndex(indexPath.section)
} else if oldCategory.section == category.section {
if oldCategory.rows > category.rows {
log.debug("deleting row from \(category.section) at \(indexPath.row)")
rowsToDelete.append(indexPath)
} else if category.rows == oldCategory.rows {
log.debug("in section \(category.section), removing row at \(indexPath.row) and inserting row at \(category.rows-1)")
rowsToDelete.append(indexPath)
rowsToAdd.append(NSIndexPath(forRow: category.rows-1, inSection: indexPath.section))
}
}
}
}
tableView.beginUpdates()
if sectionsToAdd.count > 0 {
tableView.insertSections(sectionsToAdd, withRowAnimation: UITableViewRowAnimation.Left)
}
if sectionsToDelete.count > 0 {
tableView.deleteSections(sectionsToDelete, withRowAnimation: UITableViewRowAnimation.Right)
}
if !rowsToDelete.isEmpty {
tableView.deleteRowsAtIndexPaths(rowsToDelete, withRowAnimation: UITableViewRowAnimation.Right)
}
if !rowsToAdd.isEmpty {
tableView.insertRowsAtIndexPaths(rowsToAdd, withRowAnimation: UITableViewRowAnimation.Right)
}
tableView.endUpdates()
self.updateEmptyPanelState()
}
}
}
}
})
return [delete]
}
}
|
mpl-2.0
|
db22c8e4309c0dd9d40bd11ad4330ea1
| 42.371495 | 165 | 0.587136 | 5.813655 | false | false | false | false |
eduarenas80/MarvelClient
|
Tests/RequestBuilders/CreatorRequestBuilderTests.swift
|
2
|
5424
|
//
// CreatorRequestBuilderTests.swift
// MarvelClient
//
// Copyright (c) 2016 Eduardo Arenas <[email protected]>
//
// 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 XCTest
@testable import MarvelClient
class CreatorRequestBuilderTests: XCTestCase {
let marvelClient = MarvelClient(privateKey: "private", publicKey: "public")
var requestBuilder: CreatorRequestBuilder?
override func setUp() {
super.setUp()
self.requestBuilder = self.marvelClient.requestCreators()
}
func testGetsInitializedWithCreatorsEntityType() {
XCTAssertEqual(self.requestBuilder?.entityType, "creators")
}
func testDefaultRequestContainsAuthParameters() {
XCTAssertNotNil(self.requestBuilder!.parameters["ts"])
XCTAssertEqual(self.requestBuilder!.parameters["apikey"] as? String, "public")
XCTAssertNotNil(self.requestBuilder!.parameters["hash"])
}
func testFirstNameTitleGetsSetOnRequest() {
let builder = self.requestBuilder!.firstName("Stan")
XCTAssertEqual(builder.parameters["firstName"] as? String, "Stan")
}
func testMiddleNameWithGetsSetOnRequest() {
let builder = self.requestBuilder!.middleName("Martin")
XCTAssertEqual(builder.parameters["middleName"] as? String, "Martin")
}
func testLastNameWithGetsSetOnRequest() {
let builder = self.requestBuilder!.lastName("Lee")
XCTAssertEqual(builder.parameters["lastName"] as? String, "Lee")
}
func testSuffixWithGetsSetOnRequest() {
let builder = self.requestBuilder!.suffix("Jr")
XCTAssertEqual(builder.parameters["suffix"] as? String, "Jr")
}
func testFirstNameStartsWithTitleGetsSetOnRequest() {
let builder = self.requestBuilder!.firstNameStartsWith("Stan")
XCTAssertEqual(builder.parameters["firstNameStartsWith"] as? String, "Stan")
}
func testMiddleNameStartsWithWithGetsSetOnRequest() {
let builder = self.requestBuilder!.middleNameStartsWith("Martin")
XCTAssertEqual(builder.parameters["middleNameStartsWith"] as? String, "Martin")
}
func testLastNameStartsWithWithGetsSetOnRequest() {
let builder = self.requestBuilder!.lastNameStartsWith("Lee")
XCTAssertEqual(builder.parameters["lastNameStartsWith"] as? String, "Lee")
}
func testComicsGetsSetOnRequest() {
let builder = self.requestBuilder!.comics([1, 2, 3])
XCTAssertEqual(builder.parameters["comics"] as? String, "1,2,3")
}
func testSeriesGetsSetOnRequest() {
let builder = self.requestBuilder!.series([1, 2, 3])
XCTAssertEqual(builder.parameters["series"] as? String, "1,2,3")
}
func testEventsGetsSetOnRequest() {
let builder = self.requestBuilder!.events([1, 2, 3])
XCTAssertEqual(builder.parameters["events"] as? String, "1,2,3")
}
func testStoriesGetsSetOnRequest() {
let builder = self.requestBuilder!.stories([1, 2, 3])
XCTAssertEqual(builder.parameters["stories"] as? String, "1,2,3")
}
func testOrderByGetsSetOnRequest() {
let builder = self.requestBuilder!.orderBy([.LastName])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "lastName")
builder.orderBy([.FirstName])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "firstName")
builder.orderBy([.MiddleName])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "middleName")
builder.orderBy([.Suffix])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "suffix")
builder.orderBy([.Modified])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "modified")
builder.orderBy([.LastNameDescending])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "-lastName")
builder.orderBy([.FirstNameDescending])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "-firstName")
builder.orderBy([.MiddleNameDescending])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "-middleName")
builder.orderBy([.SuffixDescending])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "-suffix")
builder.orderBy([.ModifiedDescending])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "-modified")
}
func testOrderByGetsSetOnRequestWithMultipleCriteria() {
let builder = self.requestBuilder!.orderBy([.FirstName, .SuffixDescending])
XCTAssertEqual(builder.parameters["orderBy"] as? String, "firstName,-suffix")
}
}
|
mit
|
4892aa8fded5ca46e31ec733d40caa43
| 37.468085 | 83 | 0.72806 | 4.377724 | false | true | false | false |
c-Viorel/MBIcons
|
MBIconsKit/MBWheatherKit.swift
|
1
|
478555
|
//
// MBWheatherKit.swift
// MBIconsSet
//
// Created by Porumbescu Viorel on 07/04/2017.
// Copyright © 2017 MingleBit. All rights reserved.
//
// Generated by PaintCode
// http://www.paintcodeapp.com
//
import Cocoa
public class MBWheatherKit : NSObject {
//// Drawing Methods
public dynamic class func drawCloudSun(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// path Drawing
let pathPath = NSBezierPath()
pathPath.move(to: NSPoint(x: 5.6, y: 11.9))
pathPath.curve(to: NSPoint(x: 2.5, y: 8), controlPoint1: NSPoint(x: 3.82, y: 11.49), controlPoint2: NSPoint(x: 2.5, y: 9.9))
pathPath.curve(to: NSPoint(x: 6.5, y: 4), controlPoint1: NSPoint(x: 2.5, y: 5.79), controlPoint2: NSPoint(x: 4.3, y: 4))
pathPath.line(to: NSPoint(x: 23.5, y: 4))
pathPath.curve(to: NSPoint(x: 27.5, y: 8), controlPoint1: NSPoint(x: 25.71, y: 4), controlPoint2: NSPoint(x: 27.5, y: 5.8))
pathPath.curve(to: NSPoint(x: 24.46, y: 11.88), controlPoint1: NSPoint(x: 27.5, y: 9.88), controlPoint2: NSPoint(x: 26.2, y: 11.45))
pathPath.line(to: NSPoint(x: 24.46, y: 11.88))
pathPath.curve(to: NSPoint(x: 24.5, y: 12.5), controlPoint1: NSPoint(x: 24.49, y: 12.09), controlPoint2: NSPoint(x: 24.5, y: 12.29))
pathPath.curve(to: NSPoint(x: 20, y: 17), controlPoint1: NSPoint(x: 24.5, y: 14.99), controlPoint2: NSPoint(x: 22.49, y: 17))
pathPath.curve(to: NSPoint(x: 16.85, y: 15.72), controlPoint1: NSPoint(x: 18.77, y: 17), controlPoint2: NSPoint(x: 17.66, y: 16.51))
pathPath.curve(to: NSPoint(x: 11.5, y: 19), controlPoint1: NSPoint(x: 15.86, y: 17.66), controlPoint2: NSPoint(x: 13.84, y: 19))
pathPath.curve(to: NSPoint(x: 5.5, y: 13), controlPoint1: NSPoint(x: 8.19, y: 19), controlPoint2: NSPoint(x: 5.5, y: 16.31))
pathPath.curve(to: NSPoint(x: 5.6, y: 11.9), controlPoint1: NSPoint(x: 5.5, y: 12.62), controlPoint2: NSPoint(x: 5.53, y: 12.26))
pathPath.line(to: NSPoint(x: 5.6, y: 11.9))
pathPath.close()
pathPath.move(to: NSPoint(x: 23.45, y: 16.78))
pathPath.curve(to: NSPoint(x: 23.5, y: 17.5), controlPoint1: NSPoint(x: 23.48, y: 17.02), controlPoint2: NSPoint(x: 23.5, y: 17.26))
pathPath.curve(to: NSPoint(x: 18, y: 23), controlPoint1: NSPoint(x: 23.5, y: 20.54), controlPoint2: NSPoint(x: 21.04, y: 23))
pathPath.curve(to: NSPoint(x: 13.02, y: 19.83), controlPoint1: NSPoint(x: 15.8, y: 23), controlPoint2: NSPoint(x: 13.9, y: 21.71))
pathPath.line(to: NSPoint(x: 13.02, y: 19.83))
pathPath.curve(to: NSPoint(x: 11.5, y: 20), controlPoint1: NSPoint(x: 12.53, y: 19.94), controlPoint2: NSPoint(x: 12.02, y: 20))
pathPath.curve(to: NSPoint(x: 4.5, y: 13), controlPoint1: NSPoint(x: 7.63, y: 20), controlPoint2: NSPoint(x: 4.5, y: 16.87))
pathPath.curve(to: NSPoint(x: 4.51, y: 12.59), controlPoint1: NSPoint(x: 4.5, y: 12.86), controlPoint2: NSPoint(x: 4.5, y: 12.72))
pathPath.curve(to: NSPoint(x: 1.5, y: 8), controlPoint1: NSPoint(x: 2.74, y: 11.82), controlPoint2: NSPoint(x: 1.5, y: 10.05))
pathPath.curve(to: NSPoint(x: 6.5, y: 3), controlPoint1: NSPoint(x: 1.5, y: 5.24), controlPoint2: NSPoint(x: 3.73, y: 3))
pathPath.line(to: NSPoint(x: 23.5, y: 3))
pathPath.curve(to: NSPoint(x: 28.5, y: 8), controlPoint1: NSPoint(x: 26.26, y: 3), controlPoint2: NSPoint(x: 28.5, y: 5.24))
pathPath.curve(to: NSPoint(x: 25.5, y: 12.59), controlPoint1: NSPoint(x: 28.5, y: 10.05), controlPoint2: NSPoint(x: 27.27, y: 11.81))
pathPath.curve(to: NSPoint(x: 23.45, y: 16.78), controlPoint1: NSPoint(x: 25.47, y: 14.28), controlPoint2: NSPoint(x: 24.68, y: 15.79))
pathPath.line(to: NSPoint(x: 23.45, y: 16.78))
pathPath.line(to: NSPoint(x: 23.45, y: 16.78))
pathPath.close()
pathPath.move(to: NSPoint(x: 22.5, y: 17.4))
pathPath.curve(to: NSPoint(x: 22.5, y: 17.5), controlPoint1: NSPoint(x: 22.5, y: 17.43), controlPoint2: NSPoint(x: 22.5, y: 17.47))
pathPath.curve(to: NSPoint(x: 18, y: 22), controlPoint1: NSPoint(x: 22.5, y: 19.99), controlPoint2: NSPoint(x: 20.49, y: 22))
pathPath.curve(to: NSPoint(x: 13.99, y: 19.54), controlPoint1: NSPoint(x: 16.25, y: 22), controlPoint2: NSPoint(x: 14.73, y: 21))
pathPath.curve(to: NSPoint(x: 17.11, y: 17.18), controlPoint1: NSPoint(x: 15.24, y: 19.07), controlPoint2: NSPoint(x: 16.32, y: 18.24))
pathPath.curve(to: NSPoint(x: 20, y: 18), controlPoint1: NSPoint(x: 17.95, y: 17.7), controlPoint2: NSPoint(x: 18.94, y: 18))
pathPath.curve(to: NSPoint(x: 22.5, y: 17.4), controlPoint1: NSPoint(x: 20.9, y: 18), controlPoint2: NSPoint(x: 21.75, y: 17.78))
pathPath.line(to: NSPoint(x: 22.5, y: 17.4))
pathPath.line(to: NSPoint(x: 22.5, y: 17.4))
pathPath.close()
pathPath.move(to: NSPoint(x: 18, y: 27))
pathPath.curve(to: NSPoint(x: 17.5, y: 26.5), controlPoint1: NSPoint(x: 17.72, y: 27), controlPoint2: NSPoint(x: 17.5, y: 26.78))
pathPath.line(to: NSPoint(x: 17.5, y: 24.5))
pathPath.curve(to: NSPoint(x: 18, y: 24), controlPoint1: NSPoint(x: 17.5, y: 24.22), controlPoint2: NSPoint(x: 17.73, y: 24))
pathPath.curve(to: NSPoint(x: 18.5, y: 24.5), controlPoint1: NSPoint(x: 18.28, y: 24), controlPoint2: NSPoint(x: 18.5, y: 24.22))
pathPath.line(to: NSPoint(x: 18.5, y: 26.5))
pathPath.curve(to: NSPoint(x: 18, y: 27), controlPoint1: NSPoint(x: 18.5, y: 26.78), controlPoint2: NSPoint(x: 18.27, y: 27))
pathPath.line(to: NSPoint(x: 18, y: 27))
pathPath.close()
pathPath.move(to: NSPoint(x: 24.73, y: 24.21))
pathPath.curve(to: NSPoint(x: 24.03, y: 24.21), controlPoint1: NSPoint(x: 24.54, y: 24.41), controlPoint2: NSPoint(x: 24.23, y: 24.41))
pathPath.line(to: NSPoint(x: 22.61, y: 22.79))
pathPath.curve(to: NSPoint(x: 22.61, y: 22.09), controlPoint1: NSPoint(x: 22.42, y: 22.6), controlPoint2: NSPoint(x: 22.42, y: 22.28))
pathPath.curve(to: NSPoint(x: 23.32, y: 22.09), controlPoint1: NSPoint(x: 22.81, y: 21.89), controlPoint2: NSPoint(x: 23.12, y: 21.89))
pathPath.line(to: NSPoint(x: 24.74, y: 23.51))
pathPath.curve(to: NSPoint(x: 24.73, y: 24.21), controlPoint1: NSPoint(x: 24.93, y: 23.7), controlPoint2: NSPoint(x: 24.92, y: 24.02))
pathPath.line(to: NSPoint(x: 24.73, y: 24.21))
pathPath.close()
pathPath.move(to: NSPoint(x: 27.52, y: 17.48))
pathPath.curve(to: NSPoint(x: 27.03, y: 17.98), controlPoint1: NSPoint(x: 27.52, y: 17.75), controlPoint2: NSPoint(x: 27.31, y: 17.98))
pathPath.line(to: NSPoint(x: 25.02, y: 17.98))
pathPath.curve(to: NSPoint(x: 24.52, y: 17.48), controlPoint1: NSPoint(x: 24.74, y: 17.98), controlPoint2: NSPoint(x: 24.52, y: 17.75))
pathPath.curve(to: NSPoint(x: 25.02, y: 16.98), controlPoint1: NSPoint(x: 24.52, y: 17.2), controlPoint2: NSPoint(x: 24.74, y: 16.98))
pathPath.line(to: NSPoint(x: 27.03, y: 16.98))
pathPath.curve(to: NSPoint(x: 27.52, y: 17.48), controlPoint1: NSPoint(x: 27.3, y: 16.98), controlPoint2: NSPoint(x: 27.52, y: 17.21))
pathPath.line(to: NSPoint(x: 27.52, y: 17.48))
pathPath.close()
pathPath.move(to: NSPoint(x: 11.27, y: 24.21))
pathPath.curve(to: NSPoint(x: 11.26, y: 23.51), controlPoint1: NSPoint(x: 11.07, y: 24.02), controlPoint2: NSPoint(x: 11.07, y: 23.7))
pathPath.line(to: NSPoint(x: 12.68, y: 22.09))
pathPath.curve(to: NSPoint(x: 13.39, y: 22.09), controlPoint1: NSPoint(x: 12.88, y: 21.89), controlPoint2: NSPoint(x: 13.2, y: 21.9))
pathPath.curve(to: NSPoint(x: 13.39, y: 22.79), controlPoint1: NSPoint(x: 13.58, y: 22.29), controlPoint2: NSPoint(x: 13.59, y: 22.6))
pathPath.line(to: NSPoint(x: 11.97, y: 24.21))
pathPath.curve(to: NSPoint(x: 11.27, y: 24.21), controlPoint1: NSPoint(x: 11.78, y: 24.41), controlPoint2: NSPoint(x: 11.46, y: 24.4))
pathPath.line(to: NSPoint(x: 11.27, y: 24.21))
pathPath.close()
pathPath.windingRule = .evenOddWindingRule
fillColor.setFill()
pathPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudMoon(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// path Drawing
let pathPath = NSBezierPath()
pathPath.move(to: NSPoint(x: 5.6, y: 12.4))
pathPath.curve(to: NSPoint(x: 2.5, y: 8.5), controlPoint1: NSPoint(x: 3.82, y: 11.99), controlPoint2: NSPoint(x: 2.5, y: 10.4))
pathPath.curve(to: NSPoint(x: 6.5, y: 4.5), controlPoint1: NSPoint(x: 2.5, y: 6.29), controlPoint2: NSPoint(x: 4.3, y: 4.5))
pathPath.line(to: NSPoint(x: 23.5, y: 4.5))
pathPath.curve(to: NSPoint(x: 27.5, y: 8.5), controlPoint1: NSPoint(x: 25.71, y: 4.5), controlPoint2: NSPoint(x: 27.5, y: 6.3))
pathPath.curve(to: NSPoint(x: 24.46, y: 12.38), controlPoint1: NSPoint(x: 27.5, y: 10.38), controlPoint2: NSPoint(x: 26.2, y: 11.95))
pathPath.line(to: NSPoint(x: 24.46, y: 12.38))
pathPath.curve(to: NSPoint(x: 24.5, y: 13), controlPoint1: NSPoint(x: 24.49, y: 12.59), controlPoint2: NSPoint(x: 24.5, y: 12.79))
pathPath.curve(to: NSPoint(x: 20, y: 17.5), controlPoint1: NSPoint(x: 24.5, y: 15.49), controlPoint2: NSPoint(x: 22.49, y: 17.5))
pathPath.curve(to: NSPoint(x: 16.85, y: 16.22), controlPoint1: NSPoint(x: 18.77, y: 17.5), controlPoint2: NSPoint(x: 17.66, y: 17.01))
pathPath.curve(to: NSPoint(x: 11.5, y: 19.5), controlPoint1: NSPoint(x: 15.86, y: 18.16), controlPoint2: NSPoint(x: 13.84, y: 19.5))
pathPath.curve(to: NSPoint(x: 5.5, y: 13.5), controlPoint1: NSPoint(x: 8.19, y: 19.5), controlPoint2: NSPoint(x: 5.5, y: 16.81))
pathPath.curve(to: NSPoint(x: 5.6, y: 12.4), controlPoint1: NSPoint(x: 5.5, y: 13.12), controlPoint2: NSPoint(x: 5.53, y: 12.76))
pathPath.line(to: NSPoint(x: 5.6, y: 12.4))
pathPath.close()
pathPath.move(to: NSPoint(x: 23.77, y: 17))
pathPath.curve(to: NSPoint(x: 25.34, y: 19.66), controlPoint1: NSPoint(x: 24.53, y: 17.71), controlPoint2: NSPoint(x: 25.08, y: 18.63))
pathPath.curve(to: NSPoint(x: 25.49, y: 20.75), controlPoint1: NSPoint(x: 25.42, y: 20.01), controlPoint2: NSPoint(x: 25.48, y: 20.38))
pathPath.curve(to: NSPoint(x: 24, y: 20.5), controlPoint1: NSPoint(x: 25.03, y: 20.59), controlPoint2: NSPoint(x: 24.52, y: 20.5))
pathPath.curve(to: NSPoint(x: 19.5, y: 25), controlPoint1: NSPoint(x: 21.51, y: 20.5), controlPoint2: NSPoint(x: 19.5, y: 22.51))
pathPath.curve(to: NSPoint(x: 19.75, y: 26.49), controlPoint1: NSPoint(x: 19.5, y: 25.52), controlPoint2: NSPoint(x: 19.59, y: 26.03))
pathPath.curve(to: NSPoint(x: 18.66, y: 26.34), controlPoint1: NSPoint(x: 19.38, y: 26.48), controlPoint2: NSPoint(x: 19.01, y: 26.42))
pathPath.curve(to: NSPoint(x: 14.5, y: 21), controlPoint1: NSPoint(x: 16.27, y: 25.74), controlPoint2: NSPoint(x: 14.5, y: 23.58))
pathPath.curve(to: NSPoint(x: 14.64, y: 19.76), controlPoint1: NSPoint(x: 14.5, y: 20.57), controlPoint2: NSPoint(x: 14.55, y: 20.16))
pathPath.curve(to: NSPoint(x: 11.5, y: 20.5), controlPoint1: NSPoint(x: 13.7, y: 20.23), controlPoint2: NSPoint(x: 12.63, y: 20.5))
pathPath.curve(to: NSPoint(x: 4.5, y: 13.5), controlPoint1: NSPoint(x: 7.63, y: 20.5), controlPoint2: NSPoint(x: 4.5, y: 17.37))
pathPath.curve(to: NSPoint(x: 4.51, y: 13.09), controlPoint1: NSPoint(x: 4.5, y: 13.36), controlPoint2: NSPoint(x: 4.5, y: 13.22))
pathPath.curve(to: NSPoint(x: 1.5, y: 8.5), controlPoint1: NSPoint(x: 2.74, y: 12.32), controlPoint2: NSPoint(x: 1.5, y: 10.55))
pathPath.curve(to: NSPoint(x: 6.5, y: 3.5), controlPoint1: NSPoint(x: 1.5, y: 5.74), controlPoint2: NSPoint(x: 3.73, y: 3.5))
pathPath.line(to: NSPoint(x: 23.5, y: 3.5))
pathPath.curve(to: NSPoint(x: 28.5, y: 8.5), controlPoint1: NSPoint(x: 26.26, y: 3.5), controlPoint2: NSPoint(x: 28.5, y: 5.74))
pathPath.curve(to: NSPoint(x: 25.5, y: 13.09), controlPoint1: NSPoint(x: 28.5, y: 10.55), controlPoint2: NSPoint(x: 27.27, y: 12.31))
pathPath.curve(to: NSPoint(x: 23.77, y: 17), controlPoint1: NSPoint(x: 25.48, y: 14.63), controlPoint2: NSPoint(x: 24.82, y: 16.02))
pathPath.line(to: NSPoint(x: 23.77, y: 17))
pathPath.line(to: NSPoint(x: 23.77, y: 17))
pathPath.close()
pathPath.move(to: NSPoint(x: 22.98, y: 17.63))
pathPath.curve(to: NSPoint(x: 24.25, y: 19.51), controlPoint1: NSPoint(x: 23.55, y: 18.13), controlPoint2: NSPoint(x: 23.99, y: 18.77))
pathPath.curve(to: NSPoint(x: 24, y: 19.5), controlPoint1: NSPoint(x: 24.16, y: 19.5), controlPoint2: NSPoint(x: 24.08, y: 19.5))
pathPath.curve(to: NSPoint(x: 18.5, y: 25), controlPoint1: NSPoint(x: 20.96, y: 19.5), controlPoint2: NSPoint(x: 18.5, y: 21.96))
pathPath.curve(to: NSPoint(x: 18.51, y: 25.25), controlPoint1: NSPoint(x: 18.5, y: 25.08), controlPoint2: NSPoint(x: 18.5, y: 25.16))
pathPath.curve(to: NSPoint(x: 15.5, y: 21), controlPoint1: NSPoint(x: 16.75, y: 24.63), controlPoint2: NSPoint(x: 15.5, y: 22.96))
pathPath.curve(to: NSPoint(x: 16.07, y: 18.8), controlPoint1: NSPoint(x: 15.5, y: 20.2), controlPoint2: NSPoint(x: 15.71, y: 19.45))
pathPath.curve(to: NSPoint(x: 17.11, y: 17.68), controlPoint1: NSPoint(x: 16.46, y: 18.47), controlPoint2: NSPoint(x: 16.81, y: 18.09))
pathPath.curve(to: NSPoint(x: 20, y: 18.5), controlPoint1: NSPoint(x: 17.95, y: 18.2), controlPoint2: NSPoint(x: 18.94, y: 18.5))
pathPath.curve(to: NSPoint(x: 22.98, y: 17.63), controlPoint1: NSPoint(x: 21.1, y: 18.5), controlPoint2: NSPoint(x: 22.12, y: 18.18))
pathPath.line(to: NSPoint(x: 22.98, y: 17.63))
pathPath.line(to: NSPoint(x: 22.98, y: 17.63))
pathPath.close()
pathPath.windingRule = .evenOddWindingRule
fillColor.setFill()
pathPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudRain(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 18.4))
mainPath.curve(to: NSPoint(x: 2.5, y: 14.5), controlPoint1: NSPoint(x: 3.82, y: 17.99), controlPoint2: NSPoint(x: 2.5, y: 16.4))
mainPath.curve(to: NSPoint(x: 6.5, y: 10.5), controlPoint1: NSPoint(x: 2.5, y: 12.29), controlPoint2: NSPoint(x: 4.3, y: 10.5))
mainPath.line(to: NSPoint(x: 23.5, y: 10.5))
mainPath.curve(to: NSPoint(x: 27.5, y: 14.5), controlPoint1: NSPoint(x: 25.71, y: 10.5), controlPoint2: NSPoint(x: 27.5, y: 12.3))
mainPath.curve(to: NSPoint(x: 24.46, y: 18.38), controlPoint1: NSPoint(x: 27.5, y: 16.38), controlPoint2: NSPoint(x: 26.2, y: 17.95))
mainPath.line(to: NSPoint(x: 24.46, y: 18.38))
mainPath.curve(to: NSPoint(x: 24.5, y: 19), controlPoint1: NSPoint(x: 24.49, y: 18.59), controlPoint2: NSPoint(x: 24.5, y: 18.79))
mainPath.curve(to: NSPoint(x: 20, y: 23.5), controlPoint1: NSPoint(x: 24.5, y: 21.49), controlPoint2: NSPoint(x: 22.49, y: 23.5))
mainPath.curve(to: NSPoint(x: 16.85, y: 22.22), controlPoint1: NSPoint(x: 18.77, y: 23.5), controlPoint2: NSPoint(x: 17.66, y: 23.01))
mainPath.curve(to: NSPoint(x: 11.5, y: 25.5), controlPoint1: NSPoint(x: 15.86, y: 24.16), controlPoint2: NSPoint(x: 13.84, y: 25.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 19.5), controlPoint1: NSPoint(x: 8.19, y: 25.5), controlPoint2: NSPoint(x: 5.5, y: 22.81))
mainPath.curve(to: NSPoint(x: 5.6, y: 18.4), controlPoint1: NSPoint(x: 5.5, y: 19.12), controlPoint2: NSPoint(x: 5.53, y: 18.76))
mainPath.line(to: NSPoint(x: 5.6, y: 18.4))
mainPath.line(to: NSPoint(x: 5.6, y: 18.4))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.5, y: 19.09))
mainPath.curve(to: NSPoint(x: 28.5, y: 14.5), controlPoint1: NSPoint(x: 27.27, y: 18.31), controlPoint2: NSPoint(x: 28.5, y: 16.55))
mainPath.curve(to: NSPoint(x: 23.5, y: 9.5), controlPoint1: NSPoint(x: 28.5, y: 11.74), controlPoint2: NSPoint(x: 26.26, y: 9.5))
mainPath.line(to: NSPoint(x: 6.5, y: 9.5))
mainPath.curve(to: NSPoint(x: 1.5, y: 14.5), controlPoint1: NSPoint(x: 3.73, y: 9.5), controlPoint2: NSPoint(x: 1.5, y: 11.74))
mainPath.curve(to: NSPoint(x: 4.51, y: 19.09), controlPoint1: NSPoint(x: 1.5, y: 16.55), controlPoint2: NSPoint(x: 2.74, y: 18.32))
mainPath.line(to: NSPoint(x: 4.51, y: 19.09))
mainPath.curve(to: NSPoint(x: 4.5, y: 19.5), controlPoint1: NSPoint(x: 4.5, y: 19.22), controlPoint2: NSPoint(x: 4.5, y: 19.36))
mainPath.curve(to: NSPoint(x: 11.5, y: 26.5), controlPoint1: NSPoint(x: 4.5, y: 23.37), controlPoint2: NSPoint(x: 7.63, y: 26.5))
mainPath.curve(to: NSPoint(x: 17.11, y: 23.68), controlPoint1: NSPoint(x: 13.8, y: 26.5), controlPoint2: NSPoint(x: 15.84, y: 25.39))
mainPath.curve(to: NSPoint(x: 20, y: 24.5), controlPoint1: NSPoint(x: 17.95, y: 24.2), controlPoint2: NSPoint(x: 18.94, y: 24.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 19.09), controlPoint1: NSPoint(x: 23.01, y: 24.5), controlPoint2: NSPoint(x: 25.45, y: 22.08))
mainPath.line(to: NSPoint(x: 25.5, y: 19.09))
mainPath.line(to: NSPoint(x: 25.5, y: 19.09))
mainPath.close()
mainPath.move(to: NSPoint(x: 9, y: 8.5))
mainPath.curve(to: NSPoint(x: 8.5, y: 8), controlPoint1: NSPoint(x: 8.72, y: 8.5), controlPoint2: NSPoint(x: 8.5, y: 8.28))
mainPath.line(to: NSPoint(x: 8.5, y: 6))
mainPath.curve(to: NSPoint(x: 9, y: 5.5), controlPoint1: NSPoint(x: 8.5, y: 5.72), controlPoint2: NSPoint(x: 8.73, y: 5.5))
mainPath.curve(to: NSPoint(x: 9.5, y: 6), controlPoint1: NSPoint(x: 9.28, y: 5.5), controlPoint2: NSPoint(x: 9.5, y: 5.72))
mainPath.line(to: NSPoint(x: 9.5, y: 8))
mainPath.curve(to: NSPoint(x: 9, y: 8.5), controlPoint1: NSPoint(x: 9.5, y: 8.28), controlPoint2: NSPoint(x: 9.27, y: 8.5))
mainPath.line(to: NSPoint(x: 9, y: 8.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 12, y: 6.5))
mainPath.curve(to: NSPoint(x: 11.5, y: 6), controlPoint1: NSPoint(x: 11.72, y: 6.5), controlPoint2: NSPoint(x: 11.5, y: 6.28))
mainPath.line(to: NSPoint(x: 11.5, y: 4))
mainPath.curve(to: NSPoint(x: 12, y: 3.5), controlPoint1: NSPoint(x: 11.5, y: 3.72), controlPoint2: NSPoint(x: 11.73, y: 3.5))
mainPath.curve(to: NSPoint(x: 12.5, y: 4), controlPoint1: NSPoint(x: 12.28, y: 3.5), controlPoint2: NSPoint(x: 12.5, y: 3.72))
mainPath.line(to: NSPoint(x: 12.5, y: 6))
mainPath.curve(to: NSPoint(x: 12, y: 6.5), controlPoint1: NSPoint(x: 12.5, y: 6.28), controlPoint2: NSPoint(x: 12.27, y: 6.5))
mainPath.line(to: NSPoint(x: 12, y: 6.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 8.5))
mainPath.curve(to: NSPoint(x: 14.5, y: 8), controlPoint1: NSPoint(x: 14.72, y: 8.5), controlPoint2: NSPoint(x: 14.5, y: 8.28))
mainPath.line(to: NSPoint(x: 14.5, y: 6))
mainPath.curve(to: NSPoint(x: 15, y: 5.5), controlPoint1: NSPoint(x: 14.5, y: 5.72), controlPoint2: NSPoint(x: 14.73, y: 5.5))
mainPath.curve(to: NSPoint(x: 15.5, y: 6), controlPoint1: NSPoint(x: 15.28, y: 5.5), controlPoint2: NSPoint(x: 15.5, y: 5.72))
mainPath.line(to: NSPoint(x: 15.5, y: 8))
mainPath.curve(to: NSPoint(x: 15, y: 8.5), controlPoint1: NSPoint(x: 15.5, y: 8.28), controlPoint2: NSPoint(x: 15.27, y: 8.5))
mainPath.line(to: NSPoint(x: 15, y: 8.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 6.5))
mainPath.curve(to: NSPoint(x: 17.5, y: 6), controlPoint1: NSPoint(x: 17.72, y: 6.5), controlPoint2: NSPoint(x: 17.5, y: 6.28))
mainPath.line(to: NSPoint(x: 17.5, y: 4))
mainPath.curve(to: NSPoint(x: 18, y: 3.5), controlPoint1: NSPoint(x: 17.5, y: 3.72), controlPoint2: NSPoint(x: 17.73, y: 3.5))
mainPath.curve(to: NSPoint(x: 18.5, y: 4), controlPoint1: NSPoint(x: 18.28, y: 3.5), controlPoint2: NSPoint(x: 18.5, y: 3.72))
mainPath.line(to: NSPoint(x: 18.5, y: 6))
mainPath.curve(to: NSPoint(x: 18, y: 6.5), controlPoint1: NSPoint(x: 18.5, y: 6.28), controlPoint2: NSPoint(x: 18.27, y: 6.5))
mainPath.line(to: NSPoint(x: 18, y: 6.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 21, y: 8.5))
mainPath.curve(to: NSPoint(x: 20.5, y: 8), controlPoint1: NSPoint(x: 20.72, y: 8.5), controlPoint2: NSPoint(x: 20.5, y: 8.28))
mainPath.line(to: NSPoint(x: 20.5, y: 6))
mainPath.curve(to: NSPoint(x: 21, y: 5.5), controlPoint1: NSPoint(x: 20.5, y: 5.72), controlPoint2: NSPoint(x: 20.73, y: 5.5))
mainPath.curve(to: NSPoint(x: 21.5, y: 6), controlPoint1: NSPoint(x: 21.28, y: 5.5), controlPoint2: NSPoint(x: 21.5, y: 5.72))
mainPath.line(to: NSPoint(x: 21.5, y: 8))
mainPath.curve(to: NSPoint(x: 21, y: 8.5), controlPoint1: NSPoint(x: 21.5, y: 8.28), controlPoint2: NSPoint(x: 21.27, y: 8.5))
mainPath.line(to: NSPoint(x: 21, y: 8.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudRunRain(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 14.9))
mainPath.curve(to: NSPoint(x: 2.5, y: 11), controlPoint1: NSPoint(x: 3.82, y: 14.49), controlPoint2: NSPoint(x: 2.5, y: 12.9))
mainPath.curve(to: NSPoint(x: 6.5, y: 7), controlPoint1: NSPoint(x: 2.5, y: 8.79), controlPoint2: NSPoint(x: 4.3, y: 7))
mainPath.line(to: NSPoint(x: 23.5, y: 7))
mainPath.curve(to: NSPoint(x: 27.5, y: 11), controlPoint1: NSPoint(x: 25.71, y: 7), controlPoint2: NSPoint(x: 27.5, y: 8.8))
mainPath.curve(to: NSPoint(x: 24.46, y: 14.88), controlPoint1: NSPoint(x: 27.5, y: 12.88), controlPoint2: NSPoint(x: 26.2, y: 14.45))
mainPath.line(to: NSPoint(x: 24.46, y: 14.88))
mainPath.curve(to: NSPoint(x: 24.5, y: 15.5), controlPoint1: NSPoint(x: 24.49, y: 15.09), controlPoint2: NSPoint(x: 24.5, y: 15.29))
mainPath.curve(to: NSPoint(x: 20, y: 20), controlPoint1: NSPoint(x: 24.5, y: 17.99), controlPoint2: NSPoint(x: 22.49, y: 20))
mainPath.curve(to: NSPoint(x: 16.85, y: 18.72), controlPoint1: NSPoint(x: 18.77, y: 20), controlPoint2: NSPoint(x: 17.66, y: 19.51))
mainPath.curve(to: NSPoint(x: 11.5, y: 22), controlPoint1: NSPoint(x: 15.86, y: 20.66), controlPoint2: NSPoint(x: 13.84, y: 22))
mainPath.curve(to: NSPoint(x: 5.5, y: 16), controlPoint1: NSPoint(x: 8.19, y: 22), controlPoint2: NSPoint(x: 5.5, y: 19.31))
mainPath.curve(to: NSPoint(x: 5.6, y: 14.9), controlPoint1: NSPoint(x: 5.5, y: 15.62), controlPoint2: NSPoint(x: 5.53, y: 15.26))
mainPath.line(to: NSPoint(x: 5.6, y: 14.9))
mainPath.close()
mainPath.move(to: NSPoint(x: 23.45, y: 19.78))
mainPath.curve(to: NSPoint(x: 23.5, y: 20.5), controlPoint1: NSPoint(x: 23.48, y: 20.02), controlPoint2: NSPoint(x: 23.5, y: 20.26))
mainPath.curve(to: NSPoint(x: 18, y: 26), controlPoint1: NSPoint(x: 23.5, y: 23.54), controlPoint2: NSPoint(x: 21.04, y: 26))
mainPath.curve(to: NSPoint(x: 13.02, y: 22.83), controlPoint1: NSPoint(x: 15.8, y: 26), controlPoint2: NSPoint(x: 13.9, y: 24.71))
mainPath.line(to: NSPoint(x: 13.02, y: 22.83))
mainPath.curve(to: NSPoint(x: 11.5, y: 23), controlPoint1: NSPoint(x: 12.53, y: 22.94), controlPoint2: NSPoint(x: 12.02, y: 23))
mainPath.curve(to: NSPoint(x: 4.5, y: 16), controlPoint1: NSPoint(x: 7.63, y: 23), controlPoint2: NSPoint(x: 4.5, y: 19.87))
mainPath.curve(to: NSPoint(x: 4.51, y: 15.59), controlPoint1: NSPoint(x: 4.5, y: 15.86), controlPoint2: NSPoint(x: 4.5, y: 15.72))
mainPath.curve(to: NSPoint(x: 1.5, y: 11), controlPoint1: NSPoint(x: 2.74, y: 14.82), controlPoint2: NSPoint(x: 1.5, y: 13.05))
mainPath.curve(to: NSPoint(x: 6.5, y: 6), controlPoint1: NSPoint(x: 1.5, y: 8.24), controlPoint2: NSPoint(x: 3.73, y: 6))
mainPath.line(to: NSPoint(x: 23.5, y: 6))
mainPath.curve(to: NSPoint(x: 28.5, y: 11), controlPoint1: NSPoint(x: 26.26, y: 6), controlPoint2: NSPoint(x: 28.5, y: 8.24))
mainPath.curve(to: NSPoint(x: 25.5, y: 15.59), controlPoint1: NSPoint(x: 28.5, y: 13.05), controlPoint2: NSPoint(x: 27.27, y: 14.81))
mainPath.curve(to: NSPoint(x: 23.45, y: 19.78), controlPoint1: NSPoint(x: 25.47, y: 17.28), controlPoint2: NSPoint(x: 24.68, y: 18.79))
mainPath.line(to: NSPoint(x: 23.45, y: 19.78))
mainPath.line(to: NSPoint(x: 23.45, y: 19.78))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.5, y: 20.4))
mainPath.curve(to: NSPoint(x: 22.5, y: 20.5), controlPoint1: NSPoint(x: 22.5, y: 20.43), controlPoint2: NSPoint(x: 22.5, y: 20.47))
mainPath.curve(to: NSPoint(x: 18, y: 25), controlPoint1: NSPoint(x: 22.5, y: 22.99), controlPoint2: NSPoint(x: 20.49, y: 25))
mainPath.curve(to: NSPoint(x: 13.99, y: 22.54), controlPoint1: NSPoint(x: 16.25, y: 25), controlPoint2: NSPoint(x: 14.73, y: 24))
mainPath.curve(to: NSPoint(x: 17.11, y: 20.18), controlPoint1: NSPoint(x: 15.24, y: 22.07), controlPoint2: NSPoint(x: 16.32, y: 21.24))
mainPath.curve(to: NSPoint(x: 20, y: 21), controlPoint1: NSPoint(x: 17.95, y: 20.7), controlPoint2: NSPoint(x: 18.94, y: 21))
mainPath.curve(to: NSPoint(x: 22.5, y: 20.4), controlPoint1: NSPoint(x: 20.9, y: 21), controlPoint2: NSPoint(x: 21.75, y: 20.78))
mainPath.line(to: NSPoint(x: 22.5, y: 20.4))
mainPath.line(to: NSPoint(x: 22.5, y: 20.4))
mainPath.close()
mainPath.move(to: NSPoint(x: 9, y: 5))
mainPath.curve(to: NSPoint(x: 8.5, y: 4.5), controlPoint1: NSPoint(x: 8.72, y: 5), controlPoint2: NSPoint(x: 8.5, y: 4.78))
mainPath.line(to: NSPoint(x: 8.5, y: 2.5))
mainPath.curve(to: NSPoint(x: 9, y: 2), controlPoint1: NSPoint(x: 8.5, y: 2.22), controlPoint2: NSPoint(x: 8.73, y: 2))
mainPath.curve(to: NSPoint(x: 9.5, y: 2.5), controlPoint1: NSPoint(x: 9.28, y: 2), controlPoint2: NSPoint(x: 9.5, y: 2.22))
mainPath.line(to: NSPoint(x: 9.5, y: 4.5))
mainPath.curve(to: NSPoint(x: 9, y: 5), controlPoint1: NSPoint(x: 9.5, y: 4.78), controlPoint2: NSPoint(x: 9.27, y: 5))
mainPath.line(to: NSPoint(x: 9, y: 5))
mainPath.close()
mainPath.move(to: NSPoint(x: 12, y: 3))
mainPath.curve(to: NSPoint(x: 11.5, y: 2.5), controlPoint1: NSPoint(x: 11.72, y: 3), controlPoint2: NSPoint(x: 11.5, y: 2.78))
mainPath.line(to: NSPoint(x: 11.5, y: 0.5))
mainPath.curve(to: NSPoint(x: 12, y: 0), controlPoint1: NSPoint(x: 11.5, y: 0.22), controlPoint2: NSPoint(x: 11.73, y: 0))
mainPath.curve(to: NSPoint(x: 12.5, y: 0.5), controlPoint1: NSPoint(x: 12.28, y: 0), controlPoint2: NSPoint(x: 12.5, y: 0.22))
mainPath.line(to: NSPoint(x: 12.5, y: 2.5))
mainPath.curve(to: NSPoint(x: 12, y: 3), controlPoint1: NSPoint(x: 12.5, y: 2.78), controlPoint2: NSPoint(x: 12.27, y: 3))
mainPath.line(to: NSPoint(x: 12, y: 3))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 5))
mainPath.curve(to: NSPoint(x: 14.5, y: 4.5), controlPoint1: NSPoint(x: 14.72, y: 5), controlPoint2: NSPoint(x: 14.5, y: 4.78))
mainPath.line(to: NSPoint(x: 14.5, y: 2.5))
mainPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 14.5, y: 2.22), controlPoint2: NSPoint(x: 14.73, y: 2))
mainPath.curve(to: NSPoint(x: 15.5, y: 2.5), controlPoint1: NSPoint(x: 15.28, y: 2), controlPoint2: NSPoint(x: 15.5, y: 2.22))
mainPath.line(to: NSPoint(x: 15.5, y: 4.5))
mainPath.curve(to: NSPoint(x: 15, y: 5), controlPoint1: NSPoint(x: 15.5, y: 4.78), controlPoint2: NSPoint(x: 15.27, y: 5))
mainPath.line(to: NSPoint(x: 15, y: 5))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 3))
mainPath.curve(to: NSPoint(x: 17.5, y: 2.5), controlPoint1: NSPoint(x: 17.72, y: 3), controlPoint2: NSPoint(x: 17.5, y: 2.78))
mainPath.line(to: NSPoint(x: 17.5, y: 0.5))
mainPath.curve(to: NSPoint(x: 18, y: 0), controlPoint1: NSPoint(x: 17.5, y: 0.22), controlPoint2: NSPoint(x: 17.73, y: 0))
mainPath.curve(to: NSPoint(x: 18.5, y: 0.5), controlPoint1: NSPoint(x: 18.28, y: 0), controlPoint2: NSPoint(x: 18.5, y: 0.22))
mainPath.line(to: NSPoint(x: 18.5, y: 2.5))
mainPath.curve(to: NSPoint(x: 18, y: 3), controlPoint1: NSPoint(x: 18.5, y: 2.78), controlPoint2: NSPoint(x: 18.27, y: 3))
mainPath.line(to: NSPoint(x: 18, y: 3))
mainPath.close()
mainPath.move(to: NSPoint(x: 21, y: 5))
mainPath.curve(to: NSPoint(x: 20.5, y: 4.5), controlPoint1: NSPoint(x: 20.72, y: 5), controlPoint2: NSPoint(x: 20.5, y: 4.78))
mainPath.line(to: NSPoint(x: 20.5, y: 2.5))
mainPath.curve(to: NSPoint(x: 21, y: 2), controlPoint1: NSPoint(x: 20.5, y: 2.22), controlPoint2: NSPoint(x: 20.73, y: 2))
mainPath.curve(to: NSPoint(x: 21.5, y: 2.5), controlPoint1: NSPoint(x: 21.28, y: 2), controlPoint2: NSPoint(x: 21.5, y: 2.22))
mainPath.line(to: NSPoint(x: 21.5, y: 4.5))
mainPath.curve(to: NSPoint(x: 21, y: 5), controlPoint1: NSPoint(x: 21.5, y: 4.78), controlPoint2: NSPoint(x: 21.27, y: 5))
mainPath.line(to: NSPoint(x: 21, y: 5))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 30))
mainPath.curve(to: NSPoint(x: 17.5, y: 29.5), controlPoint1: NSPoint(x: 17.72, y: 30), controlPoint2: NSPoint(x: 17.5, y: 29.78))
mainPath.line(to: NSPoint(x: 17.5, y: 27.5))
mainPath.curve(to: NSPoint(x: 18, y: 27), controlPoint1: NSPoint(x: 17.5, y: 27.22), controlPoint2: NSPoint(x: 17.73, y: 27))
mainPath.curve(to: NSPoint(x: 18.5, y: 27.5), controlPoint1: NSPoint(x: 18.28, y: 27), controlPoint2: NSPoint(x: 18.5, y: 27.22))
mainPath.line(to: NSPoint(x: 18.5, y: 29.5))
mainPath.curve(to: NSPoint(x: 18, y: 30), controlPoint1: NSPoint(x: 18.5, y: 29.78), controlPoint2: NSPoint(x: 18.27, y: 30))
mainPath.line(to: NSPoint(x: 18, y: 30))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.73, y: 27.21))
mainPath.curve(to: NSPoint(x: 24.03, y: 27.21), controlPoint1: NSPoint(x: 24.54, y: 27.41), controlPoint2: NSPoint(x: 24.23, y: 27.41))
mainPath.line(to: NSPoint(x: 22.61, y: 25.79))
mainPath.curve(to: NSPoint(x: 22.61, y: 25.09), controlPoint1: NSPoint(x: 22.42, y: 25.6), controlPoint2: NSPoint(x: 22.42, y: 25.28))
mainPath.curve(to: NSPoint(x: 23.32, y: 25.09), controlPoint1: NSPoint(x: 22.81, y: 24.89), controlPoint2: NSPoint(x: 23.12, y: 24.89))
mainPath.line(to: NSPoint(x: 24.74, y: 26.51))
mainPath.curve(to: NSPoint(x: 24.73, y: 27.21), controlPoint1: NSPoint(x: 24.93, y: 26.7), controlPoint2: NSPoint(x: 24.92, y: 27.02))
mainPath.line(to: NSPoint(x: 24.73, y: 27.21))
mainPath.close()
mainPath.move(to: NSPoint(x: 27.52, y: 20.48))
mainPath.curve(to: NSPoint(x: 27.03, y: 20.98), controlPoint1: NSPoint(x: 27.52, y: 20.75), controlPoint2: NSPoint(x: 27.31, y: 20.98))
mainPath.line(to: NSPoint(x: 25.02, y: 20.98))
mainPath.curve(to: NSPoint(x: 24.52, y: 20.48), controlPoint1: NSPoint(x: 24.74, y: 20.98), controlPoint2: NSPoint(x: 24.52, y: 20.75))
mainPath.curve(to: NSPoint(x: 25.02, y: 19.98), controlPoint1: NSPoint(x: 24.52, y: 20.2), controlPoint2: NSPoint(x: 24.74, y: 19.98))
mainPath.line(to: NSPoint(x: 27.03, y: 19.98))
mainPath.curve(to: NSPoint(x: 27.52, y: 20.48), controlPoint1: NSPoint(x: 27.3, y: 19.98), controlPoint2: NSPoint(x: 27.52, y: 20.21))
mainPath.line(to: NSPoint(x: 27.52, y: 20.48))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.27, y: 27.21))
mainPath.curve(to: NSPoint(x: 11.26, y: 26.51), controlPoint1: NSPoint(x: 11.07, y: 27.02), controlPoint2: NSPoint(x: 11.07, y: 26.7))
mainPath.line(to: NSPoint(x: 12.68, y: 25.09))
mainPath.curve(to: NSPoint(x: 13.39, y: 25.09), controlPoint1: NSPoint(x: 12.88, y: 24.89), controlPoint2: NSPoint(x: 13.2, y: 24.9))
mainPath.curve(to: NSPoint(x: 13.39, y: 25.79), controlPoint1: NSPoint(x: 13.58, y: 25.29), controlPoint2: NSPoint(x: 13.59, y: 25.6))
mainPath.line(to: NSPoint(x: 11.97, y: 27.21))
mainPath.curve(to: NSPoint(x: 11.27, y: 27.21), controlPoint1: NSPoint(x: 11.78, y: 27.41), controlPoint2: NSPoint(x: 11.46, y: 27.4))
mainPath.line(to: NSPoint(x: 11.27, y: 27.21))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudMoonRain(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 15.4))
mainPath.curve(to: NSPoint(x: 2.5, y: 11.51), controlPoint1: NSPoint(x: 3.82, y: 14.99), controlPoint2: NSPoint(x: 2.5, y: 13.4))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.51), controlPoint1: NSPoint(x: 2.5, y: 9.3), controlPoint2: NSPoint(x: 4.3, y: 7.51))
mainPath.line(to: NSPoint(x: 23.5, y: 7.51))
mainPath.curve(to: NSPoint(x: 27.5, y: 11.51), controlPoint1: NSPoint(x: 25.71, y: 7.51), controlPoint2: NSPoint(x: 27.5, y: 9.3))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.39), controlPoint1: NSPoint(x: 27.5, y: 13.38), controlPoint2: NSPoint(x: 26.2, y: 14.96))
mainPath.line(to: NSPoint(x: 24.46, y: 15.39))
mainPath.curve(to: NSPoint(x: 24.5, y: 16.01), controlPoint1: NSPoint(x: 24.49, y: 15.59), controlPoint2: NSPoint(x: 24.5, y: 15.8))
mainPath.curve(to: NSPoint(x: 20, y: 20.51), controlPoint1: NSPoint(x: 24.5, y: 18.49), controlPoint2: NSPoint(x: 22.49, y: 20.51))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.22), controlPoint1: NSPoint(x: 18.77, y: 20.51), controlPoint2: NSPoint(x: 17.66, y: 20.02))
mainPath.curve(to: NSPoint(x: 11.5, y: 22.51), controlPoint1: NSPoint(x: 15.86, y: 21.17), controlPoint2: NSPoint(x: 13.84, y: 22.51))
mainPath.curve(to: NSPoint(x: 5.5, y: 16.51), controlPoint1: NSPoint(x: 8.19, y: 22.51), controlPoint2: NSPoint(x: 5.5, y: 19.82))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.4), controlPoint1: NSPoint(x: 5.5, y: 16.13), controlPoint2: NSPoint(x: 5.53, y: 15.76))
mainPath.line(to: NSPoint(x: 5.6, y: 15.4))
mainPath.line(to: NSPoint(x: 5.6, y: 15.4))
mainPath.close()
mainPath.move(to: NSPoint(x: 23.77, y: 20.01))
mainPath.curve(to: NSPoint(x: 25.34, y: 22.67), controlPoint1: NSPoint(x: 24.53, y: 20.71), controlPoint2: NSPoint(x: 25.08, y: 21.63))
mainPath.curve(to: NSPoint(x: 25.49, y: 23.76), controlPoint1: NSPoint(x: 25.42, y: 23.02), controlPoint2: NSPoint(x: 25.48, y: 23.39))
mainPath.curve(to: NSPoint(x: 24, y: 23.51), controlPoint1: NSPoint(x: 25.03, y: 23.59), controlPoint2: NSPoint(x: 24.52, y: 23.51))
mainPath.curve(to: NSPoint(x: 19.5, y: 28.01), controlPoint1: NSPoint(x: 21.51, y: 23.51), controlPoint2: NSPoint(x: 19.5, y: 25.52))
mainPath.curve(to: NSPoint(x: 19.75, y: 29.5), controlPoint1: NSPoint(x: 19.5, y: 28.53), controlPoint2: NSPoint(x: 19.59, y: 29.03))
mainPath.curve(to: NSPoint(x: 18.66, y: 29.34), controlPoint1: NSPoint(x: 19.38, y: 29.48), controlPoint2: NSPoint(x: 19.01, y: 29.43))
mainPath.curve(to: NSPoint(x: 14.5, y: 24.01), controlPoint1: NSPoint(x: 16.27, y: 28.74), controlPoint2: NSPoint(x: 14.5, y: 26.58))
mainPath.curve(to: NSPoint(x: 14.64, y: 22.76), controlPoint1: NSPoint(x: 14.5, y: 23.58), controlPoint2: NSPoint(x: 14.55, y: 23.16))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.51), controlPoint1: NSPoint(x: 13.7, y: 23.24), controlPoint2: NSPoint(x: 12.63, y: 23.51))
mainPath.curve(to: NSPoint(x: 4.5, y: 16.51), controlPoint1: NSPoint(x: 7.63, y: 23.51), controlPoint2: NSPoint(x: 4.5, y: 20.37))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.09), controlPoint1: NSPoint(x: 4.5, y: 16.37), controlPoint2: NSPoint(x: 4.5, y: 16.23))
mainPath.curve(to: NSPoint(x: 1.5, y: 11.51), controlPoint1: NSPoint(x: 2.74, y: 15.32), controlPoint2: NSPoint(x: 1.5, y: 13.56))
mainPath.curve(to: NSPoint(x: 6.5, y: 6.51), controlPoint1: NSPoint(x: 1.5, y: 8.74), controlPoint2: NSPoint(x: 3.73, y: 6.51))
mainPath.line(to: NSPoint(x: 23.5, y: 6.51))
mainPath.curve(to: NSPoint(x: 28.5, y: 11.51), controlPoint1: NSPoint(x: 26.26, y: 6.51), controlPoint2: NSPoint(x: 28.5, y: 8.75))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.09), controlPoint1: NSPoint(x: 28.5, y: 13.56), controlPoint2: NSPoint(x: 27.27, y: 15.32))
mainPath.curve(to: NSPoint(x: 23.77, y: 20.01), controlPoint1: NSPoint(x: 25.48, y: 17.63), controlPoint2: NSPoint(x: 24.82, y: 19.02))
mainPath.line(to: NSPoint(x: 23.77, y: 20.01))
mainPath.line(to: NSPoint(x: 23.77, y: 20.01))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.98, y: 20.63))
mainPath.curve(to: NSPoint(x: 24.25, y: 22.51), controlPoint1: NSPoint(x: 23.55, y: 21.13), controlPoint2: NSPoint(x: 23.99, y: 21.78))
mainPath.curve(to: NSPoint(x: 24, y: 22.51), controlPoint1: NSPoint(x: 24.16, y: 22.51), controlPoint2: NSPoint(x: 24.08, y: 22.51))
mainPath.curve(to: NSPoint(x: 18.5, y: 28.01), controlPoint1: NSPoint(x: 20.96, y: 22.51), controlPoint2: NSPoint(x: 18.5, y: 24.97))
mainPath.curve(to: NSPoint(x: 18.51, y: 28.25), controlPoint1: NSPoint(x: 18.5, y: 28.09), controlPoint2: NSPoint(x: 18.5, y: 28.17))
mainPath.curve(to: NSPoint(x: 15.5, y: 24.01), controlPoint1: NSPoint(x: 16.75, y: 27.64), controlPoint2: NSPoint(x: 15.5, y: 25.97))
mainPath.curve(to: NSPoint(x: 16.07, y: 21.8), controlPoint1: NSPoint(x: 15.5, y: 23.21), controlPoint2: NSPoint(x: 15.71, y: 22.46))
mainPath.curve(to: NSPoint(x: 17.11, y: 20.69), controlPoint1: NSPoint(x: 16.46, y: 21.47), controlPoint2: NSPoint(x: 16.81, y: 21.1))
mainPath.curve(to: NSPoint(x: 20, y: 21.51), controlPoint1: NSPoint(x: 17.95, y: 21.21), controlPoint2: NSPoint(x: 18.94, y: 21.51))
mainPath.curve(to: NSPoint(x: 22.98, y: 20.63), controlPoint1: NSPoint(x: 21.1, y: 21.51), controlPoint2: NSPoint(x: 22.12, y: 21.18))
mainPath.line(to: NSPoint(x: 22.98, y: 20.63))
mainPath.line(to: NSPoint(x: 22.98, y: 20.63))
mainPath.close()
mainPath.move(to: NSPoint(x: 9, y: 5.5))
mainPath.curve(to: NSPoint(x: 8.5, y: 5), controlPoint1: NSPoint(x: 8.72, y: 5.5), controlPoint2: NSPoint(x: 8.5, y: 5.28))
mainPath.line(to: NSPoint(x: 8.5, y: 3))
mainPath.curve(to: NSPoint(x: 9, y: 2.5), controlPoint1: NSPoint(x: 8.5, y: 2.72), controlPoint2: NSPoint(x: 8.73, y: 2.5))
mainPath.curve(to: NSPoint(x: 9.5, y: 3), controlPoint1: NSPoint(x: 9.28, y: 2.5), controlPoint2: NSPoint(x: 9.5, y: 2.72))
mainPath.line(to: NSPoint(x: 9.5, y: 5))
mainPath.curve(to: NSPoint(x: 9, y: 5.5), controlPoint1: NSPoint(x: 9.5, y: 5.28), controlPoint2: NSPoint(x: 9.27, y: 5.5))
mainPath.line(to: NSPoint(x: 9, y: 5.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 12, y: 3.5))
mainPath.curve(to: NSPoint(x: 11.5, y: 3), controlPoint1: NSPoint(x: 11.72, y: 3.5), controlPoint2: NSPoint(x: 11.5, y: 3.28))
mainPath.line(to: NSPoint(x: 11.5, y: 1))
mainPath.curve(to: NSPoint(x: 12, y: 0.5), controlPoint1: NSPoint(x: 11.5, y: 0.72), controlPoint2: NSPoint(x: 11.73, y: 0.5))
mainPath.curve(to: NSPoint(x: 12.5, y: 1), controlPoint1: NSPoint(x: 12.28, y: 0.5), controlPoint2: NSPoint(x: 12.5, y: 0.72))
mainPath.line(to: NSPoint(x: 12.5, y: 3))
mainPath.curve(to: NSPoint(x: 12, y: 3.5), controlPoint1: NSPoint(x: 12.5, y: 3.28), controlPoint2: NSPoint(x: 12.27, y: 3.5))
mainPath.line(to: NSPoint(x: 12, y: 3.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 5.5))
mainPath.curve(to: NSPoint(x: 14.5, y: 5), controlPoint1: NSPoint(x: 14.72, y: 5.5), controlPoint2: NSPoint(x: 14.5, y: 5.28))
mainPath.line(to: NSPoint(x: 14.5, y: 3))
mainPath.curve(to: NSPoint(x: 15, y: 2.5), controlPoint1: NSPoint(x: 14.5, y: 2.72), controlPoint2: NSPoint(x: 14.73, y: 2.5))
mainPath.curve(to: NSPoint(x: 15.5, y: 3), controlPoint1: NSPoint(x: 15.28, y: 2.5), controlPoint2: NSPoint(x: 15.5, y: 2.72))
mainPath.line(to: NSPoint(x: 15.5, y: 5))
mainPath.curve(to: NSPoint(x: 15, y: 5.5), controlPoint1: NSPoint(x: 15.5, y: 5.28), controlPoint2: NSPoint(x: 15.27, y: 5.5))
mainPath.line(to: NSPoint(x: 15, y: 5.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 3.5))
mainPath.curve(to: NSPoint(x: 17.5, y: 3), controlPoint1: NSPoint(x: 17.72, y: 3.5), controlPoint2: NSPoint(x: 17.5, y: 3.28))
mainPath.line(to: NSPoint(x: 17.5, y: 1))
mainPath.curve(to: NSPoint(x: 18, y: 0.5), controlPoint1: NSPoint(x: 17.5, y: 0.72), controlPoint2: NSPoint(x: 17.73, y: 0.5))
mainPath.curve(to: NSPoint(x: 18.5, y: 1), controlPoint1: NSPoint(x: 18.28, y: 0.5), controlPoint2: NSPoint(x: 18.5, y: 0.72))
mainPath.line(to: NSPoint(x: 18.5, y: 3))
mainPath.curve(to: NSPoint(x: 18, y: 3.5), controlPoint1: NSPoint(x: 18.5, y: 3.28), controlPoint2: NSPoint(x: 18.27, y: 3.5))
mainPath.line(to: NSPoint(x: 18, y: 3.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 21, y: 5.5))
mainPath.curve(to: NSPoint(x: 20.5, y: 5), controlPoint1: NSPoint(x: 20.72, y: 5.5), controlPoint2: NSPoint(x: 20.5, y: 5.28))
mainPath.line(to: NSPoint(x: 20.5, y: 3))
mainPath.curve(to: NSPoint(x: 21, y: 2.5), controlPoint1: NSPoint(x: 20.5, y: 2.72), controlPoint2: NSPoint(x: 20.73, y: 2.5))
mainPath.curve(to: NSPoint(x: 21.5, y: 3), controlPoint1: NSPoint(x: 21.28, y: 2.5), controlPoint2: NSPoint(x: 21.5, y: 2.72))
mainPath.line(to: NSPoint(x: 21.5, y: 5))
mainPath.curve(to: NSPoint(x: 21, y: 5.5), controlPoint1: NSPoint(x: 21.5, y: 5.28), controlPoint2: NSPoint(x: 21.27, y: 5.5))
mainPath.line(to: NSPoint(x: 21, y: 5.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudSnow(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 18.9))
mainPath.curve(to: NSPoint(x: 2.5, y: 15), controlPoint1: NSPoint(x: 3.82, y: 18.49), controlPoint2: NSPoint(x: 2.5, y: 16.9))
mainPath.curve(to: NSPoint(x: 6.5, y: 11), controlPoint1: NSPoint(x: 2.5, y: 12.79), controlPoint2: NSPoint(x: 4.3, y: 11))
mainPath.line(to: NSPoint(x: 23.5, y: 11))
mainPath.curve(to: NSPoint(x: 27.5, y: 15), controlPoint1: NSPoint(x: 25.71, y: 11), controlPoint2: NSPoint(x: 27.5, y: 12.8))
mainPath.curve(to: NSPoint(x: 24.46, y: 18.88), controlPoint1: NSPoint(x: 27.5, y: 16.88), controlPoint2: NSPoint(x: 26.2, y: 18.45))
mainPath.line(to: NSPoint(x: 24.46, y: 18.88))
mainPath.curve(to: NSPoint(x: 24.5, y: 19.5), controlPoint1: NSPoint(x: 24.49, y: 19.09), controlPoint2: NSPoint(x: 24.5, y: 19.29))
mainPath.curve(to: NSPoint(x: 20, y: 24), controlPoint1: NSPoint(x: 24.5, y: 21.99), controlPoint2: NSPoint(x: 22.49, y: 24))
mainPath.curve(to: NSPoint(x: 16.85, y: 22.72), controlPoint1: NSPoint(x: 18.77, y: 24), controlPoint2: NSPoint(x: 17.66, y: 23.51))
mainPath.curve(to: NSPoint(x: 11.5, y: 26), controlPoint1: NSPoint(x: 15.86, y: 24.66), controlPoint2: NSPoint(x: 13.84, y: 26))
mainPath.curve(to: NSPoint(x: 5.5, y: 20), controlPoint1: NSPoint(x: 8.19, y: 26), controlPoint2: NSPoint(x: 5.5, y: 23.31))
mainPath.curve(to: NSPoint(x: 5.6, y: 18.9), controlPoint1: NSPoint(x: 5.5, y: 19.62), controlPoint2: NSPoint(x: 5.53, y: 19.26))
mainPath.line(to: NSPoint(x: 5.6, y: 18.9))
mainPath.line(to: NSPoint(x: 5.6, y: 18.9))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.5, y: 19.59))
mainPath.curve(to: NSPoint(x: 28.5, y: 15), controlPoint1: NSPoint(x: 27.27, y: 18.81), controlPoint2: NSPoint(x: 28.5, y: 17.05))
mainPath.curve(to: NSPoint(x: 23.5, y: 10), controlPoint1: NSPoint(x: 28.5, y: 12.24), controlPoint2: NSPoint(x: 26.26, y: 10))
mainPath.line(to: NSPoint(x: 6.5, y: 10))
mainPath.curve(to: NSPoint(x: 1.5, y: 15), controlPoint1: NSPoint(x: 3.73, y: 10), controlPoint2: NSPoint(x: 1.5, y: 12.24))
mainPath.curve(to: NSPoint(x: 4.51, y: 19.59), controlPoint1: NSPoint(x: 1.5, y: 17.05), controlPoint2: NSPoint(x: 2.74, y: 18.82))
mainPath.line(to: NSPoint(x: 4.51, y: 19.59))
mainPath.curve(to: NSPoint(x: 4.5, y: 20), controlPoint1: NSPoint(x: 4.5, y: 19.72), controlPoint2: NSPoint(x: 4.5, y: 19.86))
mainPath.curve(to: NSPoint(x: 11.5, y: 27), controlPoint1: NSPoint(x: 4.5, y: 23.87), controlPoint2: NSPoint(x: 7.63, y: 27))
mainPath.curve(to: NSPoint(x: 17.11, y: 24.18), controlPoint1: NSPoint(x: 13.8, y: 27), controlPoint2: NSPoint(x: 15.84, y: 25.89))
mainPath.curve(to: NSPoint(x: 20, y: 25), controlPoint1: NSPoint(x: 17.95, y: 24.7), controlPoint2: NSPoint(x: 18.94, y: 25))
mainPath.curve(to: NSPoint(x: 25.5, y: 19.59), controlPoint1: NSPoint(x: 23.01, y: 25), controlPoint2: NSPoint(x: 25.45, y: 22.58))
mainPath.line(to: NSPoint(x: 25.5, y: 19.59))
mainPath.line(to: NSPoint(x: 25.5, y: 19.59))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.5, y: 8))
mainPath.curve(to: NSPoint(x: 7.5, y: 7), controlPoint1: NSPoint(x: 7.95, y: 8), controlPoint2: NSPoint(x: 7.5, y: 7.56))
mainPath.curve(to: NSPoint(x: 8.5, y: 6), controlPoint1: NSPoint(x: 7.5, y: 6.45), controlPoint2: NSPoint(x: 7.94, y: 6))
mainPath.curve(to: NSPoint(x: 9.5, y: 7), controlPoint1: NSPoint(x: 9.05, y: 6), controlPoint2: NSPoint(x: 9.5, y: 6.44))
mainPath.curve(to: NSPoint(x: 8.5, y: 8), controlPoint1: NSPoint(x: 9.5, y: 7.55), controlPoint2: NSPoint(x: 9.06, y: 8))
mainPath.line(to: NSPoint(x: 8.5, y: 8))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.5, y: 5))
mainPath.curve(to: NSPoint(x: 10.5, y: 4), controlPoint1: NSPoint(x: 10.95, y: 5), controlPoint2: NSPoint(x: 10.5, y: 4.56))
mainPath.curve(to: NSPoint(x: 11.5, y: 3), controlPoint1: NSPoint(x: 10.5, y: 3.45), controlPoint2: NSPoint(x: 10.94, y: 3))
mainPath.curve(to: NSPoint(x: 12.5, y: 4), controlPoint1: NSPoint(x: 12.05, y: 3), controlPoint2: NSPoint(x: 12.5, y: 3.44))
mainPath.curve(to: NSPoint(x: 11.5, y: 5), controlPoint1: NSPoint(x: 12.5, y: 4.55), controlPoint2: NSPoint(x: 12.06, y: 5))
mainPath.line(to: NSPoint(x: 11.5, y: 5))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.5, y: 8))
mainPath.curve(to: NSPoint(x: 14.5, y: 7), controlPoint1: NSPoint(x: 14.95, y: 8), controlPoint2: NSPoint(x: 14.5, y: 7.56))
mainPath.curve(to: NSPoint(x: 15.5, y: 6), controlPoint1: NSPoint(x: 14.5, y: 6.45), controlPoint2: NSPoint(x: 14.94, y: 6))
mainPath.curve(to: NSPoint(x: 16.5, y: 7), controlPoint1: NSPoint(x: 16.05, y: 6), controlPoint2: NSPoint(x: 16.5, y: 6.44))
mainPath.curve(to: NSPoint(x: 15.5, y: 8), controlPoint1: NSPoint(x: 16.5, y: 7.55), controlPoint2: NSPoint(x: 16.06, y: 8))
mainPath.line(to: NSPoint(x: 15.5, y: 8))
mainPath.close()
mainPath.move(to: NSPoint(x: 18.5, y: 5))
mainPath.curve(to: NSPoint(x: 17.5, y: 4), controlPoint1: NSPoint(x: 17.95, y: 5), controlPoint2: NSPoint(x: 17.5, y: 4.56))
mainPath.curve(to: NSPoint(x: 18.5, y: 3), controlPoint1: NSPoint(x: 17.5, y: 3.45), controlPoint2: NSPoint(x: 17.94, y: 3))
mainPath.curve(to: NSPoint(x: 19.5, y: 4), controlPoint1: NSPoint(x: 19.05, y: 3), controlPoint2: NSPoint(x: 19.5, y: 3.44))
mainPath.curve(to: NSPoint(x: 18.5, y: 5), controlPoint1: NSPoint(x: 19.5, y: 4.55), controlPoint2: NSPoint(x: 19.06, y: 5))
mainPath.line(to: NSPoint(x: 18.5, y: 5))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.5, y: 8))
mainPath.curve(to: NSPoint(x: 20.5, y: 7), controlPoint1: NSPoint(x: 20.95, y: 8), controlPoint2: NSPoint(x: 20.5, y: 7.56))
mainPath.curve(to: NSPoint(x: 21.5, y: 6), controlPoint1: NSPoint(x: 20.5, y: 6.45), controlPoint2: NSPoint(x: 20.94, y: 6))
mainPath.curve(to: NSPoint(x: 22.5, y: 7), controlPoint1: NSPoint(x: 22.05, y: 6), controlPoint2: NSPoint(x: 22.5, y: 6.44))
mainPath.curve(to: NSPoint(x: 21.5, y: 8), controlPoint1: NSPoint(x: 22.5, y: 7.55), controlPoint2: NSPoint(x: 22.06, y: 8))
mainPath.line(to: NSPoint(x: 21.5, y: 8))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudSunSnow(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 15.39))
mainPath.curve(to: NSPoint(x: 2.5, y: 11.61), controlPoint1: NSPoint(x: 3.82, y: 14.99), controlPoint2: NSPoint(x: 2.5, y: 13.45))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.74), controlPoint1: NSPoint(x: 2.5, y: 9.48), controlPoint2: NSPoint(x: 4.3, y: 7.74))
mainPath.line(to: NSPoint(x: 23.5, y: 7.74))
mainPath.curve(to: NSPoint(x: 27.5, y: 11.61), controlPoint1: NSPoint(x: 25.71, y: 7.74), controlPoint2: NSPoint(x: 27.5, y: 9.48))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.37), controlPoint1: NSPoint(x: 27.5, y: 13.43), controlPoint2: NSPoint(x: 26.2, y: 14.95))
mainPath.line(to: NSPoint(x: 24.46, y: 15.37))
mainPath.curve(to: NSPoint(x: 24.5, y: 15.97), controlPoint1: NSPoint(x: 24.49, y: 15.57), controlPoint2: NSPoint(x: 24.5, y: 15.77))
mainPath.curve(to: NSPoint(x: 20, y: 20.32), controlPoint1: NSPoint(x: 24.5, y: 18.37), controlPoint2: NSPoint(x: 22.49, y: 20.32))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.08), controlPoint1: NSPoint(x: 18.77, y: 20.32), controlPoint2: NSPoint(x: 17.66, y: 19.85))
mainPath.curve(to: NSPoint(x: 11.5, y: 22.26), controlPoint1: NSPoint(x: 15.86, y: 20.97), controlPoint2: NSPoint(x: 13.84, y: 22.26))
mainPath.curve(to: NSPoint(x: 5.5, y: 16.45), controlPoint1: NSPoint(x: 8.19, y: 22.26), controlPoint2: NSPoint(x: 5.5, y: 19.66))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.39), controlPoint1: NSPoint(x: 5.5, y: 16.09), controlPoint2: NSPoint(x: 5.53, y: 15.73))
mainPath.line(to: NSPoint(x: 5.6, y: 15.39))
mainPath.close()
mainPath.move(to: NSPoint(x: 23.45, y: 20.11))
mainPath.curve(to: NSPoint(x: 23.5, y: 20.81), controlPoint1: NSPoint(x: 23.48, y: 20.34), controlPoint2: NSPoint(x: 23.5, y: 20.57))
mainPath.curve(to: NSPoint(x: 18, y: 26.13), controlPoint1: NSPoint(x: 23.5, y: 23.75), controlPoint2: NSPoint(x: 21.04, y: 26.13))
mainPath.curve(to: NSPoint(x: 13.02, y: 23.07), controlPoint1: NSPoint(x: 15.8, y: 26.13), controlPoint2: NSPoint(x: 13.9, y: 24.88))
mainPath.line(to: NSPoint(x: 13.02, y: 23.07))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.23), controlPoint1: NSPoint(x: 12.53, y: 23.17), controlPoint2: NSPoint(x: 12.02, y: 23.23))
mainPath.curve(to: NSPoint(x: 4.5, y: 16.45), controlPoint1: NSPoint(x: 7.63, y: 23.23), controlPoint2: NSPoint(x: 4.5, y: 20.19))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.05), controlPoint1: NSPoint(x: 4.5, y: 16.32), controlPoint2: NSPoint(x: 4.5, y: 16.19))
mainPath.curve(to: NSPoint(x: 1.5, y: 11.61), controlPoint1: NSPoint(x: 2.74, y: 15.31), controlPoint2: NSPoint(x: 1.5, y: 13.6))
mainPath.curve(to: NSPoint(x: 6.5, y: 6.77), controlPoint1: NSPoint(x: 1.5, y: 8.94), controlPoint2: NSPoint(x: 3.73, y: 6.77))
mainPath.line(to: NSPoint(x: 23.5, y: 6.77))
mainPath.curve(to: NSPoint(x: 28.5, y: 11.61), controlPoint1: NSPoint(x: 26.26, y: 6.77), controlPoint2: NSPoint(x: 28.5, y: 8.95))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.05), controlPoint1: NSPoint(x: 28.5, y: 13.6), controlPoint2: NSPoint(x: 27.27, y: 15.3))
mainPath.curve(to: NSPoint(x: 23.45, y: 20.11), controlPoint1: NSPoint(x: 25.47, y: 17.69), controlPoint2: NSPoint(x: 24.68, y: 19.15))
mainPath.line(to: NSPoint(x: 23.45, y: 20.11))
mainPath.line(to: NSPoint(x: 23.45, y: 20.11))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.5, y: 20.71))
mainPath.curve(to: NSPoint(x: 22.5, y: 20.81), controlPoint1: NSPoint(x: 22.5, y: 20.74), controlPoint2: NSPoint(x: 22.5, y: 20.77))
mainPath.curve(to: NSPoint(x: 18, y: 25.16), controlPoint1: NSPoint(x: 22.5, y: 23.21), controlPoint2: NSPoint(x: 20.49, y: 25.16))
mainPath.curve(to: NSPoint(x: 13.99, y: 22.78), controlPoint1: NSPoint(x: 16.25, y: 25.16), controlPoint2: NSPoint(x: 14.73, y: 24.2))
mainPath.curve(to: NSPoint(x: 17.11, y: 20.5), controlPoint1: NSPoint(x: 15.24, y: 22.32), controlPoint2: NSPoint(x: 16.32, y: 21.52))
mainPath.curve(to: NSPoint(x: 20, y: 21.29), controlPoint1: NSPoint(x: 17.95, y: 21), controlPoint2: NSPoint(x: 18.94, y: 21.29))
mainPath.curve(to: NSPoint(x: 22.5, y: 20.71), controlPoint1: NSPoint(x: 20.9, y: 21.29), controlPoint2: NSPoint(x: 21.75, y: 21.08))
mainPath.line(to: NSPoint(x: 22.5, y: 20.71))
mainPath.line(to: NSPoint(x: 22.5, y: 20.71))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.5, y: 4.84))
mainPath.curve(to: NSPoint(x: 7.5, y: 3.87), controlPoint1: NSPoint(x: 7.95, y: 4.84), controlPoint2: NSPoint(x: 7.5, y: 4.41))
mainPath.curve(to: NSPoint(x: 8.5, y: 2.9), controlPoint1: NSPoint(x: 7.5, y: 3.34), controlPoint2: NSPoint(x: 7.94, y: 2.9))
mainPath.curve(to: NSPoint(x: 9.5, y: 3.87), controlPoint1: NSPoint(x: 9.05, y: 2.9), controlPoint2: NSPoint(x: 9.5, y: 3.33))
mainPath.curve(to: NSPoint(x: 8.5, y: 4.84), controlPoint1: NSPoint(x: 9.5, y: 4.41), controlPoint2: NSPoint(x: 9.06, y: 4.84))
mainPath.line(to: NSPoint(x: 8.5, y: 4.84))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.5, y: 1.94))
mainPath.curve(to: NSPoint(x: 10.5, y: 0.97), controlPoint1: NSPoint(x: 10.95, y: 1.94), controlPoint2: NSPoint(x: 10.5, y: 1.51))
mainPath.curve(to: NSPoint(x: 11.5, y: 0), controlPoint1: NSPoint(x: 10.5, y: 0.43), controlPoint2: NSPoint(x: 10.94, y: 0))
mainPath.curve(to: NSPoint(x: 12.5, y: 0.97), controlPoint1: NSPoint(x: 12.05, y: 0), controlPoint2: NSPoint(x: 12.5, y: 0.43))
mainPath.curve(to: NSPoint(x: 11.5, y: 1.94), controlPoint1: NSPoint(x: 12.5, y: 1.5), controlPoint2: NSPoint(x: 12.06, y: 1.94))
mainPath.line(to: NSPoint(x: 11.5, y: 1.94))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.5, y: 4.84))
mainPath.curve(to: NSPoint(x: 14.5, y: 3.87), controlPoint1: NSPoint(x: 14.95, y: 4.84), controlPoint2: NSPoint(x: 14.5, y: 4.41))
mainPath.curve(to: NSPoint(x: 15.5, y: 2.9), controlPoint1: NSPoint(x: 14.5, y: 3.34), controlPoint2: NSPoint(x: 14.94, y: 2.9))
mainPath.curve(to: NSPoint(x: 16.5, y: 3.87), controlPoint1: NSPoint(x: 16.05, y: 2.9), controlPoint2: NSPoint(x: 16.5, y: 3.33))
mainPath.curve(to: NSPoint(x: 15.5, y: 4.84), controlPoint1: NSPoint(x: 16.5, y: 4.41), controlPoint2: NSPoint(x: 16.06, y: 4.84))
mainPath.line(to: NSPoint(x: 15.5, y: 4.84))
mainPath.close()
mainPath.move(to: NSPoint(x: 18.5, y: 1.94))
mainPath.curve(to: NSPoint(x: 17.5, y: 0.97), controlPoint1: NSPoint(x: 17.95, y: 1.94), controlPoint2: NSPoint(x: 17.5, y: 1.51))
mainPath.curve(to: NSPoint(x: 18.5, y: 0), controlPoint1: NSPoint(x: 17.5, y: 0.43), controlPoint2: NSPoint(x: 17.94, y: 0))
mainPath.curve(to: NSPoint(x: 19.5, y: 0.97), controlPoint1: NSPoint(x: 19.05, y: 0), controlPoint2: NSPoint(x: 19.5, y: 0.43))
mainPath.curve(to: NSPoint(x: 18.5, y: 1.94), controlPoint1: NSPoint(x: 19.5, y: 1.5), controlPoint2: NSPoint(x: 19.06, y: 1.94))
mainPath.line(to: NSPoint(x: 18.5, y: 1.94))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.5, y: 4.84))
mainPath.curve(to: NSPoint(x: 20.5, y: 3.87), controlPoint1: NSPoint(x: 20.95, y: 4.84), controlPoint2: NSPoint(x: 20.5, y: 4.41))
mainPath.curve(to: NSPoint(x: 21.5, y: 2.9), controlPoint1: NSPoint(x: 20.5, y: 3.34), controlPoint2: NSPoint(x: 20.94, y: 2.9))
mainPath.curve(to: NSPoint(x: 22.5, y: 3.87), controlPoint1: NSPoint(x: 22.05, y: 2.9), controlPoint2: NSPoint(x: 22.5, y: 3.33))
mainPath.curve(to: NSPoint(x: 21.5, y: 4.84), controlPoint1: NSPoint(x: 22.5, y: 4.41), controlPoint2: NSPoint(x: 22.06, y: 4.84))
mainPath.line(to: NSPoint(x: 21.5, y: 4.84))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 30))
mainPath.curve(to: NSPoint(x: 17.5, y: 29.52), controlPoint1: NSPoint(x: 17.72, y: 30), controlPoint2: NSPoint(x: 17.5, y: 29.79))
mainPath.line(to: NSPoint(x: 17.5, y: 27.58))
mainPath.curve(to: NSPoint(x: 18, y: 27.1), controlPoint1: NSPoint(x: 17.5, y: 27.31), controlPoint2: NSPoint(x: 17.73, y: 27.1))
mainPath.curve(to: NSPoint(x: 18.5, y: 27.58), controlPoint1: NSPoint(x: 18.28, y: 27.1), controlPoint2: NSPoint(x: 18.5, y: 27.31))
mainPath.line(to: NSPoint(x: 18.5, y: 29.52))
mainPath.curve(to: NSPoint(x: 18, y: 30), controlPoint1: NSPoint(x: 18.5, y: 29.79), controlPoint2: NSPoint(x: 18.27, y: 30))
mainPath.line(to: NSPoint(x: 18, y: 30))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.73, y: 27.3))
mainPath.curve(to: NSPoint(x: 24.03, y: 27.3), controlPoint1: NSPoint(x: 24.54, y: 27.49), controlPoint2: NSPoint(x: 24.23, y: 27.5))
mainPath.line(to: NSPoint(x: 22.61, y: 25.93))
mainPath.curve(to: NSPoint(x: 22.61, y: 25.25), controlPoint1: NSPoint(x: 22.42, y: 25.74), controlPoint2: NSPoint(x: 22.42, y: 25.43))
mainPath.curve(to: NSPoint(x: 23.32, y: 25.24), controlPoint1: NSPoint(x: 22.81, y: 25.06), controlPoint2: NSPoint(x: 23.12, y: 25.05))
mainPath.line(to: NSPoint(x: 24.74, y: 26.62))
mainPath.curve(to: NSPoint(x: 24.73, y: 27.3), controlPoint1: NSPoint(x: 24.93, y: 26.81), controlPoint2: NSPoint(x: 24.92, y: 27.12))
mainPath.line(to: NSPoint(x: 24.73, y: 27.3))
mainPath.close()
mainPath.move(to: NSPoint(x: 27.52, y: 20.79))
mainPath.curve(to: NSPoint(x: 27.03, y: 21.27), controlPoint1: NSPoint(x: 27.52, y: 21.05), controlPoint2: NSPoint(x: 27.31, y: 21.27))
mainPath.line(to: NSPoint(x: 25.02, y: 21.27))
mainPath.curve(to: NSPoint(x: 24.52, y: 20.79), controlPoint1: NSPoint(x: 24.74, y: 21.27), controlPoint2: NSPoint(x: 24.52, y: 21.04))
mainPath.curve(to: NSPoint(x: 25.02, y: 20.3), controlPoint1: NSPoint(x: 24.52, y: 20.52), controlPoint2: NSPoint(x: 24.74, y: 20.3))
mainPath.line(to: NSPoint(x: 27.03, y: 20.3))
mainPath.curve(to: NSPoint(x: 27.52, y: 20.79), controlPoint1: NSPoint(x: 27.3, y: 20.3), controlPoint2: NSPoint(x: 27.52, y: 20.53))
mainPath.line(to: NSPoint(x: 27.52, y: 20.79))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.27, y: 27.3))
mainPath.curve(to: NSPoint(x: 11.26, y: 26.62), controlPoint1: NSPoint(x: 11.07, y: 27.11), controlPoint2: NSPoint(x: 11.07, y: 26.81))
mainPath.line(to: NSPoint(x: 12.68, y: 25.24))
mainPath.curve(to: NSPoint(x: 13.39, y: 25.25), controlPoint1: NSPoint(x: 12.88, y: 25.06), controlPoint2: NSPoint(x: 13.2, y: 25.06))
mainPath.curve(to: NSPoint(x: 13.39, y: 25.93), controlPoint1: NSPoint(x: 13.58, y: 25.44), controlPoint2: NSPoint(x: 13.59, y: 25.74))
mainPath.line(to: NSPoint(x: 11.97, y: 27.3))
mainPath.curve(to: NSPoint(x: 11.27, y: 27.3), controlPoint1: NSPoint(x: 11.78, y: 27.49), controlPoint2: NSPoint(x: 11.46, y: 27.48))
mainPath.line(to: NSPoint(x: 11.27, y: 27.3))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoonSnow(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 15.9))
mainPath.curve(to: NSPoint(x: 2.5, y: 12.01), controlPoint1: NSPoint(x: 3.82, y: 15.49), controlPoint2: NSPoint(x: 2.5, y: 13.9))
mainPath.curve(to: NSPoint(x: 6.5, y: 8.01), controlPoint1: NSPoint(x: 2.5, y: 9.8), controlPoint2: NSPoint(x: 4.3, y: 8.01))
mainPath.line(to: NSPoint(x: 23.5, y: 8.01))
mainPath.curve(to: NSPoint(x: 27.5, y: 12.01), controlPoint1: NSPoint(x: 25.71, y: 8.01), controlPoint2: NSPoint(x: 27.5, y: 9.8))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.89), controlPoint1: NSPoint(x: 27.5, y: 13.88), controlPoint2: NSPoint(x: 26.2, y: 15.46))
mainPath.line(to: NSPoint(x: 24.46, y: 15.89))
mainPath.curve(to: NSPoint(x: 24.5, y: 16.51), controlPoint1: NSPoint(x: 24.49, y: 16.09), controlPoint2: NSPoint(x: 24.5, y: 16.3))
mainPath.curve(to: NSPoint(x: 20, y: 21.01), controlPoint1: NSPoint(x: 24.5, y: 18.99), controlPoint2: NSPoint(x: 22.49, y: 21.01))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.72), controlPoint1: NSPoint(x: 18.77, y: 21.01), controlPoint2: NSPoint(x: 17.66, y: 20.52))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.01), controlPoint1: NSPoint(x: 15.86, y: 21.67), controlPoint2: NSPoint(x: 13.84, y: 23.01))
mainPath.curve(to: NSPoint(x: 5.5, y: 17.01), controlPoint1: NSPoint(x: 8.19, y: 23.01), controlPoint2: NSPoint(x: 5.5, y: 20.32))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.9), controlPoint1: NSPoint(x: 5.5, y: 16.63), controlPoint2: NSPoint(x: 5.53, y: 16.26))
mainPath.line(to: NSPoint(x: 5.6, y: 15.9))
mainPath.close()
mainPath.move(to: NSPoint(x: 23.77, y: 20.51))
mainPath.curve(to: NSPoint(x: 25.34, y: 23.17), controlPoint1: NSPoint(x: 24.53, y: 21.21), controlPoint2: NSPoint(x: 25.08, y: 22.13))
mainPath.curve(to: NSPoint(x: 25.49, y: 24.26), controlPoint1: NSPoint(x: 25.42, y: 23.52), controlPoint2: NSPoint(x: 25.48, y: 23.89))
mainPath.curve(to: NSPoint(x: 24, y: 24.01), controlPoint1: NSPoint(x: 25.03, y: 24.09), controlPoint2: NSPoint(x: 24.52, y: 24.01))
mainPath.curve(to: NSPoint(x: 19.5, y: 28.51), controlPoint1: NSPoint(x: 21.51, y: 24.01), controlPoint2: NSPoint(x: 19.5, y: 26.02))
mainPath.curve(to: NSPoint(x: 19.75, y: 30), controlPoint1: NSPoint(x: 19.5, y: 29.03), controlPoint2: NSPoint(x: 19.59, y: 29.53))
mainPath.curve(to: NSPoint(x: 18.66, y: 29.84), controlPoint1: NSPoint(x: 19.38, y: 29.98), controlPoint2: NSPoint(x: 19.01, y: 29.93))
mainPath.curve(to: NSPoint(x: 14.5, y: 24.51), controlPoint1: NSPoint(x: 16.27, y: 29.24), controlPoint2: NSPoint(x: 14.5, y: 27.08))
mainPath.curve(to: NSPoint(x: 14.64, y: 23.26), controlPoint1: NSPoint(x: 14.5, y: 24.08), controlPoint2: NSPoint(x: 14.55, y: 23.66))
mainPath.curve(to: NSPoint(x: 11.5, y: 24.01), controlPoint1: NSPoint(x: 13.7, y: 23.74), controlPoint2: NSPoint(x: 12.63, y: 24.01))
mainPath.curve(to: NSPoint(x: 4.5, y: 17.01), controlPoint1: NSPoint(x: 7.63, y: 24.01), controlPoint2: NSPoint(x: 4.5, y: 20.87))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.59), controlPoint1: NSPoint(x: 4.5, y: 16.87), controlPoint2: NSPoint(x: 4.5, y: 16.73))
mainPath.curve(to: NSPoint(x: 1.5, y: 12.01), controlPoint1: NSPoint(x: 2.74, y: 15.82), controlPoint2: NSPoint(x: 1.5, y: 14.06))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.01), controlPoint1: NSPoint(x: 1.5, y: 9.24), controlPoint2: NSPoint(x: 3.73, y: 7.01))
mainPath.line(to: NSPoint(x: 23.5, y: 7.01))
mainPath.curve(to: NSPoint(x: 28.5, y: 12.01), controlPoint1: NSPoint(x: 26.26, y: 7.01), controlPoint2: NSPoint(x: 28.5, y: 9.25))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.59), controlPoint1: NSPoint(x: 28.5, y: 14.06), controlPoint2: NSPoint(x: 27.27, y: 15.82))
mainPath.curve(to: NSPoint(x: 23.77, y: 20.51), controlPoint1: NSPoint(x: 25.48, y: 18.13), controlPoint2: NSPoint(x: 24.82, y: 19.52))
mainPath.line(to: NSPoint(x: 23.77, y: 20.51))
mainPath.line(to: NSPoint(x: 23.77, y: 20.51))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.98, y: 21.13))
mainPath.curve(to: NSPoint(x: 24.25, y: 23.01), controlPoint1: NSPoint(x: 23.55, y: 21.63), controlPoint2: NSPoint(x: 23.99, y: 22.28))
mainPath.curve(to: NSPoint(x: 24, y: 23.01), controlPoint1: NSPoint(x: 24.16, y: 23.01), controlPoint2: NSPoint(x: 24.08, y: 23.01))
mainPath.curve(to: NSPoint(x: 18.5, y: 28.51), controlPoint1: NSPoint(x: 20.96, y: 23.01), controlPoint2: NSPoint(x: 18.5, y: 25.47))
mainPath.curve(to: NSPoint(x: 18.51, y: 28.75), controlPoint1: NSPoint(x: 18.5, y: 28.59), controlPoint2: NSPoint(x: 18.5, y: 28.67))
mainPath.curve(to: NSPoint(x: 15.5, y: 24.51), controlPoint1: NSPoint(x: 16.75, y: 28.14), controlPoint2: NSPoint(x: 15.5, y: 26.47))
mainPath.curve(to: NSPoint(x: 16.07, y: 22.3), controlPoint1: NSPoint(x: 15.5, y: 23.71), controlPoint2: NSPoint(x: 15.71, y: 22.96))
mainPath.curve(to: NSPoint(x: 17.11, y: 21.19), controlPoint1: NSPoint(x: 16.46, y: 21.97), controlPoint2: NSPoint(x: 16.81, y: 21.6))
mainPath.curve(to: NSPoint(x: 20, y: 22.01), controlPoint1: NSPoint(x: 17.95, y: 21.71), controlPoint2: NSPoint(x: 18.94, y: 22.01))
mainPath.curve(to: NSPoint(x: 22.98, y: 21.13), controlPoint1: NSPoint(x: 21.1, y: 22.01), controlPoint2: NSPoint(x: 22.12, y: 21.68))
mainPath.line(to: NSPoint(x: 22.98, y: 21.13))
mainPath.line(to: NSPoint(x: 22.98, y: 21.13))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.5, y: 5))
mainPath.curve(to: NSPoint(x: 7.5, y: 4), controlPoint1: NSPoint(x: 7.95, y: 5), controlPoint2: NSPoint(x: 7.5, y: 4.56))
mainPath.curve(to: NSPoint(x: 8.5, y: 3), controlPoint1: NSPoint(x: 7.5, y: 3.45), controlPoint2: NSPoint(x: 7.94, y: 3))
mainPath.curve(to: NSPoint(x: 9.5, y: 4), controlPoint1: NSPoint(x: 9.05, y: 3), controlPoint2: NSPoint(x: 9.5, y: 3.44))
mainPath.curve(to: NSPoint(x: 8.5, y: 5), controlPoint1: NSPoint(x: 9.5, y: 4.55), controlPoint2: NSPoint(x: 9.06, y: 5))
mainPath.line(to: NSPoint(x: 8.5, y: 5))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.5, y: 2))
mainPath.curve(to: NSPoint(x: 10.5, y: 1), controlPoint1: NSPoint(x: 10.95, y: 2), controlPoint2: NSPoint(x: 10.5, y: 1.56))
mainPath.curve(to: NSPoint(x: 11.5, y: 0), controlPoint1: NSPoint(x: 10.5, y: 0.45), controlPoint2: NSPoint(x: 10.94, y: 0))
mainPath.curve(to: NSPoint(x: 12.5, y: 1), controlPoint1: NSPoint(x: 12.05, y: 0), controlPoint2: NSPoint(x: 12.5, y: 0.44))
mainPath.curve(to: NSPoint(x: 11.5, y: 2), controlPoint1: NSPoint(x: 12.5, y: 1.55), controlPoint2: NSPoint(x: 12.06, y: 2))
mainPath.line(to: NSPoint(x: 11.5, y: 2))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.5, y: 5))
mainPath.curve(to: NSPoint(x: 14.5, y: 4), controlPoint1: NSPoint(x: 14.95, y: 5), controlPoint2: NSPoint(x: 14.5, y: 4.56))
mainPath.curve(to: NSPoint(x: 15.5, y: 3), controlPoint1: NSPoint(x: 14.5, y: 3.45), controlPoint2: NSPoint(x: 14.94, y: 3))
mainPath.curve(to: NSPoint(x: 16.5, y: 4), controlPoint1: NSPoint(x: 16.05, y: 3), controlPoint2: NSPoint(x: 16.5, y: 3.44))
mainPath.curve(to: NSPoint(x: 15.5, y: 5), controlPoint1: NSPoint(x: 16.5, y: 4.55), controlPoint2: NSPoint(x: 16.06, y: 5))
mainPath.line(to: NSPoint(x: 15.5, y: 5))
mainPath.close()
mainPath.move(to: NSPoint(x: 18.5, y: 2))
mainPath.curve(to: NSPoint(x: 17.5, y: 1), controlPoint1: NSPoint(x: 17.95, y: 2), controlPoint2: NSPoint(x: 17.5, y: 1.56))
mainPath.curve(to: NSPoint(x: 18.5, y: 0), controlPoint1: NSPoint(x: 17.5, y: 0.45), controlPoint2: NSPoint(x: 17.94, y: 0))
mainPath.curve(to: NSPoint(x: 19.5, y: 1), controlPoint1: NSPoint(x: 19.05, y: 0), controlPoint2: NSPoint(x: 19.5, y: 0.44))
mainPath.curve(to: NSPoint(x: 18.5, y: 2), controlPoint1: NSPoint(x: 19.5, y: 1.55), controlPoint2: NSPoint(x: 19.06, y: 2))
mainPath.line(to: NSPoint(x: 18.5, y: 2))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.5, y: 5))
mainPath.curve(to: NSPoint(x: 20.5, y: 4), controlPoint1: NSPoint(x: 20.95, y: 5), controlPoint2: NSPoint(x: 20.5, y: 4.56))
mainPath.curve(to: NSPoint(x: 21.5, y: 3), controlPoint1: NSPoint(x: 20.5, y: 3.45), controlPoint2: NSPoint(x: 20.94, y: 3))
mainPath.curve(to: NSPoint(x: 22.5, y: 4), controlPoint1: NSPoint(x: 22.05, y: 3), controlPoint2: NSPoint(x: 22.5, y: 3.44))
mainPath.curve(to: NSPoint(x: 21.5, y: 5), controlPoint1: NSPoint(x: 22.5, y: 4.55), controlPoint2: NSPoint(x: 22.06, y: 5))
mainPath.line(to: NSPoint(x: 21.5, y: 5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudLightning(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15.57, y: 13))
mainPath.line(to: NSPoint(x: 18.1, y: 13))
mainPath.line(to: NSPoint(x: 12, y: 6.9))
mainPath.line(to: NSPoint(x: 13.48, y: 11))
mainPath.line(to: NSPoint(x: 10.9, y: 11))
mainPath.line(to: NSPoint(x: 13.2, y: 17))
mainPath.line(to: NSPoint(x: 17.1, y: 17))
mainPath.line(to: NSPoint(x: 15.57, y: 13))
mainPath.line(to: NSPoint(x: 15.57, y: 13))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.5, y: 11))
mainPath.line(to: NSPoint(x: 23.5, y: 11))
mainPath.curve(to: NSPoint(x: 27.5, y: 15), controlPoint1: NSPoint(x: 25.71, y: 11), controlPoint2: NSPoint(x: 27.5, y: 12.8))
mainPath.curve(to: NSPoint(x: 24.46, y: 18.88), controlPoint1: NSPoint(x: 27.5, y: 16.88), controlPoint2: NSPoint(x: 26.2, y: 18.45))
mainPath.line(to: NSPoint(x: 24.46, y: 18.88))
mainPath.curve(to: NSPoint(x: 24.5, y: 19.5), controlPoint1: NSPoint(x: 24.49, y: 19.09), controlPoint2: NSPoint(x: 24.5, y: 19.29))
mainPath.curve(to: NSPoint(x: 20, y: 24), controlPoint1: NSPoint(x: 24.5, y: 21.99), controlPoint2: NSPoint(x: 22.49, y: 24))
mainPath.curve(to: NSPoint(x: 16.85, y: 22.72), controlPoint1: NSPoint(x: 18.77, y: 24), controlPoint2: NSPoint(x: 17.66, y: 23.51))
mainPath.curve(to: NSPoint(x: 11.5, y: 26), controlPoint1: NSPoint(x: 15.86, y: 24.66), controlPoint2: NSPoint(x: 13.84, y: 26))
mainPath.curve(to: NSPoint(x: 5.5, y: 20), controlPoint1: NSPoint(x: 8.19, y: 26), controlPoint2: NSPoint(x: 5.5, y: 23.31))
mainPath.curve(to: NSPoint(x: 5.6, y: 18.9), controlPoint1: NSPoint(x: 5.5, y: 19.62), controlPoint2: NSPoint(x: 5.53, y: 19.26))
mainPath.line(to: NSPoint(x: 5.6, y: 18.9))
mainPath.curve(to: NSPoint(x: 2.5, y: 15), controlPoint1: NSPoint(x: 3.82, y: 18.49), controlPoint2: NSPoint(x: 2.5, y: 16.9))
mainPath.curve(to: NSPoint(x: 6.5, y: 11), controlPoint1: NSPoint(x: 2.5, y: 12.79), controlPoint2: NSPoint(x: 4.3, y: 11))
mainPath.line(to: NSPoint(x: 9.88, y: 11))
mainPath.line(to: NSPoint(x: 9.88, y: 11))
mainPath.line(to: NSPoint(x: 12.5, y: 18))
mainPath.line(to: NSPoint(x: 18.5, y: 18))
mainPath.line(to: NSPoint(x: 17, y: 14))
mainPath.line(to: NSPoint(x: 20.5, y: 14))
mainPath.line(to: NSPoint(x: 17.5, y: 11))
mainPath.line(to: NSPoint(x: 17.5, y: 11))
mainPath.close()
mainPath.move(to: NSPoint(x: 16.5, y: 10))
mainPath.line(to: NSPoint(x: 23.5, y: 10))
mainPath.curve(to: NSPoint(x: 28.5, y: 15), controlPoint1: NSPoint(x: 26.26, y: 10), controlPoint2: NSPoint(x: 28.5, y: 12.24))
mainPath.curve(to: NSPoint(x: 25.5, y: 19.59), controlPoint1: NSPoint(x: 28.5, y: 17.05), controlPoint2: NSPoint(x: 27.27, y: 18.81))
mainPath.line(to: NSPoint(x: 25.5, y: 19.59))
mainPath.curve(to: NSPoint(x: 20, y: 25), controlPoint1: NSPoint(x: 25.45, y: 22.58), controlPoint2: NSPoint(x: 23.01, y: 25))
mainPath.curve(to: NSPoint(x: 17.11, y: 24.18), controlPoint1: NSPoint(x: 18.94, y: 25), controlPoint2: NSPoint(x: 17.95, y: 24.7))
mainPath.curve(to: NSPoint(x: 11.5, y: 27), controlPoint1: NSPoint(x: 15.84, y: 25.89), controlPoint2: NSPoint(x: 13.8, y: 27))
mainPath.curve(to: NSPoint(x: 4.5, y: 20), controlPoint1: NSPoint(x: 7.63, y: 27), controlPoint2: NSPoint(x: 4.5, y: 23.87))
mainPath.curve(to: NSPoint(x: 4.51, y: 19.59), controlPoint1: NSPoint(x: 4.5, y: 19.86), controlPoint2: NSPoint(x: 4.5, y: 19.72))
mainPath.line(to: NSPoint(x: 4.51, y: 19.59))
mainPath.curve(to: NSPoint(x: 1.5, y: 15), controlPoint1: NSPoint(x: 2.74, y: 18.82), controlPoint2: NSPoint(x: 1.5, y: 17.05))
mainPath.curve(to: NSPoint(x: 6.5, y: 10), controlPoint1: NSPoint(x: 1.5, y: 12.24), controlPoint2: NSPoint(x: 3.73, y: 10))
mainPath.line(to: NSPoint(x: 12.05, y: 10))
mainPath.line(to: NSPoint(x: 9.5, y: 3))
mainPath.line(to: NSPoint(x: 16.5, y: 10))
mainPath.line(to: NSPoint(x: 16.5, y: 10))
mainPath.line(to: NSPoint(x: 16.5, y: 10))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudSunLightning(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15.57, y: 9.68))
mainPath.line(to: NSPoint(x: 18.1, y: 9.68))
mainPath.line(to: NSPoint(x: 12, y: 3.77))
mainPath.line(to: NSPoint(x: 13.48, y: 7.74))
mainPath.line(to: NSPoint(x: 10.9, y: 7.74))
mainPath.line(to: NSPoint(x: 13.2, y: 13.55))
mainPath.line(to: NSPoint(x: 17.1, y: 13.55))
mainPath.line(to: NSPoint(x: 15.57, y: 9.68))
mainPath.line(to: NSPoint(x: 15.57, y: 9.68))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.5, y: 7.74))
mainPath.line(to: NSPoint(x: 23.5, y: 7.74))
mainPath.curve(to: NSPoint(x: 27.5, y: 11.61), controlPoint1: NSPoint(x: 25.71, y: 7.74), controlPoint2: NSPoint(x: 27.5, y: 9.48))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.37), controlPoint1: NSPoint(x: 27.5, y: 13.43), controlPoint2: NSPoint(x: 26.2, y: 14.95))
mainPath.line(to: NSPoint(x: 24.46, y: 15.37))
mainPath.curve(to: NSPoint(x: 24.5, y: 15.97), controlPoint1: NSPoint(x: 24.49, y: 15.57), controlPoint2: NSPoint(x: 24.5, y: 15.77))
mainPath.curve(to: NSPoint(x: 20, y: 20.32), controlPoint1: NSPoint(x: 24.5, y: 18.37), controlPoint2: NSPoint(x: 22.49, y: 20.32))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.08), controlPoint1: NSPoint(x: 18.77, y: 20.32), controlPoint2: NSPoint(x: 17.66, y: 19.85))
mainPath.curve(to: NSPoint(x: 11.5, y: 22.26), controlPoint1: NSPoint(x: 15.86, y: 20.97), controlPoint2: NSPoint(x: 13.84, y: 22.26))
mainPath.curve(to: NSPoint(x: 5.5, y: 16.45), controlPoint1: NSPoint(x: 8.19, y: 22.26), controlPoint2: NSPoint(x: 5.5, y: 19.66))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.39), controlPoint1: NSPoint(x: 5.5, y: 16.09), controlPoint2: NSPoint(x: 5.53, y: 15.73))
mainPath.line(to: NSPoint(x: 5.6, y: 15.39))
mainPath.curve(to: NSPoint(x: 2.5, y: 11.61), controlPoint1: NSPoint(x: 3.82, y: 14.99), controlPoint2: NSPoint(x: 2.5, y: 13.45))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.74), controlPoint1: NSPoint(x: 2.5, y: 9.48), controlPoint2: NSPoint(x: 4.3, y: 7.74))
mainPath.line(to: NSPoint(x: 9.88, y: 7.74))
mainPath.line(to: NSPoint(x: 9.88, y: 7.74))
mainPath.line(to: NSPoint(x: 12.5, y: 14.52))
mainPath.line(to: NSPoint(x: 18.5, y: 14.52))
mainPath.line(to: NSPoint(x: 17, y: 10.65))
mainPath.line(to: NSPoint(x: 20.5, y: 10.65))
mainPath.line(to: NSPoint(x: 17.5, y: 7.74))
mainPath.line(to: NSPoint(x: 17.5, y: 7.74))
mainPath.line(to: NSPoint(x: 17.5, y: 7.74))
mainPath.close()
mainPath.move(to: NSPoint(x: 12.05, y: 6.77))
mainPath.line(to: NSPoint(x: 6.5, y: 6.77))
mainPath.curve(to: NSPoint(x: 1.5, y: 11.61), controlPoint1: NSPoint(x: 3.73, y: 6.77), controlPoint2: NSPoint(x: 1.5, y: 8.94))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.05), controlPoint1: NSPoint(x: 1.5, y: 13.6), controlPoint2: NSPoint(x: 2.74, y: 15.31))
mainPath.curve(to: NSPoint(x: 4.5, y: 16.45), controlPoint1: NSPoint(x: 4.5, y: 16.19), controlPoint2: NSPoint(x: 4.5, y: 16.32))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.23), controlPoint1: NSPoint(x: 4.5, y: 20.19), controlPoint2: NSPoint(x: 7.63, y: 23.23))
mainPath.curve(to: NSPoint(x: 13.02, y: 23.07), controlPoint1: NSPoint(x: 12.02, y: 23.23), controlPoint2: NSPoint(x: 12.53, y: 23.17))
mainPath.line(to: NSPoint(x: 13.02, y: 23.07))
mainPath.curve(to: NSPoint(x: 18, y: 26.13), controlPoint1: NSPoint(x: 13.9, y: 24.88), controlPoint2: NSPoint(x: 15.8, y: 26.13))
mainPath.curve(to: NSPoint(x: 23.5, y: 20.81), controlPoint1: NSPoint(x: 21.04, y: 26.13), controlPoint2: NSPoint(x: 23.5, y: 23.75))
mainPath.curve(to: NSPoint(x: 23.45, y: 20.11), controlPoint1: NSPoint(x: 23.5, y: 20.57), controlPoint2: NSPoint(x: 23.48, y: 20.34))
mainPath.line(to: NSPoint(x: 23.45, y: 20.11))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.05), controlPoint1: NSPoint(x: 24.68, y: 19.15), controlPoint2: NSPoint(x: 25.47, y: 17.69))
mainPath.curve(to: NSPoint(x: 28.5, y: 11.61), controlPoint1: NSPoint(x: 27.27, y: 15.3), controlPoint2: NSPoint(x: 28.5, y: 13.6))
mainPath.curve(to: NSPoint(x: 23.5, y: 6.77), controlPoint1: NSPoint(x: 28.5, y: 8.95), controlPoint2: NSPoint(x: 26.26, y: 6.77))
mainPath.line(to: NSPoint(x: 16.5, y: 6.77))
mainPath.line(to: NSPoint(x: 9.5, y: 0))
mainPath.line(to: NSPoint(x: 12.05, y: 6.77))
mainPath.line(to: NSPoint(x: 12.05, y: 6.77))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.5, y: 20.71))
mainPath.curve(to: NSPoint(x: 22.5, y: 20.81), controlPoint1: NSPoint(x: 22.5, y: 20.74), controlPoint2: NSPoint(x: 22.5, y: 20.77))
mainPath.curve(to: NSPoint(x: 18, y: 25.16), controlPoint1: NSPoint(x: 22.5, y: 23.21), controlPoint2: NSPoint(x: 20.49, y: 25.16))
mainPath.curve(to: NSPoint(x: 13.99, y: 22.78), controlPoint1: NSPoint(x: 16.25, y: 25.16), controlPoint2: NSPoint(x: 14.73, y: 24.2))
mainPath.curve(to: NSPoint(x: 17.11, y: 20.5), controlPoint1: NSPoint(x: 15.24, y: 22.32), controlPoint2: NSPoint(x: 16.32, y: 21.52))
mainPath.curve(to: NSPoint(x: 20, y: 21.29), controlPoint1: NSPoint(x: 17.95, y: 21), controlPoint2: NSPoint(x: 18.94, y: 21.29))
mainPath.curve(to: NSPoint(x: 22.5, y: 20.71), controlPoint1: NSPoint(x: 20.9, y: 21.29), controlPoint2: NSPoint(x: 21.75, y: 21.08))
mainPath.line(to: NSPoint(x: 22.5, y: 20.71))
mainPath.line(to: NSPoint(x: 22.5, y: 20.71))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 30))
mainPath.curve(to: NSPoint(x: 17.5, y: 29.52), controlPoint1: NSPoint(x: 17.72, y: 30), controlPoint2: NSPoint(x: 17.5, y: 29.79))
mainPath.line(to: NSPoint(x: 17.5, y: 27.58))
mainPath.curve(to: NSPoint(x: 18, y: 27.1), controlPoint1: NSPoint(x: 17.5, y: 27.31), controlPoint2: NSPoint(x: 17.73, y: 27.1))
mainPath.curve(to: NSPoint(x: 18.5, y: 27.58), controlPoint1: NSPoint(x: 18.28, y: 27.1), controlPoint2: NSPoint(x: 18.5, y: 27.31))
mainPath.line(to: NSPoint(x: 18.5, y: 29.52))
mainPath.curve(to: NSPoint(x: 18, y: 30), controlPoint1: NSPoint(x: 18.5, y: 29.79), controlPoint2: NSPoint(x: 18.27, y: 30))
mainPath.line(to: NSPoint(x: 18, y: 30))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.73, y: 27.3))
mainPath.curve(to: NSPoint(x: 24.03, y: 27.3), controlPoint1: NSPoint(x: 24.54, y: 27.49), controlPoint2: NSPoint(x: 24.23, y: 27.5))
mainPath.line(to: NSPoint(x: 22.61, y: 25.93))
mainPath.curve(to: NSPoint(x: 22.61, y: 25.25), controlPoint1: NSPoint(x: 22.42, y: 25.74), controlPoint2: NSPoint(x: 22.42, y: 25.43))
mainPath.curve(to: NSPoint(x: 23.32, y: 25.24), controlPoint1: NSPoint(x: 22.81, y: 25.06), controlPoint2: NSPoint(x: 23.12, y: 25.05))
mainPath.line(to: NSPoint(x: 24.74, y: 26.62))
mainPath.curve(to: NSPoint(x: 24.73, y: 27.3), controlPoint1: NSPoint(x: 24.93, y: 26.81), controlPoint2: NSPoint(x: 24.92, y: 27.12))
mainPath.line(to: NSPoint(x: 24.73, y: 27.3))
mainPath.close()
mainPath.move(to: NSPoint(x: 27.52, y: 20.79))
mainPath.curve(to: NSPoint(x: 27.03, y: 21.27), controlPoint1: NSPoint(x: 27.52, y: 21.05), controlPoint2: NSPoint(x: 27.31, y: 21.27))
mainPath.line(to: NSPoint(x: 25.02, y: 21.27))
mainPath.curve(to: NSPoint(x: 24.52, y: 20.79), controlPoint1: NSPoint(x: 24.74, y: 21.27), controlPoint2: NSPoint(x: 24.52, y: 21.04))
mainPath.curve(to: NSPoint(x: 25.02, y: 20.3), controlPoint1: NSPoint(x: 24.52, y: 20.52), controlPoint2: NSPoint(x: 24.74, y: 20.3))
mainPath.line(to: NSPoint(x: 27.03, y: 20.3))
mainPath.curve(to: NSPoint(x: 27.52, y: 20.79), controlPoint1: NSPoint(x: 27.3, y: 20.3), controlPoint2: NSPoint(x: 27.52, y: 20.53))
mainPath.line(to: NSPoint(x: 27.52, y: 20.79))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.27, y: 27.3))
mainPath.curve(to: NSPoint(x: 11.26, y: 26.62), controlPoint1: NSPoint(x: 11.07, y: 27.11), controlPoint2: NSPoint(x: 11.07, y: 26.81))
mainPath.line(to: NSPoint(x: 12.68, y: 25.24))
mainPath.curve(to: NSPoint(x: 13.39, y: 25.25), controlPoint1: NSPoint(x: 12.88, y: 25.06), controlPoint2: NSPoint(x: 13.2, y: 25.06))
mainPath.curve(to: NSPoint(x: 13.39, y: 25.93), controlPoint1: NSPoint(x: 13.58, y: 25.44), controlPoint2: NSPoint(x: 13.59, y: 25.74))
mainPath.line(to: NSPoint(x: 11.97, y: 27.3))
mainPath.curve(to: NSPoint(x: 11.27, y: 27.3), controlPoint1: NSPoint(x: 11.78, y: 27.49), controlPoint2: NSPoint(x: 11.46, y: 27.48))
mainPath.line(to: NSPoint(x: 11.27, y: 27.3))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudMoonLightning(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15.57, y: 10))
mainPath.line(to: NSPoint(x: 18.1, y: 10))
mainPath.line(to: NSPoint(x: 12, y: 3.9))
mainPath.line(to: NSPoint(x: 13.48, y: 8))
mainPath.line(to: NSPoint(x: 10.9, y: 8))
mainPath.line(to: NSPoint(x: 13.2, y: 14))
mainPath.line(to: NSPoint(x: 17.1, y: 14))
mainPath.line(to: NSPoint(x: 15.57, y: 10))
mainPath.line(to: NSPoint(x: 15.57, y: 10))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.5, y: 8))
mainPath.line(to: NSPoint(x: 23.5, y: 8))
mainPath.curve(to: NSPoint(x: 27.5, y: 12), controlPoint1: NSPoint(x: 25.71, y: 8), controlPoint2: NSPoint(x: 27.5, y: 9.8))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.88), controlPoint1: NSPoint(x: 27.5, y: 13.88), controlPoint2: NSPoint(x: 26.2, y: 15.45))
mainPath.line(to: NSPoint(x: 24.46, y: 15.88))
mainPath.curve(to: NSPoint(x: 24.5, y: 16.5), controlPoint1: NSPoint(x: 24.49, y: 16.09), controlPoint2: NSPoint(x: 24.5, y: 16.29))
mainPath.curve(to: NSPoint(x: 20, y: 21), controlPoint1: NSPoint(x: 24.5, y: 18.99), controlPoint2: NSPoint(x: 22.49, y: 21))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.72), controlPoint1: NSPoint(x: 18.77, y: 21), controlPoint2: NSPoint(x: 17.66, y: 20.51))
mainPath.curve(to: NSPoint(x: 11.5, y: 23), controlPoint1: NSPoint(x: 15.86, y: 21.66), controlPoint2: NSPoint(x: 13.84, y: 23))
mainPath.curve(to: NSPoint(x: 5.5, y: 17), controlPoint1: NSPoint(x: 8.19, y: 23), controlPoint2: NSPoint(x: 5.5, y: 20.31))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.9), controlPoint1: NSPoint(x: 5.5, y: 16.62), controlPoint2: NSPoint(x: 5.53, y: 16.26))
mainPath.line(to: NSPoint(x: 5.6, y: 15.9))
mainPath.curve(to: NSPoint(x: 2.5, y: 12), controlPoint1: NSPoint(x: 3.82, y: 15.49), controlPoint2: NSPoint(x: 2.5, y: 13.9))
mainPath.curve(to: NSPoint(x: 6.5, y: 8), controlPoint1: NSPoint(x: 2.5, y: 9.79), controlPoint2: NSPoint(x: 4.3, y: 8))
mainPath.line(to: NSPoint(x: 9.88, y: 8))
mainPath.line(to: NSPoint(x: 9.88, y: 8))
mainPath.line(to: NSPoint(x: 12.5, y: 15))
mainPath.line(to: NSPoint(x: 18.5, y: 15))
mainPath.line(to: NSPoint(x: 17, y: 11))
mainPath.line(to: NSPoint(x: 20.5, y: 11))
mainPath.line(to: NSPoint(x: 17.5, y: 8))
mainPath.line(to: NSPoint(x: 17.5, y: 8))
mainPath.line(to: NSPoint(x: 17.5, y: 8))
mainPath.close()
mainPath.move(to: NSPoint(x: 12.05, y: 7))
mainPath.line(to: NSPoint(x: 6.5, y: 7))
mainPath.curve(to: NSPoint(x: 1.5, y: 12), controlPoint1: NSPoint(x: 3.73, y: 7), controlPoint2: NSPoint(x: 1.5, y: 9.24))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.59), controlPoint1: NSPoint(x: 1.5, y: 14.05), controlPoint2: NSPoint(x: 2.74, y: 15.82))
mainPath.curve(to: NSPoint(x: 4.5, y: 17), controlPoint1: NSPoint(x: 4.5, y: 16.72), controlPoint2: NSPoint(x: 4.5, y: 16.86))
mainPath.curve(to: NSPoint(x: 11.5, y: 24), controlPoint1: NSPoint(x: 4.5, y: 20.87), controlPoint2: NSPoint(x: 7.63, y: 24))
mainPath.curve(to: NSPoint(x: 14.64, y: 23.26), controlPoint1: NSPoint(x: 12.63, y: 24), controlPoint2: NSPoint(x: 13.7, y: 23.73))
mainPath.curve(to: NSPoint(x: 14.5, y: 24.5), controlPoint1: NSPoint(x: 14.55, y: 23.66), controlPoint2: NSPoint(x: 14.5, y: 24.07))
mainPath.curve(to: NSPoint(x: 18.66, y: 29.84), controlPoint1: NSPoint(x: 14.5, y: 27.08), controlPoint2: NSPoint(x: 16.27, y: 29.24))
mainPath.curve(to: NSPoint(x: 19.75, y: 29.99), controlPoint1: NSPoint(x: 19.01, y: 29.92), controlPoint2: NSPoint(x: 19.38, y: 29.98))
mainPath.curve(to: NSPoint(x: 19.5, y: 28.5), controlPoint1: NSPoint(x: 19.59, y: 29.53), controlPoint2: NSPoint(x: 19.5, y: 29.02))
mainPath.curve(to: NSPoint(x: 24, y: 24), controlPoint1: NSPoint(x: 19.5, y: 26.01), controlPoint2: NSPoint(x: 21.51, y: 24))
mainPath.curve(to: NSPoint(x: 25.49, y: 24.25), controlPoint1: NSPoint(x: 24.52, y: 24), controlPoint2: NSPoint(x: 25.03, y: 24.09))
mainPath.curve(to: NSPoint(x: 25.34, y: 23.16), controlPoint1: NSPoint(x: 25.48, y: 23.88), controlPoint2: NSPoint(x: 25.42, y: 23.51))
mainPath.curve(to: NSPoint(x: 23.77, y: 20.5), controlPoint1: NSPoint(x: 25.08, y: 22.13), controlPoint2: NSPoint(x: 24.53, y: 21.21))
mainPath.line(to: NSPoint(x: 23.77, y: 20.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.59), controlPoint1: NSPoint(x: 24.82, y: 19.52), controlPoint2: NSPoint(x: 25.48, y: 18.13))
mainPath.curve(to: NSPoint(x: 28.5, y: 12), controlPoint1: NSPoint(x: 27.27, y: 15.81), controlPoint2: NSPoint(x: 28.5, y: 14.05))
mainPath.curve(to: NSPoint(x: 23.5, y: 7), controlPoint1: NSPoint(x: 28.5, y: 9.24), controlPoint2: NSPoint(x: 26.26, y: 7))
mainPath.line(to: NSPoint(x: 16.5, y: 7))
mainPath.line(to: NSPoint(x: 9.5, y: 0))
mainPath.line(to: NSPoint(x: 12.05, y: 7))
mainPath.line(to: NSPoint(x: 12.05, y: 7))
mainPath.line(to: NSPoint(x: 12.05, y: 7))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.98, y: 21.13))
mainPath.curve(to: NSPoint(x: 24.25, y: 23.01), controlPoint1: NSPoint(x: 23.55, y: 21.63), controlPoint2: NSPoint(x: 23.99, y: 22.27))
mainPath.curve(to: NSPoint(x: 24, y: 23), controlPoint1: NSPoint(x: 24.16, y: 23), controlPoint2: NSPoint(x: 24.08, y: 23))
mainPath.curve(to: NSPoint(x: 18.5, y: 28.5), controlPoint1: NSPoint(x: 20.96, y: 23), controlPoint2: NSPoint(x: 18.5, y: 25.46))
mainPath.curve(to: NSPoint(x: 18.51, y: 28.75), controlPoint1: NSPoint(x: 18.5, y: 28.58), controlPoint2: NSPoint(x: 18.5, y: 28.66))
mainPath.curve(to: NSPoint(x: 15.5, y: 24.5), controlPoint1: NSPoint(x: 16.75, y: 28.13), controlPoint2: NSPoint(x: 15.5, y: 26.46))
mainPath.curve(to: NSPoint(x: 16.07, y: 22.3), controlPoint1: NSPoint(x: 15.5, y: 23.7), controlPoint2: NSPoint(x: 15.71, y: 22.95))
mainPath.curve(to: NSPoint(x: 17.11, y: 21.18), controlPoint1: NSPoint(x: 16.46, y: 21.97), controlPoint2: NSPoint(x: 16.81, y: 21.59))
mainPath.curve(to: NSPoint(x: 20, y: 22), controlPoint1: NSPoint(x: 17.95, y: 21.7), controlPoint2: NSPoint(x: 18.94, y: 22))
mainPath.curve(to: NSPoint(x: 22.98, y: 21.13), controlPoint1: NSPoint(x: 21.1, y: 22), controlPoint2: NSPoint(x: 22.12, y: 21.68))
mainPath.line(to: NSPoint(x: 22.98, y: 21.13))
mainPath.line(to: NSPoint(x: 22.98, y: 21.13))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudWind(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
NSGraphicsContext.saveGraphicsState()
context.translateBy(x: 2.5, y: 1)
//// icon-13-cloud-wind
NSGraphicsContext.restoreGraphicsState()
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 22.16))
mainPath.curve(to: NSPoint(x: 2.5, y: 18.39), controlPoint1: NSPoint(x: 3.82, y: 21.76), controlPoint2: NSPoint(x: 2.5, y: 20.22))
mainPath.curve(to: NSPoint(x: 6.5, y: 14.52), controlPoint1: NSPoint(x: 2.5, y: 16.25), controlPoint2: NSPoint(x: 4.3, y: 14.52))
mainPath.line(to: NSPoint(x: 23.5, y: 14.52))
mainPath.curve(to: NSPoint(x: 27.5, y: 18.39), controlPoint1: NSPoint(x: 25.71, y: 14.52), controlPoint2: NSPoint(x: 27.5, y: 16.25))
mainPath.curve(to: NSPoint(x: 24.46, y: 22.15), controlPoint1: NSPoint(x: 27.5, y: 20.2), controlPoint2: NSPoint(x: 26.2, y: 21.73))
mainPath.line(to: NSPoint(x: 24.46, y: 22.15))
mainPath.curve(to: NSPoint(x: 24.5, y: 22.74), controlPoint1: NSPoint(x: 24.49, y: 22.34), controlPoint2: NSPoint(x: 24.5, y: 22.54))
mainPath.curve(to: NSPoint(x: 20, y: 27.1), controlPoint1: NSPoint(x: 24.5, y: 25.15), controlPoint2: NSPoint(x: 22.49, y: 27.1))
mainPath.curve(to: NSPoint(x: 16.85, y: 25.85), controlPoint1: NSPoint(x: 18.77, y: 27.1), controlPoint2: NSPoint(x: 17.66, y: 26.62))
mainPath.curve(to: NSPoint(x: 11.5, y: 29.03), controlPoint1: NSPoint(x: 15.86, y: 27.74), controlPoint2: NSPoint(x: 13.84, y: 29.03))
mainPath.curve(to: NSPoint(x: 5.5, y: 23.23), controlPoint1: NSPoint(x: 8.19, y: 29.03), controlPoint2: NSPoint(x: 5.5, y: 26.43))
mainPath.curve(to: NSPoint(x: 5.6, y: 22.16), controlPoint1: NSPoint(x: 5.5, y: 22.86), controlPoint2: NSPoint(x: 5.53, y: 22.5))
mainPath.line(to: NSPoint(x: 5.6, y: 22.16))
mainPath.line(to: NSPoint(x: 5.6, y: 22.16))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.5, y: 22.82))
mainPath.curve(to: NSPoint(x: 28.5, y: 18.39), controlPoint1: NSPoint(x: 27.27, y: 22.08), controlPoint2: NSPoint(x: 28.5, y: 20.37))
mainPath.curve(to: NSPoint(x: 23.5, y: 13.55), controlPoint1: NSPoint(x: 28.5, y: 15.72), controlPoint2: NSPoint(x: 26.26, y: 13.55))
mainPath.line(to: NSPoint(x: 6.5, y: 13.55))
mainPath.curve(to: NSPoint(x: 1.5, y: 18.39), controlPoint1: NSPoint(x: 3.73, y: 13.55), controlPoint2: NSPoint(x: 1.5, y: 15.71))
mainPath.curve(to: NSPoint(x: 4.51, y: 22.83), controlPoint1: NSPoint(x: 1.5, y: 20.37), controlPoint2: NSPoint(x: 2.74, y: 22.08))
mainPath.line(to: NSPoint(x: 4.51, y: 22.83))
mainPath.curve(to: NSPoint(x: 4.5, y: 23.23), controlPoint1: NSPoint(x: 4.5, y: 22.96), controlPoint2: NSPoint(x: 4.5, y: 23.09))
mainPath.curve(to: NSPoint(x: 11.5, y: 30), controlPoint1: NSPoint(x: 4.5, y: 26.97), controlPoint2: NSPoint(x: 7.63, y: 30))
mainPath.curve(to: NSPoint(x: 17.11, y: 27.27), controlPoint1: NSPoint(x: 13.8, y: 30), controlPoint2: NSPoint(x: 15.84, y: 28.93))
mainPath.curve(to: NSPoint(x: 20, y: 28.06), controlPoint1: NSPoint(x: 17.95, y: 27.78), controlPoint2: NSPoint(x: 18.94, y: 28.06))
mainPath.curve(to: NSPoint(x: 25.5, y: 22.82), controlPoint1: NSPoint(x: 23.01, y: 28.06), controlPoint2: NSPoint(x: 25.45, y: 25.73))
mainPath.line(to: NSPoint(x: 25.5, y: 22.82))
mainPath.line(to: NSPoint(x: 25.5, y: 22.82))
mainPath.close()
mainPath.move(to: NSPoint(x: 28.5, y: 8.71))
mainPath.curve(to: NSPoint(x: 24.5, y: 12.58), controlPoint1: NSPoint(x: 28.5, y: 10.85), controlPoint2: NSPoint(x: 26.7, y: 12.58))
mainPath.curve(to: NSPoint(x: 20.5, y: 8.71), controlPoint1: NSPoint(x: 22.29, y: 12.58), controlPoint2: NSPoint(x: 20.5, y: 10.85))
mainPath.line(to: NSPoint(x: 21.5, y: 8.71))
mainPath.curve(to: NSPoint(x: 24.5, y: 11.61), controlPoint1: NSPoint(x: 21.5, y: 10.31), controlPoint2: NSPoint(x: 22.85, y: 11.61))
mainPath.curve(to: NSPoint(x: 27.5, y: 8.71), controlPoint1: NSPoint(x: 26.16, y: 11.61), controlPoint2: NSPoint(x: 27.5, y: 10.31))
mainPath.curve(to: NSPoint(x: 24.49, y: 5.81), controlPoint1: NSPoint(x: 27.5, y: 7.11), controlPoint2: NSPoint(x: 26.16, y: 5.81))
mainPath.line(to: NSPoint(x: 1.5, y: 5.81))
mainPath.line(to: NSPoint(x: 1.5, y: 4.84))
mainPath.line(to: NSPoint(x: 24.5, y: 4.84))
mainPath.curve(to: NSPoint(x: 28.5, y: 8.71), controlPoint1: NSPoint(x: 26.71, y: 4.84), controlPoint2: NSPoint(x: 28.5, y: 6.58))
mainPath.line(to: NSPoint(x: 28.5, y: 8.71))
mainPath.close()
mainPath.move(to: NSPoint(x: 19.5, y: 9.68))
mainPath.curve(to: NSPoint(x: 16.5, y: 12.58), controlPoint1: NSPoint(x: 19.5, y: 11.28), controlPoint2: NSPoint(x: 18.15, y: 12.58))
mainPath.curve(to: NSPoint(x: 13.5, y: 9.69), controlPoint1: NSPoint(x: 14.84, y: 12.58), controlPoint2: NSPoint(x: 13.5, y: 11.28))
mainPath.line(to: NSPoint(x: 13.5, y: 9.68))
mainPath.line(to: NSPoint(x: 14.5, y: 9.68))
mainPath.curve(to: NSPoint(x: 16.5, y: 11.61), controlPoint1: NSPoint(x: 14.5, y: 10.75), controlPoint2: NSPoint(x: 15.39, y: 11.61))
mainPath.curve(to: NSPoint(x: 18.5, y: 9.68), controlPoint1: NSPoint(x: 17.6, y: 11.61), controlPoint2: NSPoint(x: 18.5, y: 10.75))
mainPath.curve(to: NSPoint(x: 16.49, y: 7.74), controlPoint1: NSPoint(x: 18.5, y: 8.61), controlPoint2: NSPoint(x: 17.6, y: 7.74))
mainPath.line(to: NSPoint(x: 4.5, y: 7.74))
mainPath.line(to: NSPoint(x: 4.5, y: 6.77))
mainPath.line(to: NSPoint(x: 16.5, y: 6.77))
mainPath.curve(to: NSPoint(x: 19.5, y: 9.68), controlPoint1: NSPoint(x: 18.16, y: 6.77), controlPoint2: NSPoint(x: 19.5, y: 8.08))
mainPath.line(to: NSPoint(x: 19.5, y: 9.68))
mainPath.close()
mainPath.move(to: NSPoint(x: 23.5, y: 1.94))
mainPath.curve(to: NSPoint(x: 21.5, y: 0), controlPoint1: NSPoint(x: 23.5, y: 0.87), controlPoint2: NSPoint(x: 22.61, y: 0))
mainPath.line(to: NSPoint(x: 21.5, y: 0))
mainPath.curve(to: NSPoint(x: 19.5, y: 1.93), controlPoint1: NSPoint(x: 20.4, y: 0), controlPoint2: NSPoint(x: 19.5, y: 0.87))
mainPath.line(to: NSPoint(x: 19.5, y: 1.94))
mainPath.line(to: NSPoint(x: 20.5, y: 1.94))
mainPath.curve(to: NSPoint(x: 21.5, y: 0.97), controlPoint1: NSPoint(x: 20.5, y: 1.4), controlPoint2: NSPoint(x: 20.94, y: 0.97))
mainPath.line(to: NSPoint(x: 21.5, y: 0.97))
mainPath.curve(to: NSPoint(x: 22.5, y: 1.94), controlPoint1: NSPoint(x: 22.05, y: 0.97), controlPoint2: NSPoint(x: 22.5, y: 1.4))
mainPath.line(to: NSPoint(x: 22.5, y: 1.94))
mainPath.curve(to: NSPoint(x: 21.49, y: 2.9), controlPoint1: NSPoint(x: 22.5, y: 2.47), controlPoint2: NSPoint(x: 22.05, y: 2.9))
mainPath.line(to: NSPoint(x: 7.5, y: 2.9))
mainPath.line(to: NSPoint(x: 7.5, y: 3.87))
mainPath.line(to: NSPoint(x: 21.51, y: 3.87))
mainPath.curve(to: NSPoint(x: 23.5, y: 1.94), controlPoint1: NSPoint(x: 22.61, y: 3.87), controlPoint2: NSPoint(x: 23.5, y: 3.01))
mainPath.line(to: NSPoint(x: 23.5, y: 1.94))
mainPath.line(to: NSPoint(x: 23.5, y: 1.94))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudRaindrops(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
NSGraphicsContext.saveGraphicsState()
context.translateBy(x: 2.5, y: 3.5)
//// icon-14-cloud-raindrops
NSGraphicsContext.restoreGraphicsState()
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 19.4))
mainPath.curve(to: NSPoint(x: 2.5, y: 15.5), controlPoint1: NSPoint(x: 3.82, y: 18.99), controlPoint2: NSPoint(x: 2.5, y: 17.4))
mainPath.curve(to: NSPoint(x: 6.5, y: 11.5), controlPoint1: NSPoint(x: 2.5, y: 13.29), controlPoint2: NSPoint(x: 4.3, y: 11.5))
mainPath.line(to: NSPoint(x: 23.5, y: 11.5))
mainPath.curve(to: NSPoint(x: 27.5, y: 15.5), controlPoint1: NSPoint(x: 25.71, y: 11.5), controlPoint2: NSPoint(x: 27.5, y: 13.3))
mainPath.curve(to: NSPoint(x: 24.46, y: 19.38), controlPoint1: NSPoint(x: 27.5, y: 17.38), controlPoint2: NSPoint(x: 26.2, y: 18.95))
mainPath.line(to: NSPoint(x: 24.46, y: 19.38))
mainPath.curve(to: NSPoint(x: 24.5, y: 20), controlPoint1: NSPoint(x: 24.49, y: 19.59), controlPoint2: NSPoint(x: 24.5, y: 19.79))
mainPath.curve(to: NSPoint(x: 20, y: 24.5), controlPoint1: NSPoint(x: 24.5, y: 22.49), controlPoint2: NSPoint(x: 22.49, y: 24.5))
mainPath.curve(to: NSPoint(x: 16.85, y: 23.22), controlPoint1: NSPoint(x: 18.77, y: 24.5), controlPoint2: NSPoint(x: 17.66, y: 24.01))
mainPath.curve(to: NSPoint(x: 11.5, y: 26.5), controlPoint1: NSPoint(x: 15.86, y: 25.16), controlPoint2: NSPoint(x: 13.84, y: 26.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 20.5), controlPoint1: NSPoint(x: 8.19, y: 26.5), controlPoint2: NSPoint(x: 5.5, y: 23.81))
mainPath.curve(to: NSPoint(x: 5.6, y: 19.4), controlPoint1: NSPoint(x: 5.5, y: 20.12), controlPoint2: NSPoint(x: 5.53, y: 19.76))
mainPath.line(to: NSPoint(x: 5.6, y: 19.4))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.5, y: 20.09))
mainPath.curve(to: NSPoint(x: 28.5, y: 15.5), controlPoint1: NSPoint(x: 27.27, y: 19.31), controlPoint2: NSPoint(x: 28.5, y: 17.55))
mainPath.curve(to: NSPoint(x: 23.5, y: 10.5), controlPoint1: NSPoint(x: 28.5, y: 12.74), controlPoint2: NSPoint(x: 26.26, y: 10.5))
mainPath.line(to: NSPoint(x: 6.5, y: 10.5))
mainPath.curve(to: NSPoint(x: 1.5, y: 15.5), controlPoint1: NSPoint(x: 3.73, y: 10.5), controlPoint2: NSPoint(x: 1.5, y: 12.74))
mainPath.curve(to: NSPoint(x: 4.51, y: 20.09), controlPoint1: NSPoint(x: 1.5, y: 17.55), controlPoint2: NSPoint(x: 2.74, y: 19.32))
mainPath.line(to: NSPoint(x: 4.51, y: 20.09))
mainPath.curve(to: NSPoint(x: 4.5, y: 20.5), controlPoint1: NSPoint(x: 4.5, y: 20.22), controlPoint2: NSPoint(x: 4.5, y: 20.36))
mainPath.curve(to: NSPoint(x: 11.5, y: 27.5), controlPoint1: NSPoint(x: 4.5, y: 24.37), controlPoint2: NSPoint(x: 7.63, y: 27.5))
mainPath.curve(to: NSPoint(x: 17.11, y: 24.68), controlPoint1: NSPoint(x: 13.8, y: 27.5), controlPoint2: NSPoint(x: 15.84, y: 26.39))
mainPath.curve(to: NSPoint(x: 20, y: 25.5), controlPoint1: NSPoint(x: 17.95, y: 25.2), controlPoint2: NSPoint(x: 18.94, y: 25.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 20.09), controlPoint1: NSPoint(x: 23.01, y: 25.5), controlPoint2: NSPoint(x: 25.45, y: 23.08))
mainPath.line(to: NSPoint(x: 25.5, y: 20.09))
mainPath.line(to: NSPoint(x: 25.5, y: 20.09))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.5, y: 5.64))
mainPath.curve(to: NSPoint(x: 8.01, y: 9.5), controlPoint1: NSPoint(x: 5.5, y: 7.09), controlPoint2: NSPoint(x: 8.01, y: 9.5))
mainPath.curve(to: NSPoint(x: 10.5, y: 5.64), controlPoint1: NSPoint(x: 8.01, y: 9.5), controlPoint2: NSPoint(x: 10.5, y: 7.09))
mainPath.curve(to: NSPoint(x: 8.01, y: 3.5), controlPoint1: NSPoint(x: 10.5, y: 4.61), controlPoint2: NSPoint(x: 9.69, y: 3.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 5.64), controlPoint1: NSPoint(x: 6.33, y: 3.5), controlPoint2: NSPoint(x: 5.5, y: 4.53))
mainPath.line(to: NSPoint(x: 5.5, y: 5.64))
mainPath.close()
mainPath.move(to: NSPoint(x: 6.51, y: 5.7))
mainPath.curve(to: NSPoint(x: 8.01, y: 8.02), controlPoint1: NSPoint(x: 6.51, y: 6.4), controlPoint2: NSPoint(x: 8.01, y: 8.02))
mainPath.curve(to: NSPoint(x: 9.51, y: 5.7), controlPoint1: NSPoint(x: 8.01, y: 8.02), controlPoint2: NSPoint(x: 9.51, y: 6.4))
mainPath.curve(to: NSPoint(x: 8.01, y: 4.5), controlPoint1: NSPoint(x: 9.51, y: 4.95), controlPoint2: NSPoint(x: 8.84, y: 4.5))
mainPath.curve(to: NSPoint(x: 6.51, y: 5.7), controlPoint1: NSPoint(x: 7.18, y: 4.5), controlPoint2: NSPoint(x: 6.51, y: 4.83))
mainPath.line(to: NSPoint(x: 6.51, y: 5.7))
mainPath.close()
mainPath.move(to: NSPoint(x: 12.5, y: 4.64))
mainPath.curve(to: NSPoint(x: 15.01, y: 8.5), controlPoint1: NSPoint(x: 12.5, y: 6.09), controlPoint2: NSPoint(x: 15.01, y: 8.5))
mainPath.curve(to: NSPoint(x: 17.5, y: 4.64), controlPoint1: NSPoint(x: 15.01, y: 8.5), controlPoint2: NSPoint(x: 17.5, y: 6.09))
mainPath.curve(to: NSPoint(x: 15.01, y: 2.5), controlPoint1: NSPoint(x: 17.5, y: 3.61), controlPoint2: NSPoint(x: 16.69, y: 2.5))
mainPath.curve(to: NSPoint(x: 12.5, y: 4.64), controlPoint1: NSPoint(x: 13.33, y: 2.5), controlPoint2: NSPoint(x: 12.5, y: 3.53))
mainPath.line(to: NSPoint(x: 12.5, y: 4.64))
mainPath.close()
mainPath.move(to: NSPoint(x: 13.51, y: 4.7))
mainPath.curve(to: NSPoint(x: 15.01, y: 7.02), controlPoint1: NSPoint(x: 13.51, y: 5.4), controlPoint2: NSPoint(x: 15.01, y: 7.02))
mainPath.curve(to: NSPoint(x: 16.51, y: 4.7), controlPoint1: NSPoint(x: 15.01, y: 7.02), controlPoint2: NSPoint(x: 16.51, y: 5.4))
mainPath.curve(to: NSPoint(x: 15.01, y: 3.5), controlPoint1: NSPoint(x: 16.51, y: 3.95), controlPoint2: NSPoint(x: 15.84, y: 3.5))
mainPath.curve(to: NSPoint(x: 13.51, y: 4.7), controlPoint1: NSPoint(x: 14.18, y: 3.5), controlPoint2: NSPoint(x: 13.51, y: 3.83))
mainPath.line(to: NSPoint(x: 13.51, y: 4.7))
mainPath.close()
mainPath.move(to: NSPoint(x: 19.5, y: 5.64))
mainPath.curve(to: NSPoint(x: 22.01, y: 9.5), controlPoint1: NSPoint(x: 19.5, y: 7.09), controlPoint2: NSPoint(x: 22.01, y: 9.5))
mainPath.curve(to: NSPoint(x: 24.5, y: 5.64), controlPoint1: NSPoint(x: 22.01, y: 9.5), controlPoint2: NSPoint(x: 24.5, y: 7.09))
mainPath.curve(to: NSPoint(x: 22.01, y: 3.5), controlPoint1: NSPoint(x: 24.5, y: 4.61), controlPoint2: NSPoint(x: 23.69, y: 3.5))
mainPath.curve(to: NSPoint(x: 19.5, y: 5.64), controlPoint1: NSPoint(x: 20.33, y: 3.5), controlPoint2: NSPoint(x: 19.5, y: 4.53))
mainPath.line(to: NSPoint(x: 19.5, y: 5.64))
mainPath.close()
mainPath.move(to: NSPoint(x: 20.51, y: 5.7))
mainPath.curve(to: NSPoint(x: 22.01, y: 8.02), controlPoint1: NSPoint(x: 20.51, y: 6.4), controlPoint2: NSPoint(x: 22.01, y: 8.02))
mainPath.curve(to: NSPoint(x: 23.51, y: 5.7), controlPoint1: NSPoint(x: 22.01, y: 8.02), controlPoint2: NSPoint(x: 23.51, y: 6.4))
mainPath.curve(to: NSPoint(x: 22.01, y: 4.5), controlPoint1: NSPoint(x: 23.51, y: 4.95), controlPoint2: NSPoint(x: 22.84, y: 4.5))
mainPath.curve(to: NSPoint(x: 20.51, y: 5.7), controlPoint1: NSPoint(x: 21.18, y: 4.5), controlPoint2: NSPoint(x: 20.51, y: 4.83))
mainPath.line(to: NSPoint(x: 20.51, y: 5.7))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudSunRaindrops(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.95, y: 15.84))
mainPath.curve(to: NSPoint(x: 2.96, y: 12.19), controlPoint1: NSPoint(x: 4.24, y: 15.46), controlPoint2: NSPoint(x: 2.96, y: 13.96))
mainPath.curve(to: NSPoint(x: 6.82, y: 8.44), controlPoint1: NSPoint(x: 2.96, y: 10.12), controlPoint2: NSPoint(x: 4.69, y: 8.44))
mainPath.line(to: NSPoint(x: 23.18, y: 8.44))
mainPath.curve(to: NSPoint(x: 27.04, y: 12.19), controlPoint1: NSPoint(x: 25.31, y: 8.44), controlPoint2: NSPoint(x: 27.04, y: 10.12))
mainPath.curve(to: NSPoint(x: 24.11, y: 15.83), controlPoint1: NSPoint(x: 27.04, y: 13.95), controlPoint2: NSPoint(x: 25.79, y: 15.42))
mainPath.line(to: NSPoint(x: 24.11, y: 15.83))
mainPath.curve(to: NSPoint(x: 24.15, y: 16.41), controlPoint1: NSPoint(x: 24.13, y: 16.02), controlPoint2: NSPoint(x: 24.15, y: 16.21))
mainPath.curve(to: NSPoint(x: 19.81, y: 20.62), controlPoint1: NSPoint(x: 24.15, y: 18.74), controlPoint2: NSPoint(x: 22.21, y: 20.62))
mainPath.curve(to: NSPoint(x: 16.78, y: 19.42), controlPoint1: NSPoint(x: 18.63, y: 20.62), controlPoint2: NSPoint(x: 17.56, y: 20.17))
mainPath.curve(to: NSPoint(x: 11.63, y: 22.5), controlPoint1: NSPoint(x: 15.83, y: 21.25), controlPoint2: NSPoint(x: 13.88, y: 22.5))
mainPath.curve(to: NSPoint(x: 5.85, y: 16.88), controlPoint1: NSPoint(x: 8.44, y: 22.5), controlPoint2: NSPoint(x: 5.85, y: 19.98))
mainPath.curve(to: NSPoint(x: 5.95, y: 15.84), controlPoint1: NSPoint(x: 5.85, y: 16.52), controlPoint2: NSPoint(x: 5.89, y: 16.18))
mainPath.line(to: NSPoint(x: 5.95, y: 15.84))
mainPath.close()
mainPath.move(to: NSPoint(x: 23.14, y: 20.42))
mainPath.curve(to: NSPoint(x: 23.19, y: 21.09), controlPoint1: NSPoint(x: 23.17, y: 20.64), controlPoint2: NSPoint(x: 23.19, y: 20.87))
mainPath.curve(to: NSPoint(x: 17.89, y: 26.25), controlPoint1: NSPoint(x: 23.19, y: 23.94), controlPoint2: NSPoint(x: 20.81, y: 26.25))
mainPath.curve(to: NSPoint(x: 13.09, y: 23.28), controlPoint1: NSPoint(x: 15.77, y: 26.25), controlPoint2: NSPoint(x: 13.94, y: 25.04))
mainPath.line(to: NSPoint(x: 13.09, y: 23.28))
mainPath.curve(to: NSPoint(x: 11.63, y: 23.44), controlPoint1: NSPoint(x: 12.62, y: 23.38), controlPoint2: NSPoint(x: 12.13, y: 23.44))
mainPath.curve(to: NSPoint(x: 4.89, y: 16.88), controlPoint1: NSPoint(x: 7.91, y: 23.44), controlPoint2: NSPoint(x: 4.89, y: 20.5))
mainPath.curve(to: NSPoint(x: 4.9, y: 16.49), controlPoint1: NSPoint(x: 4.89, y: 16.75), controlPoint2: NSPoint(x: 4.89, y: 16.62))
mainPath.curve(to: NSPoint(x: 2, y: 12.19), controlPoint1: NSPoint(x: 3.19, y: 15.77), controlPoint2: NSPoint(x: 2, y: 14.11))
mainPath.curve(to: NSPoint(x: 6.81, y: 7.5), controlPoint1: NSPoint(x: 2, y: 9.6), controlPoint2: NSPoint(x: 4.15, y: 7.5))
mainPath.line(to: NSPoint(x: 23.19, y: 7.5))
mainPath.curve(to: NSPoint(x: 28, y: 12.19), controlPoint1: NSPoint(x: 25.84, y: 7.5), controlPoint2: NSPoint(x: 28, y: 9.6))
mainPath.curve(to: NSPoint(x: 25.11, y: 16.49), controlPoint1: NSPoint(x: 28, y: 14.11), controlPoint2: NSPoint(x: 26.81, y: 15.76))
mainPath.curve(to: NSPoint(x: 23.14, y: 20.42), controlPoint1: NSPoint(x: 25.09, y: 18.08), controlPoint2: NSPoint(x: 24.32, y: 19.49))
mainPath.line(to: NSPoint(x: 23.14, y: 20.42))
mainPath.line(to: NSPoint(x: 23.14, y: 20.42))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.22, y: 21))
mainPath.curve(to: NSPoint(x: 22.22, y: 21.09), controlPoint1: NSPoint(x: 22.22, y: 21.03), controlPoint2: NSPoint(x: 22.22, y: 21.06))
mainPath.curve(to: NSPoint(x: 17.89, y: 25.31), controlPoint1: NSPoint(x: 22.22, y: 23.42), controlPoint2: NSPoint(x: 20.28, y: 25.31))
mainPath.curve(to: NSPoint(x: 14.03, y: 23.01), controlPoint1: NSPoint(x: 16.2, y: 25.31), controlPoint2: NSPoint(x: 14.74, y: 24.38))
mainPath.curve(to: NSPoint(x: 17.04, y: 20.8), controlPoint1: NSPoint(x: 15.23, y: 22.56), controlPoint2: NSPoint(x: 16.28, y: 21.79))
mainPath.curve(to: NSPoint(x: 19.81, y: 21.56), controlPoint1: NSPoint(x: 17.84, y: 21.28), controlPoint2: NSPoint(x: 18.8, y: 21.56))
mainPath.curve(to: NSPoint(x: 22.22, y: 21), controlPoint1: NSPoint(x: 20.68, y: 21.56), controlPoint2: NSPoint(x: 21.5, y: 21.36))
mainPath.line(to: NSPoint(x: 22.22, y: 21))
mainPath.line(to: NSPoint(x: 22.22, y: 21))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.85, y: 2.95))
mainPath.curve(to: NSPoint(x: 8.27, y: 6.56), controlPoint1: NSPoint(x: 5.85, y: 4.3), controlPoint2: NSPoint(x: 8.27, y: 6.56))
mainPath.curve(to: NSPoint(x: 10.67, y: 2.95), controlPoint1: NSPoint(x: 8.27, y: 6.56), controlPoint2: NSPoint(x: 10.67, y: 4.3))
mainPath.curve(to: NSPoint(x: 8.27, y: 0.94), controlPoint1: NSPoint(x: 10.67, y: 1.98), controlPoint2: NSPoint(x: 9.88, y: 0.94))
mainPath.curve(to: NSPoint(x: 5.85, y: 2.95), controlPoint1: NSPoint(x: 6.65, y: 0.94), controlPoint2: NSPoint(x: 5.85, y: 1.9))
mainPath.line(to: NSPoint(x: 5.85, y: 2.95))
mainPath.close()
mainPath.move(to: NSPoint(x: 6.82, y: 3))
mainPath.curve(to: NSPoint(x: 8.27, y: 5.18), controlPoint1: NSPoint(x: 6.82, y: 3.66), controlPoint2: NSPoint(x: 8.27, y: 5.18))
mainPath.curve(to: NSPoint(x: 9.72, y: 3), controlPoint1: NSPoint(x: 8.27, y: 5.18), controlPoint2: NSPoint(x: 9.72, y: 3.66))
mainPath.curve(to: NSPoint(x: 8.27, y: 1.88), controlPoint1: NSPoint(x: 9.72, y: 2.29), controlPoint2: NSPoint(x: 9.07, y: 1.88))
mainPath.curve(to: NSPoint(x: 6.82, y: 3), controlPoint1: NSPoint(x: 7.47, y: 1.87), controlPoint2: NSPoint(x: 6.82, y: 2.18))
mainPath.line(to: NSPoint(x: 6.82, y: 3))
mainPath.close()
mainPath.move(to: NSPoint(x: 12.59, y: 2.01))
mainPath.curve(to: NSPoint(x: 15.01, y: 5.62), controlPoint1: NSPoint(x: 12.59, y: 3.36), controlPoint2: NSPoint(x: 15.01, y: 5.62))
mainPath.curve(to: NSPoint(x: 17.41, y: 2.01), controlPoint1: NSPoint(x: 15.01, y: 5.62), controlPoint2: NSPoint(x: 17.41, y: 3.36))
mainPath.curve(to: NSPoint(x: 15.01, y: 0), controlPoint1: NSPoint(x: 17.41, y: 1.04), controlPoint2: NSPoint(x: 16.62, y: 0))
mainPath.curve(to: NSPoint(x: 12.59, y: 2.01), controlPoint1: NSPoint(x: 13.4, y: -0), controlPoint2: NSPoint(x: 12.59, y: 0.96))
mainPath.line(to: NSPoint(x: 12.59, y: 2.01))
mainPath.close()
mainPath.move(to: NSPoint(x: 13.56, y: 2.06))
mainPath.curve(to: NSPoint(x: 15.01, y: 4.24), controlPoint1: NSPoint(x: 13.56, y: 2.72), controlPoint2: NSPoint(x: 15.01, y: 4.24))
mainPath.curve(to: NSPoint(x: 16.46, y: 2.06), controlPoint1: NSPoint(x: 15.01, y: 4.24), controlPoint2: NSPoint(x: 16.46, y: 2.72))
mainPath.curve(to: NSPoint(x: 15.01, y: 0.94), controlPoint1: NSPoint(x: 16.46, y: 1.36), controlPoint2: NSPoint(x: 15.81, y: 0.94))
mainPath.curve(to: NSPoint(x: 13.56, y: 2.06), controlPoint1: NSPoint(x: 14.21, y: 0.94), controlPoint2: NSPoint(x: 13.56, y: 1.24))
mainPath.line(to: NSPoint(x: 13.56, y: 2.06))
mainPath.close()
mainPath.move(to: NSPoint(x: 19.33, y: 2.95))
mainPath.curve(to: NSPoint(x: 21.75, y: 6.56), controlPoint1: NSPoint(x: 19.33, y: 4.3), controlPoint2: NSPoint(x: 21.75, y: 6.56))
mainPath.curve(to: NSPoint(x: 24.15, y: 2.95), controlPoint1: NSPoint(x: 21.75, y: 6.56), controlPoint2: NSPoint(x: 24.15, y: 4.3))
mainPath.curve(to: NSPoint(x: 21.75, y: 0.94), controlPoint1: NSPoint(x: 24.15, y: 1.98), controlPoint2: NSPoint(x: 23.37, y: 0.94))
mainPath.curve(to: NSPoint(x: 19.33, y: 2.95), controlPoint1: NSPoint(x: 20.14, y: 0.94), controlPoint2: NSPoint(x: 19.33, y: 1.9))
mainPath.line(to: NSPoint(x: 19.33, y: 2.95))
mainPath.close()
mainPath.move(to: NSPoint(x: 20.31, y: 3))
mainPath.curve(to: NSPoint(x: 21.75, y: 5.18), controlPoint1: NSPoint(x: 20.31, y: 3.66), controlPoint2: NSPoint(x: 21.75, y: 5.18))
mainPath.curve(to: NSPoint(x: 23.2, y: 3), controlPoint1: NSPoint(x: 21.75, y: 5.18), controlPoint2: NSPoint(x: 23.2, y: 3.66))
mainPath.curve(to: NSPoint(x: 21.75, y: 1.88), controlPoint1: NSPoint(x: 23.2, y: 2.29), controlPoint2: NSPoint(x: 22.55, y: 1.88))
mainPath.curve(to: NSPoint(x: 20.31, y: 3), controlPoint1: NSPoint(x: 20.95, y: 1.87), controlPoint2: NSPoint(x: 20.31, y: 2.18))
mainPath.line(to: NSPoint(x: 20.31, y: 3))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.89, y: 30))
mainPath.curve(to: NSPoint(x: 17.41, y: 29.54), controlPoint1: NSPoint(x: 17.62, y: 30), controlPoint2: NSPoint(x: 17.41, y: 29.8))
mainPath.line(to: NSPoint(x: 17.41, y: 27.65))
mainPath.curve(to: NSPoint(x: 17.89, y: 27.19), controlPoint1: NSPoint(x: 17.41, y: 27.4), controlPoint2: NSPoint(x: 17.63, y: 27.19))
mainPath.curve(to: NSPoint(x: 18.37, y: 27.65), controlPoint1: NSPoint(x: 18.15, y: 27.19), controlPoint2: NSPoint(x: 18.37, y: 27.39))
mainPath.line(to: NSPoint(x: 18.37, y: 29.54))
mainPath.curve(to: NSPoint(x: 17.89, y: 30), controlPoint1: NSPoint(x: 18.37, y: 29.79), controlPoint2: NSPoint(x: 18.15, y: 30))
mainPath.line(to: NSPoint(x: 17.89, y: 30))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.37, y: 27.39))
mainPath.curve(to: NSPoint(x: 23.69, y: 27.39), controlPoint1: NSPoint(x: 24.18, y: 27.57), controlPoint2: NSPoint(x: 23.89, y: 27.57))
mainPath.line(to: NSPoint(x: 22.33, y: 26.06))
mainPath.curve(to: NSPoint(x: 22.33, y: 25.4), controlPoint1: NSPoint(x: 22.14, y: 25.88), controlPoint2: NSPoint(x: 22.15, y: 25.57))
mainPath.curve(to: NSPoint(x: 23.01, y: 25.39), controlPoint1: NSPoint(x: 22.52, y: 25.21), controlPoint2: NSPoint(x: 22.82, y: 25.21))
mainPath.line(to: NSPoint(x: 24.38, y: 26.73))
mainPath.curve(to: NSPoint(x: 24.37, y: 27.39), controlPoint1: NSPoint(x: 24.56, y: 26.91), controlPoint2: NSPoint(x: 24.56, y: 27.21))
mainPath.line(to: NSPoint(x: 24.37, y: 27.39))
mainPath.close()
mainPath.move(to: NSPoint(x: 27.06, y: 21.07))
mainPath.curve(to: NSPoint(x: 26.58, y: 21.54), controlPoint1: NSPoint(x: 27.06, y: 21.33), controlPoint2: NSPoint(x: 26.85, y: 21.54))
mainPath.line(to: NSPoint(x: 24.65, y: 21.54))
mainPath.curve(to: NSPoint(x: 24.17, y: 21.07), controlPoint1: NSPoint(x: 24.38, y: 21.54), controlPoint2: NSPoint(x: 24.17, y: 21.32))
mainPath.curve(to: NSPoint(x: 24.65, y: 20.6), controlPoint1: NSPoint(x: 24.17, y: 20.81), controlPoint2: NSPoint(x: 24.38, y: 20.6))
mainPath.line(to: NSPoint(x: 26.58, y: 20.6))
mainPath.curve(to: NSPoint(x: 27.06, y: 21.07), controlPoint1: NSPoint(x: 26.84, y: 20.6), controlPoint2: NSPoint(x: 27.06, y: 20.82))
mainPath.line(to: NSPoint(x: 27.06, y: 21.07))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.41, y: 27.39))
mainPath.curve(to: NSPoint(x: 11.4, y: 26.73), controlPoint1: NSPoint(x: 11.22, y: 27.2), controlPoint2: NSPoint(x: 11.21, y: 26.91))
mainPath.line(to: NSPoint(x: 12.77, y: 25.39))
mainPath.curve(to: NSPoint(x: 13.45, y: 25.4), controlPoint1: NSPoint(x: 12.96, y: 25.21), controlPoint2: NSPoint(x: 13.27, y: 25.22))
mainPath.curve(to: NSPoint(x: 13.45, y: 26.06), controlPoint1: NSPoint(x: 13.64, y: 25.58), controlPoint2: NSPoint(x: 13.64, y: 25.87))
mainPath.line(to: NSPoint(x: 12.08, y: 27.39))
mainPath.curve(to: NSPoint(x: 11.41, y: 27.39), controlPoint1: NSPoint(x: 11.9, y: 27.57), controlPoint2: NSPoint(x: 11.59, y: 27.56))
mainPath.line(to: NSPoint(x: 11.41, y: 27.39))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudMoonRaindrops(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
NSGraphicsContext.saveGraphicsState()
context.translateBy(x: 2.5, y: 1)
//// icon-16-cloud-moon-raindrops
NSGraphicsContext.restoreGraphicsState()
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 16.35))
mainPath.curve(to: NSPoint(x: 2.5, y: 12.58), controlPoint1: NSPoint(x: 3.82, y: 15.96), controlPoint2: NSPoint(x: 2.5, y: 14.41))
mainPath.curve(to: NSPoint(x: 6.5, y: 8.71), controlPoint1: NSPoint(x: 2.5, y: 10.44), controlPoint2: NSPoint(x: 4.3, y: 8.71))
mainPath.line(to: NSPoint(x: 23.5, y: 8.71))
mainPath.curve(to: NSPoint(x: 27.5, y: 12.58), controlPoint1: NSPoint(x: 25.71, y: 8.71), controlPoint2: NSPoint(x: 27.5, y: 10.45))
mainPath.curve(to: NSPoint(x: 24.46, y: 16.34), controlPoint1: NSPoint(x: 27.5, y: 14.4), controlPoint2: NSPoint(x: 26.2, y: 15.92))
mainPath.line(to: NSPoint(x: 24.46, y: 16.34))
mainPath.curve(to: NSPoint(x: 24.5, y: 16.94), controlPoint1: NSPoint(x: 24.49, y: 16.53), controlPoint2: NSPoint(x: 24.5, y: 16.73))
mainPath.curve(to: NSPoint(x: 20, y: 21.29), controlPoint1: NSPoint(x: 24.5, y: 19.34), controlPoint2: NSPoint(x: 22.49, y: 21.29))
mainPath.curve(to: NSPoint(x: 16.85, y: 20.05), controlPoint1: NSPoint(x: 18.77, y: 21.29), controlPoint2: NSPoint(x: 17.66, y: 20.82))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.23), controlPoint1: NSPoint(x: 15.86, y: 21.93), controlPoint2: NSPoint(x: 13.84, y: 23.23))
mainPath.curve(to: NSPoint(x: 5.5, y: 17.42), controlPoint1: NSPoint(x: 8.19, y: 23.23), controlPoint2: NSPoint(x: 5.5, y: 20.63))
mainPath.curve(to: NSPoint(x: 5.6, y: 16.35), controlPoint1: NSPoint(x: 5.5, y: 17.05), controlPoint2: NSPoint(x: 5.53, y: 16.7))
mainPath.line(to: NSPoint(x: 5.6, y: 16.35))
mainPath.close()
mainPath.move(to: NSPoint(x: 23.77, y: 20.81))
mainPath.curve(to: NSPoint(x: 25.34, y: 23.38), controlPoint1: NSPoint(x: 24.53, y: 21.49), controlPoint2: NSPoint(x: 25.08, y: 22.38))
mainPath.curve(to: NSPoint(x: 25.49, y: 24.44), controlPoint1: NSPoint(x: 25.42, y: 23.72), controlPoint2: NSPoint(x: 25.48, y: 24.08))
mainPath.curve(to: NSPoint(x: 24, y: 24.19), controlPoint1: NSPoint(x: 25.03, y: 24.28), controlPoint2: NSPoint(x: 24.52, y: 24.19))
mainPath.curve(to: NSPoint(x: 19.5, y: 28.55), controlPoint1: NSPoint(x: 21.51, y: 24.19), controlPoint2: NSPoint(x: 19.5, y: 26.14))
mainPath.curve(to: NSPoint(x: 19.75, y: 29.99), controlPoint1: NSPoint(x: 19.5, y: 29.06), controlPoint2: NSPoint(x: 19.59, y: 29.54))
mainPath.curve(to: NSPoint(x: 18.66, y: 29.84), controlPoint1: NSPoint(x: 19.38, y: 29.98), controlPoint2: NSPoint(x: 19.01, y: 29.93))
mainPath.curve(to: NSPoint(x: 14.5, y: 24.68), controlPoint1: NSPoint(x: 16.27, y: 29.26), controlPoint2: NSPoint(x: 14.5, y: 27.17))
mainPath.curve(to: NSPoint(x: 14.64, y: 23.47), controlPoint1: NSPoint(x: 14.5, y: 24.26), controlPoint2: NSPoint(x: 14.55, y: 23.86))
mainPath.curve(to: NSPoint(x: 11.5, y: 24.19), controlPoint1: NSPoint(x: 13.7, y: 23.93), controlPoint2: NSPoint(x: 12.63, y: 24.19))
mainPath.curve(to: NSPoint(x: 4.5, y: 17.42), controlPoint1: NSPoint(x: 7.63, y: 24.19), controlPoint2: NSPoint(x: 4.5, y: 21.16))
mainPath.curve(to: NSPoint(x: 4.51, y: 17.02), controlPoint1: NSPoint(x: 4.5, y: 17.29), controlPoint2: NSPoint(x: 4.5, y: 17.15))
mainPath.curve(to: NSPoint(x: 1.5, y: 12.58), controlPoint1: NSPoint(x: 2.74, y: 16.28), controlPoint2: NSPoint(x: 1.5, y: 14.57))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.74), controlPoint1: NSPoint(x: 1.5, y: 9.91), controlPoint2: NSPoint(x: 3.73, y: 7.74))
mainPath.line(to: NSPoint(x: 23.5, y: 7.74))
mainPath.curve(to: NSPoint(x: 28.5, y: 12.58), controlPoint1: NSPoint(x: 26.26, y: 7.74), controlPoint2: NSPoint(x: 28.5, y: 9.91))
mainPath.curve(to: NSPoint(x: 25.5, y: 17.02), controlPoint1: NSPoint(x: 28.5, y: 14.57), controlPoint2: NSPoint(x: 27.27, y: 16.27))
mainPath.curve(to: NSPoint(x: 23.77, y: 20.81), controlPoint1: NSPoint(x: 25.48, y: 18.51), controlPoint2: NSPoint(x: 24.82, y: 19.85))
mainPath.line(to: NSPoint(x: 23.77, y: 20.81))
mainPath.line(to: NSPoint(x: 23.77, y: 20.81))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.98, y: 21.41))
mainPath.curve(to: NSPoint(x: 24.25, y: 23.23), controlPoint1: NSPoint(x: 23.55, y: 21.9), controlPoint2: NSPoint(x: 23.99, y: 22.52))
mainPath.curve(to: NSPoint(x: 24, y: 23.23), controlPoint1: NSPoint(x: 24.16, y: 23.23), controlPoint2: NSPoint(x: 24.08, y: 23.23))
mainPath.curve(to: NSPoint(x: 18.5, y: 28.55), controlPoint1: NSPoint(x: 20.96, y: 23.23), controlPoint2: NSPoint(x: 18.5, y: 25.61))
mainPath.curve(to: NSPoint(x: 18.51, y: 28.79), controlPoint1: NSPoint(x: 18.5, y: 28.63), controlPoint2: NSPoint(x: 18.5, y: 28.71))
mainPath.curve(to: NSPoint(x: 15.5, y: 24.68), controlPoint1: NSPoint(x: 16.75, y: 28.19), controlPoint2: NSPoint(x: 15.5, y: 26.58))
mainPath.curve(to: NSPoint(x: 16.07, y: 22.55), controlPoint1: NSPoint(x: 15.5, y: 23.9), controlPoint2: NSPoint(x: 15.71, y: 23.18))
mainPath.curve(to: NSPoint(x: 17.11, y: 21.47), controlPoint1: NSPoint(x: 16.46, y: 22.22), controlPoint2: NSPoint(x: 16.81, y: 21.86))
mainPath.curve(to: NSPoint(x: 20, y: 22.26), controlPoint1: NSPoint(x: 17.95, y: 21.97), controlPoint2: NSPoint(x: 18.94, y: 22.26))
mainPath.curve(to: NSPoint(x: 22.98, y: 21.41), controlPoint1: NSPoint(x: 21.1, y: 22.26), controlPoint2: NSPoint(x: 22.12, y: 21.95))
mainPath.line(to: NSPoint(x: 22.98, y: 21.41))
mainPath.line(to: NSPoint(x: 22.98, y: 21.41))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.5, y: 3.04))
mainPath.curve(to: NSPoint(x: 8.01, y: 6.77), controlPoint1: NSPoint(x: 5.5, y: 4.44), controlPoint2: NSPoint(x: 8.01, y: 6.77))
mainPath.curve(to: NSPoint(x: 10.5, y: 3.04), controlPoint1: NSPoint(x: 8.01, y: 6.77), controlPoint2: NSPoint(x: 10.5, y: 4.44))
mainPath.curve(to: NSPoint(x: 8.01, y: 0.97), controlPoint1: NSPoint(x: 10.5, y: 2.05), controlPoint2: NSPoint(x: 9.69, y: 0.97))
mainPath.curve(to: NSPoint(x: 5.5, y: 3.04), controlPoint1: NSPoint(x: 6.33, y: 0.97), controlPoint2: NSPoint(x: 5.5, y: 1.96))
mainPath.line(to: NSPoint(x: 5.5, y: 3.04))
mainPath.close()
mainPath.move(to: NSPoint(x: 6.51, y: 3.1))
mainPath.curve(to: NSPoint(x: 8.01, y: 5.34), controlPoint1: NSPoint(x: 6.51, y: 3.77), controlPoint2: NSPoint(x: 8.01, y: 5.34))
mainPath.curve(to: NSPoint(x: 9.51, y: 3.1), controlPoint1: NSPoint(x: 8.01, y: 5.34), controlPoint2: NSPoint(x: 9.51, y: 3.77))
mainPath.curve(to: NSPoint(x: 8.01, y: 1.94), controlPoint1: NSPoint(x: 9.51, y: 2.37), controlPoint2: NSPoint(x: 8.84, y: 1.94))
mainPath.curve(to: NSPoint(x: 6.51, y: 3.1), controlPoint1: NSPoint(x: 7.18, y: 1.94), controlPoint2: NSPoint(x: 6.51, y: 2.25))
mainPath.line(to: NSPoint(x: 6.51, y: 3.1))
mainPath.close()
mainPath.move(to: NSPoint(x: 12.5, y: 2.07))
mainPath.curve(to: NSPoint(x: 15.01, y: 5.81), controlPoint1: NSPoint(x: 12.5, y: 3.47), controlPoint2: NSPoint(x: 15.01, y: 5.81))
mainPath.curve(to: NSPoint(x: 17.5, y: 2.07), controlPoint1: NSPoint(x: 15.01, y: 5.81), controlPoint2: NSPoint(x: 17.5, y: 3.47))
mainPath.curve(to: NSPoint(x: 15.01, y: 0), controlPoint1: NSPoint(x: 17.5, y: 1.08), controlPoint2: NSPoint(x: 16.69, y: 0))
mainPath.curve(to: NSPoint(x: 12.5, y: 2.07), controlPoint1: NSPoint(x: 13.33, y: -0), controlPoint2: NSPoint(x: 12.5, y: 1))
mainPath.line(to: NSPoint(x: 12.5, y: 2.07))
mainPath.close()
mainPath.move(to: NSPoint(x: 13.51, y: 2.13))
mainPath.curve(to: NSPoint(x: 15.01, y: 4.38), controlPoint1: NSPoint(x: 13.51, y: 2.81), controlPoint2: NSPoint(x: 15.01, y: 4.38))
mainPath.curve(to: NSPoint(x: 16.51, y: 2.13), controlPoint1: NSPoint(x: 15.01, y: 4.38), controlPoint2: NSPoint(x: 16.51, y: 2.81))
mainPath.curve(to: NSPoint(x: 15.01, y: 0.97), controlPoint1: NSPoint(x: 16.51, y: 1.4), controlPoint2: NSPoint(x: 15.84, y: 0.97))
mainPath.curve(to: NSPoint(x: 13.51, y: 2.13), controlPoint1: NSPoint(x: 14.18, y: 0.97), controlPoint2: NSPoint(x: 13.51, y: 1.28))
mainPath.line(to: NSPoint(x: 13.51, y: 2.13))
mainPath.close()
mainPath.move(to: NSPoint(x: 19.5, y: 3.04))
mainPath.curve(to: NSPoint(x: 22.01, y: 6.77), controlPoint1: NSPoint(x: 19.5, y: 4.44), controlPoint2: NSPoint(x: 22.01, y: 6.77))
mainPath.curve(to: NSPoint(x: 24.5, y: 3.04), controlPoint1: NSPoint(x: 22.01, y: 6.77), controlPoint2: NSPoint(x: 24.5, y: 4.44))
mainPath.curve(to: NSPoint(x: 22.01, y: 0.97), controlPoint1: NSPoint(x: 24.5, y: 2.05), controlPoint2: NSPoint(x: 23.69, y: 0.97))
mainPath.curve(to: NSPoint(x: 19.5, y: 3.04), controlPoint1: NSPoint(x: 20.33, y: 0.97), controlPoint2: NSPoint(x: 19.5, y: 1.96))
mainPath.line(to: NSPoint(x: 19.5, y: 3.04))
mainPath.close()
mainPath.move(to: NSPoint(x: 20.51, y: 3.1))
mainPath.curve(to: NSPoint(x: 22.01, y: 5.34), controlPoint1: NSPoint(x: 20.51, y: 3.77), controlPoint2: NSPoint(x: 22.01, y: 5.34))
mainPath.curve(to: NSPoint(x: 23.51, y: 3.1), controlPoint1: NSPoint(x: 22.01, y: 5.34), controlPoint2: NSPoint(x: 23.51, y: 3.77))
mainPath.curve(to: NSPoint(x: 22.01, y: 1.94), controlPoint1: NSPoint(x: 23.51, y: 2.37), controlPoint2: NSPoint(x: 22.84, y: 1.94))
mainPath.curve(to: NSPoint(x: 20.51, y: 3.1), controlPoint1: NSPoint(x: 21.18, y: 1.94), controlPoint2: NSPoint(x: 20.51, y: 2.25))
mainPath.line(to: NSPoint(x: 20.51, y: 3.1))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudSnowflakes(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 18.9))
mainPath.curve(to: NSPoint(x: 2.5, y: 15), controlPoint1: NSPoint(x: 3.82, y: 18.49), controlPoint2: NSPoint(x: 2.5, y: 16.9))
mainPath.curve(to: NSPoint(x: 6.5, y: 11), controlPoint1: NSPoint(x: 2.5, y: 12.79), controlPoint2: NSPoint(x: 4.3, y: 11))
mainPath.line(to: NSPoint(x: 23.5, y: 11))
mainPath.curve(to: NSPoint(x: 27.5, y: 15), controlPoint1: NSPoint(x: 25.71, y: 11), controlPoint2: NSPoint(x: 27.5, y: 12.8))
mainPath.curve(to: NSPoint(x: 24.46, y: 18.88), controlPoint1: NSPoint(x: 27.5, y: 16.88), controlPoint2: NSPoint(x: 26.2, y: 18.45))
mainPath.line(to: NSPoint(x: 24.46, y: 18.88))
mainPath.curve(to: NSPoint(x: 24.5, y: 19.5), controlPoint1: NSPoint(x: 24.49, y: 19.09), controlPoint2: NSPoint(x: 24.5, y: 19.29))
mainPath.curve(to: NSPoint(x: 20, y: 24), controlPoint1: NSPoint(x: 24.5, y: 21.99), controlPoint2: NSPoint(x: 22.49, y: 24))
mainPath.curve(to: NSPoint(x: 16.85, y: 22.72), controlPoint1: NSPoint(x: 18.77, y: 24), controlPoint2: NSPoint(x: 17.66, y: 23.51))
mainPath.curve(to: NSPoint(x: 11.5, y: 26), controlPoint1: NSPoint(x: 15.86, y: 24.66), controlPoint2: NSPoint(x: 13.84, y: 26))
mainPath.curve(to: NSPoint(x: 5.5, y: 20), controlPoint1: NSPoint(x: 8.19, y: 26), controlPoint2: NSPoint(x: 5.5, y: 23.31))
mainPath.curve(to: NSPoint(x: 5.6, y: 18.9), controlPoint1: NSPoint(x: 5.5, y: 19.62), controlPoint2: NSPoint(x: 5.53, y: 19.26))
mainPath.line(to: NSPoint(x: 5.6, y: 18.9))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.5, y: 19.59))
mainPath.curve(to: NSPoint(x: 28.5, y: 15), controlPoint1: NSPoint(x: 27.27, y: 18.81), controlPoint2: NSPoint(x: 28.5, y: 17.05))
mainPath.curve(to: NSPoint(x: 23.5, y: 10), controlPoint1: NSPoint(x: 28.5, y: 12.24), controlPoint2: NSPoint(x: 26.26, y: 10))
mainPath.line(to: NSPoint(x: 6.5, y: 10))
mainPath.curve(to: NSPoint(x: 1.5, y: 15), controlPoint1: NSPoint(x: 3.73, y: 10), controlPoint2: NSPoint(x: 1.5, y: 12.24))
mainPath.curve(to: NSPoint(x: 4.51, y: 19.59), controlPoint1: NSPoint(x: 1.5, y: 17.05), controlPoint2: NSPoint(x: 2.74, y: 18.82))
mainPath.line(to: NSPoint(x: 4.51, y: 19.59))
mainPath.curve(to: NSPoint(x: 4.5, y: 20), controlPoint1: NSPoint(x: 4.5, y: 19.72), controlPoint2: NSPoint(x: 4.5, y: 19.86))
mainPath.curve(to: NSPoint(x: 11.5, y: 27), controlPoint1: NSPoint(x: 4.5, y: 23.87), controlPoint2: NSPoint(x: 7.63, y: 27))
mainPath.curve(to: NSPoint(x: 17.11, y: 24.18), controlPoint1: NSPoint(x: 13.8, y: 27), controlPoint2: NSPoint(x: 15.84, y: 25.89))
mainPath.curve(to: NSPoint(x: 20, y: 25), controlPoint1: NSPoint(x: 17.95, y: 24.7), controlPoint2: NSPoint(x: 18.94, y: 25))
mainPath.curve(to: NSPoint(x: 25.5, y: 19.59), controlPoint1: NSPoint(x: 23.01, y: 25), controlPoint2: NSPoint(x: 25.45, y: 22.58))
mainPath.line(to: NSPoint(x: 25.5, y: 19.59))
mainPath.line(to: NSPoint(x: 25.5, y: 19.59))
mainPath.close()
mainPath.move(to: NSPoint(x: 9.5, y: 7.37))
mainPath.line(to: NSPoint(x: 9.5, y: 8.5))
mainPath.curve(to: NSPoint(x: 9, y: 9), controlPoint1: NSPoint(x: 9.5, y: 8.78), controlPoint2: NSPoint(x: 9.27, y: 9))
mainPath.curve(to: NSPoint(x: 8.5, y: 8.5), controlPoint1: NSPoint(x: 8.72, y: 9), controlPoint2: NSPoint(x: 8.5, y: 8.79))
mainPath.line(to: NSPoint(x: 8.5, y: 7.37))
mainPath.line(to: NSPoint(x: 8.5, y: 7.37))
mainPath.line(to: NSPoint(x: 7.52, y: 7.93))
mainPath.curve(to: NSPoint(x: 6.83, y: 7.75), controlPoint1: NSPoint(x: 7.28, y: 8.07), controlPoint2: NSPoint(x: 6.97, y: 7.98))
mainPath.curve(to: NSPoint(x: 7.02, y: 7.07), controlPoint1: NSPoint(x: 6.7, y: 7.51), controlPoint2: NSPoint(x: 6.77, y: 7.21))
mainPath.line(to: NSPoint(x: 8, y: 6.5))
mainPath.line(to: NSPoint(x: 7.02, y: 5.93))
mainPath.curve(to: NSPoint(x: 6.83, y: 5.25), controlPoint1: NSPoint(x: 6.78, y: 5.79), controlPoint2: NSPoint(x: 6.7, y: 5.48))
mainPath.curve(to: NSPoint(x: 7.52, y: 5.07), controlPoint1: NSPoint(x: 6.97, y: 5.01), controlPoint2: NSPoint(x: 7.27, y: 4.92))
mainPath.line(to: NSPoint(x: 8.5, y: 5.63))
mainPath.line(to: NSPoint(x: 8.5, y: 4.5))
mainPath.curve(to: NSPoint(x: 9, y: 4), controlPoint1: NSPoint(x: 8.5, y: 4.22), controlPoint2: NSPoint(x: 8.73, y: 4))
mainPath.curve(to: NSPoint(x: 9.5, y: 4.5), controlPoint1: NSPoint(x: 9.28, y: 4), controlPoint2: NSPoint(x: 9.5, y: 4.21))
mainPath.line(to: NSPoint(x: 9.5, y: 5.63))
mainPath.line(to: NSPoint(x: 10.48, y: 5.07))
mainPath.curve(to: NSPoint(x: 11.17, y: 5.25), controlPoint1: NSPoint(x: 10.72, y: 4.93), controlPoint2: NSPoint(x: 11.03, y: 5.02))
mainPath.curve(to: NSPoint(x: 10.98, y: 5.93), controlPoint1: NSPoint(x: 11.3, y: 5.49), controlPoint2: NSPoint(x: 11.23, y: 5.79))
mainPath.line(to: NSPoint(x: 10, y: 6.5))
mainPath.line(to: NSPoint(x: 10.98, y: 7.07))
mainPath.curve(to: NSPoint(x: 11.17, y: 7.75), controlPoint1: NSPoint(x: 11.22, y: 7.21), controlPoint2: NSPoint(x: 11.3, y: 7.52))
mainPath.curve(to: NSPoint(x: 10.48, y: 7.93), controlPoint1: NSPoint(x: 11.03, y: 7.99), controlPoint2: NSPoint(x: 10.73, y: 8.08))
mainPath.line(to: NSPoint(x: 9.5, y: 7.37))
mainPath.line(to: NSPoint(x: 9.5, y: 7.37))
mainPath.line(to: NSPoint(x: 9.5, y: 7.37))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.5, y: 7.37))
mainPath.line(to: NSPoint(x: 21.5, y: 8.5))
mainPath.curve(to: NSPoint(x: 21, y: 9), controlPoint1: NSPoint(x: 21.5, y: 8.78), controlPoint2: NSPoint(x: 21.27, y: 9))
mainPath.curve(to: NSPoint(x: 20.5, y: 8.5), controlPoint1: NSPoint(x: 20.72, y: 9), controlPoint2: NSPoint(x: 20.5, y: 8.79))
mainPath.line(to: NSPoint(x: 20.5, y: 7.37))
mainPath.line(to: NSPoint(x: 20.5, y: 7.37))
mainPath.line(to: NSPoint(x: 19.52, y: 7.93))
mainPath.curve(to: NSPoint(x: 18.83, y: 7.75), controlPoint1: NSPoint(x: 19.28, y: 8.07), controlPoint2: NSPoint(x: 18.97, y: 7.98))
mainPath.curve(to: NSPoint(x: 19.02, y: 7.07), controlPoint1: NSPoint(x: 18.7, y: 7.51), controlPoint2: NSPoint(x: 18.77, y: 7.21))
mainPath.line(to: NSPoint(x: 20, y: 6.5))
mainPath.line(to: NSPoint(x: 19.02, y: 5.93))
mainPath.curve(to: NSPoint(x: 18.83, y: 5.25), controlPoint1: NSPoint(x: 18.78, y: 5.79), controlPoint2: NSPoint(x: 18.7, y: 5.48))
mainPath.curve(to: NSPoint(x: 19.52, y: 5.07), controlPoint1: NSPoint(x: 18.97, y: 5.01), controlPoint2: NSPoint(x: 19.27, y: 4.92))
mainPath.line(to: NSPoint(x: 20.5, y: 5.63))
mainPath.line(to: NSPoint(x: 20.5, y: 4.5))
mainPath.curve(to: NSPoint(x: 21, y: 4), controlPoint1: NSPoint(x: 20.5, y: 4.22), controlPoint2: NSPoint(x: 20.73, y: 4))
mainPath.curve(to: NSPoint(x: 21.5, y: 4.5), controlPoint1: NSPoint(x: 21.28, y: 4), controlPoint2: NSPoint(x: 21.5, y: 4.21))
mainPath.line(to: NSPoint(x: 21.5, y: 5.63))
mainPath.line(to: NSPoint(x: 22.48, y: 5.07))
mainPath.curve(to: NSPoint(x: 23.17, y: 5.25), controlPoint1: NSPoint(x: 22.72, y: 4.93), controlPoint2: NSPoint(x: 23.03, y: 5.02))
mainPath.curve(to: NSPoint(x: 22.98, y: 5.93), controlPoint1: NSPoint(x: 23.3, y: 5.49), controlPoint2: NSPoint(x: 23.23, y: 5.79))
mainPath.line(to: NSPoint(x: 22, y: 6.5))
mainPath.line(to: NSPoint(x: 22.98, y: 7.07))
mainPath.curve(to: NSPoint(x: 23.17, y: 7.75), controlPoint1: NSPoint(x: 23.22, y: 7.21), controlPoint2: NSPoint(x: 23.3, y: 7.52))
mainPath.curve(to: NSPoint(x: 22.48, y: 7.93), controlPoint1: NSPoint(x: 23.03, y: 7.99), controlPoint2: NSPoint(x: 22.73, y: 8.08))
mainPath.line(to: NSPoint(x: 21.5, y: 7.37))
mainPath.line(to: NSPoint(x: 21.5, y: 7.37))
mainPath.line(to: NSPoint(x: 21.5, y: 7.37))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.5, y: 6.37))
mainPath.line(to: NSPoint(x: 15.5, y: 7.5))
mainPath.curve(to: NSPoint(x: 15, y: 8), controlPoint1: NSPoint(x: 15.5, y: 7.78), controlPoint2: NSPoint(x: 15.27, y: 8))
mainPath.curve(to: NSPoint(x: 14.5, y: 7.5), controlPoint1: NSPoint(x: 14.72, y: 8), controlPoint2: NSPoint(x: 14.5, y: 7.79))
mainPath.line(to: NSPoint(x: 14.5, y: 6.37))
mainPath.line(to: NSPoint(x: 14.5, y: 6.37))
mainPath.line(to: NSPoint(x: 13.52, y: 6.93))
mainPath.curve(to: NSPoint(x: 12.83, y: 6.75), controlPoint1: NSPoint(x: 13.28, y: 7.07), controlPoint2: NSPoint(x: 12.97, y: 6.98))
mainPath.curve(to: NSPoint(x: 13.02, y: 6.07), controlPoint1: NSPoint(x: 12.7, y: 6.51), controlPoint2: NSPoint(x: 12.77, y: 6.21))
mainPath.line(to: NSPoint(x: 14, y: 5.5))
mainPath.line(to: NSPoint(x: 13.02, y: 4.93))
mainPath.curve(to: NSPoint(x: 12.83, y: 4.25), controlPoint1: NSPoint(x: 12.78, y: 4.79), controlPoint2: NSPoint(x: 12.7, y: 4.48))
mainPath.curve(to: NSPoint(x: 13.52, y: 4.07), controlPoint1: NSPoint(x: 12.97, y: 4.01), controlPoint2: NSPoint(x: 13.27, y: 3.92))
mainPath.line(to: NSPoint(x: 14.5, y: 4.63))
mainPath.line(to: NSPoint(x: 14.5, y: 3.5))
mainPath.curve(to: NSPoint(x: 15, y: 3), controlPoint1: NSPoint(x: 14.5, y: 3.22), controlPoint2: NSPoint(x: 14.73, y: 3))
mainPath.curve(to: NSPoint(x: 15.5, y: 3.5), controlPoint1: NSPoint(x: 15.28, y: 3), controlPoint2: NSPoint(x: 15.5, y: 3.21))
mainPath.line(to: NSPoint(x: 15.5, y: 4.63))
mainPath.line(to: NSPoint(x: 16.48, y: 4.07))
mainPath.curve(to: NSPoint(x: 17.17, y: 4.25), controlPoint1: NSPoint(x: 16.72, y: 3.93), controlPoint2: NSPoint(x: 17.03, y: 4.02))
mainPath.curve(to: NSPoint(x: 16.98, y: 4.93), controlPoint1: NSPoint(x: 17.3, y: 4.49), controlPoint2: NSPoint(x: 17.23, y: 4.79))
mainPath.line(to: NSPoint(x: 16, y: 5.5))
mainPath.line(to: NSPoint(x: 16.98, y: 6.07))
mainPath.curve(to: NSPoint(x: 17.17, y: 6.75), controlPoint1: NSPoint(x: 17.22, y: 6.21), controlPoint2: NSPoint(x: 17.3, y: 6.52))
mainPath.curve(to: NSPoint(x: 16.48, y: 6.93), controlPoint1: NSPoint(x: 17.03, y: 6.99), controlPoint2: NSPoint(x: 16.73, y: 7.08))
mainPath.line(to: NSPoint(x: 15.5, y: 6.37))
mainPath.line(to: NSPoint(x: 15.5, y: 6.37))
mainPath.line(to: NSPoint(x: 15.5, y: 6.37))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudSunSnowflakes(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 15.39))
mainPath.curve(to: NSPoint(x: 2.5, y: 11.61), controlPoint1: NSPoint(x: 3.82, y: 14.99), controlPoint2: NSPoint(x: 2.5, y: 13.45))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.74), controlPoint1: NSPoint(x: 2.5, y: 9.48), controlPoint2: NSPoint(x: 4.3, y: 7.74))
mainPath.line(to: NSPoint(x: 23.5, y: 7.74))
mainPath.curve(to: NSPoint(x: 27.5, y: 11.61), controlPoint1: NSPoint(x: 25.71, y: 7.74), controlPoint2: NSPoint(x: 27.5, y: 9.48))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.37), controlPoint1: NSPoint(x: 27.5, y: 13.43), controlPoint2: NSPoint(x: 26.2, y: 14.95))
mainPath.line(to: NSPoint(x: 24.46, y: 15.37))
mainPath.curve(to: NSPoint(x: 24.5, y: 15.97), controlPoint1: NSPoint(x: 24.49, y: 15.57), controlPoint2: NSPoint(x: 24.5, y: 15.77))
mainPath.curve(to: NSPoint(x: 20, y: 20.32), controlPoint1: NSPoint(x: 24.5, y: 18.37), controlPoint2: NSPoint(x: 22.49, y: 20.32))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.08), controlPoint1: NSPoint(x: 18.77, y: 20.32), controlPoint2: NSPoint(x: 17.66, y: 19.85))
mainPath.curve(to: NSPoint(x: 11.5, y: 22.26), controlPoint1: NSPoint(x: 15.86, y: 20.97), controlPoint2: NSPoint(x: 13.84, y: 22.26))
mainPath.curve(to: NSPoint(x: 5.5, y: 16.45), controlPoint1: NSPoint(x: 8.19, y: 22.26), controlPoint2: NSPoint(x: 5.5, y: 19.66))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.39), controlPoint1: NSPoint(x: 5.5, y: 16.09), controlPoint2: NSPoint(x: 5.53, y: 15.73))
mainPath.line(to: NSPoint(x: 5.6, y: 15.39))
mainPath.close()
mainPath.move(to: NSPoint(x: 23.45, y: 20.11))
mainPath.curve(to: NSPoint(x: 23.5, y: 20.81), controlPoint1: NSPoint(x: 23.48, y: 20.34), controlPoint2: NSPoint(x: 23.5, y: 20.57))
mainPath.curve(to: NSPoint(x: 18, y: 26.13), controlPoint1: NSPoint(x: 23.5, y: 23.75), controlPoint2: NSPoint(x: 21.04, y: 26.13))
mainPath.curve(to: NSPoint(x: 13.02, y: 23.07), controlPoint1: NSPoint(x: 15.8, y: 26.13), controlPoint2: NSPoint(x: 13.9, y: 24.88))
mainPath.line(to: NSPoint(x: 13.02, y: 23.07))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.23), controlPoint1: NSPoint(x: 12.53, y: 23.17), controlPoint2: NSPoint(x: 12.02, y: 23.23))
mainPath.curve(to: NSPoint(x: 4.5, y: 16.45), controlPoint1: NSPoint(x: 7.63, y: 23.23), controlPoint2: NSPoint(x: 4.5, y: 20.19))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.05), controlPoint1: NSPoint(x: 4.5, y: 16.32), controlPoint2: NSPoint(x: 4.5, y: 16.19))
mainPath.curve(to: NSPoint(x: 1.5, y: 11.61), controlPoint1: NSPoint(x: 2.74, y: 15.31), controlPoint2: NSPoint(x: 1.5, y: 13.6))
mainPath.curve(to: NSPoint(x: 6.5, y: 6.77), controlPoint1: NSPoint(x: 1.5, y: 8.94), controlPoint2: NSPoint(x: 3.73, y: 6.77))
mainPath.line(to: NSPoint(x: 23.5, y: 6.77))
mainPath.curve(to: NSPoint(x: 28.5, y: 11.61), controlPoint1: NSPoint(x: 26.26, y: 6.77), controlPoint2: NSPoint(x: 28.5, y: 8.95))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.05), controlPoint1: NSPoint(x: 28.5, y: 13.6), controlPoint2: NSPoint(x: 27.27, y: 15.3))
mainPath.curve(to: NSPoint(x: 23.45, y: 20.11), controlPoint1: NSPoint(x: 25.47, y: 17.69), controlPoint2: NSPoint(x: 24.68, y: 19.15))
mainPath.line(to: NSPoint(x: 23.45, y: 20.11))
mainPath.line(to: NSPoint(x: 23.45, y: 20.11))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.5, y: 20.71))
mainPath.curve(to: NSPoint(x: 22.5, y: 20.81), controlPoint1: NSPoint(x: 22.5, y: 20.74), controlPoint2: NSPoint(x: 22.5, y: 20.77))
mainPath.curve(to: NSPoint(x: 18, y: 25.16), controlPoint1: NSPoint(x: 22.5, y: 23.21), controlPoint2: NSPoint(x: 20.49, y: 25.16))
mainPath.curve(to: NSPoint(x: 13.99, y: 22.78), controlPoint1: NSPoint(x: 16.25, y: 25.16), controlPoint2: NSPoint(x: 14.73, y: 24.2))
mainPath.curve(to: NSPoint(x: 17.11, y: 20.5), controlPoint1: NSPoint(x: 15.24, y: 22.32), controlPoint2: NSPoint(x: 16.32, y: 21.52))
mainPath.curve(to: NSPoint(x: 20, y: 21.29), controlPoint1: NSPoint(x: 17.95, y: 21), controlPoint2: NSPoint(x: 18.94, y: 21.29))
mainPath.curve(to: NSPoint(x: 22.5, y: 20.71), controlPoint1: NSPoint(x: 20.9, y: 21.29), controlPoint2: NSPoint(x: 21.75, y: 21.08))
mainPath.line(to: NSPoint(x: 22.5, y: 20.71))
mainPath.line(to: NSPoint(x: 22.5, y: 20.71))
mainPath.close()
mainPath.move(to: NSPoint(x: 9.5, y: 4.23))
mainPath.line(to: NSPoint(x: 9.5, y: 5.32))
mainPath.curve(to: NSPoint(x: 9, y: 5.81), controlPoint1: NSPoint(x: 9.5, y: 5.59), controlPoint2: NSPoint(x: 9.27, y: 5.81))
mainPath.curve(to: NSPoint(x: 8.5, y: 5.32), controlPoint1: NSPoint(x: 8.72, y: 5.81), controlPoint2: NSPoint(x: 8.5, y: 5.6))
mainPath.line(to: NSPoint(x: 8.5, y: 4.23))
mainPath.line(to: NSPoint(x: 8.5, y: 4.23))
mainPath.line(to: NSPoint(x: 7.52, y: 4.77))
mainPath.curve(to: NSPoint(x: 6.83, y: 4.6), controlPoint1: NSPoint(x: 7.28, y: 4.91), controlPoint2: NSPoint(x: 6.97, y: 4.82))
mainPath.curve(to: NSPoint(x: 7.02, y: 3.94), controlPoint1: NSPoint(x: 6.7, y: 4.37), controlPoint2: NSPoint(x: 6.77, y: 4.07))
mainPath.line(to: NSPoint(x: 8, y: 3.39))
mainPath.line(to: NSPoint(x: 7.02, y: 2.84))
mainPath.curve(to: NSPoint(x: 6.83, y: 2.18), controlPoint1: NSPoint(x: 6.78, y: 2.7), controlPoint2: NSPoint(x: 6.7, y: 2.4))
mainPath.curve(to: NSPoint(x: 7.52, y: 2), controlPoint1: NSPoint(x: 6.97, y: 1.95), controlPoint2: NSPoint(x: 7.27, y: 1.86))
mainPath.line(to: NSPoint(x: 8.5, y: 2.55))
mainPath.line(to: NSPoint(x: 8.5, y: 1.45))
mainPath.curve(to: NSPoint(x: 9, y: 0.97), controlPoint1: NSPoint(x: 8.5, y: 1.18), controlPoint2: NSPoint(x: 8.73, y: 0.97))
mainPath.curve(to: NSPoint(x: 9.5, y: 1.45), controlPoint1: NSPoint(x: 9.28, y: 0.97), controlPoint2: NSPoint(x: 9.5, y: 1.18))
mainPath.line(to: NSPoint(x: 9.5, y: 2.55))
mainPath.line(to: NSPoint(x: 10.48, y: 2))
mainPath.curve(to: NSPoint(x: 11.17, y: 2.18), controlPoint1: NSPoint(x: 10.72, y: 1.87), controlPoint2: NSPoint(x: 11.03, y: 1.95))
mainPath.curve(to: NSPoint(x: 10.98, y: 2.84), controlPoint1: NSPoint(x: 11.3, y: 2.41), controlPoint2: NSPoint(x: 11.23, y: 2.7))
mainPath.line(to: NSPoint(x: 10, y: 3.39))
mainPath.line(to: NSPoint(x: 10.98, y: 3.94))
mainPath.curve(to: NSPoint(x: 11.17, y: 4.6), controlPoint1: NSPoint(x: 11.22, y: 4.07), controlPoint2: NSPoint(x: 11.3, y: 4.37))
mainPath.curve(to: NSPoint(x: 10.48, y: 4.77), controlPoint1: NSPoint(x: 11.03, y: 4.83), controlPoint2: NSPoint(x: 10.73, y: 4.91))
mainPath.line(to: NSPoint(x: 9.5, y: 4.23))
mainPath.line(to: NSPoint(x: 9.5, y: 4.23))
mainPath.line(to: NSPoint(x: 9.5, y: 4.23))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.5, y: 4.23))
mainPath.line(to: NSPoint(x: 21.5, y: 5.32))
mainPath.curve(to: NSPoint(x: 21, y: 5.81), controlPoint1: NSPoint(x: 21.5, y: 5.59), controlPoint2: NSPoint(x: 21.27, y: 5.81))
mainPath.curve(to: NSPoint(x: 20.5, y: 5.32), controlPoint1: NSPoint(x: 20.72, y: 5.81), controlPoint2: NSPoint(x: 20.5, y: 5.6))
mainPath.line(to: NSPoint(x: 20.5, y: 4.23))
mainPath.line(to: NSPoint(x: 20.5, y: 4.23))
mainPath.line(to: NSPoint(x: 19.52, y: 4.77))
mainPath.curve(to: NSPoint(x: 18.83, y: 4.6), controlPoint1: NSPoint(x: 19.28, y: 4.91), controlPoint2: NSPoint(x: 18.97, y: 4.82))
mainPath.curve(to: NSPoint(x: 19.02, y: 3.94), controlPoint1: NSPoint(x: 18.7, y: 4.37), controlPoint2: NSPoint(x: 18.77, y: 4.07))
mainPath.line(to: NSPoint(x: 20, y: 3.39))
mainPath.line(to: NSPoint(x: 19.02, y: 2.84))
mainPath.curve(to: NSPoint(x: 18.83, y: 2.18), controlPoint1: NSPoint(x: 18.78, y: 2.7), controlPoint2: NSPoint(x: 18.7, y: 2.4))
mainPath.curve(to: NSPoint(x: 19.52, y: 2), controlPoint1: NSPoint(x: 18.97, y: 1.95), controlPoint2: NSPoint(x: 19.27, y: 1.86))
mainPath.line(to: NSPoint(x: 20.5, y: 2.55))
mainPath.line(to: NSPoint(x: 20.5, y: 1.45))
mainPath.curve(to: NSPoint(x: 21, y: 0.97), controlPoint1: NSPoint(x: 20.5, y: 1.18), controlPoint2: NSPoint(x: 20.73, y: 0.97))
mainPath.curve(to: NSPoint(x: 21.5, y: 1.45), controlPoint1: NSPoint(x: 21.28, y: 0.97), controlPoint2: NSPoint(x: 21.5, y: 1.18))
mainPath.line(to: NSPoint(x: 21.5, y: 2.55))
mainPath.line(to: NSPoint(x: 22.48, y: 2))
mainPath.curve(to: NSPoint(x: 23.17, y: 2.18), controlPoint1: NSPoint(x: 22.72, y: 1.87), controlPoint2: NSPoint(x: 23.03, y: 1.95))
mainPath.curve(to: NSPoint(x: 22.98, y: 2.84), controlPoint1: NSPoint(x: 23.3, y: 2.41), controlPoint2: NSPoint(x: 23.23, y: 2.7))
mainPath.line(to: NSPoint(x: 22, y: 3.39))
mainPath.line(to: NSPoint(x: 22.98, y: 3.94))
mainPath.curve(to: NSPoint(x: 23.17, y: 4.6), controlPoint1: NSPoint(x: 23.22, y: 4.07), controlPoint2: NSPoint(x: 23.3, y: 4.37))
mainPath.curve(to: NSPoint(x: 22.48, y: 4.77), controlPoint1: NSPoint(x: 23.03, y: 4.83), controlPoint2: NSPoint(x: 22.73, y: 4.91))
mainPath.line(to: NSPoint(x: 21.5, y: 4.23))
mainPath.line(to: NSPoint(x: 21.5, y: 4.23))
mainPath.line(to: NSPoint(x: 21.5, y: 4.23))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.5, y: 3.26))
mainPath.line(to: NSPoint(x: 15.5, y: 4.36))
mainPath.curve(to: NSPoint(x: 15, y: 4.84), controlPoint1: NSPoint(x: 15.5, y: 4.62), controlPoint2: NSPoint(x: 15.27, y: 4.84))
mainPath.curve(to: NSPoint(x: 14.5, y: 4.36), controlPoint1: NSPoint(x: 14.72, y: 4.84), controlPoint2: NSPoint(x: 14.5, y: 4.63))
mainPath.line(to: NSPoint(x: 14.5, y: 3.26))
mainPath.line(to: NSPoint(x: 14.5, y: 3.26))
mainPath.line(to: NSPoint(x: 13.52, y: 3.81))
mainPath.curve(to: NSPoint(x: 12.83, y: 3.63), controlPoint1: NSPoint(x: 13.28, y: 3.94), controlPoint2: NSPoint(x: 12.97, y: 3.85))
mainPath.curve(to: NSPoint(x: 13.02, y: 2.97), controlPoint1: NSPoint(x: 12.7, y: 3.4), controlPoint2: NSPoint(x: 12.77, y: 3.11))
mainPath.line(to: NSPoint(x: 14, y: 2.42))
mainPath.line(to: NSPoint(x: 13.02, y: 1.87))
mainPath.curve(to: NSPoint(x: 12.83, y: 1.21), controlPoint1: NSPoint(x: 12.78, y: 1.74), controlPoint2: NSPoint(x: 12.7, y: 1.43))
mainPath.curve(to: NSPoint(x: 13.52, y: 1.03), controlPoint1: NSPoint(x: 12.97, y: 0.98), controlPoint2: NSPoint(x: 13.27, y: 0.89))
mainPath.line(to: NSPoint(x: 14.5, y: 1.58))
mainPath.line(to: NSPoint(x: 14.5, y: 0.48))
mainPath.curve(to: NSPoint(x: 15, y: 0), controlPoint1: NSPoint(x: 14.5, y: 0.22), controlPoint2: NSPoint(x: 14.73, y: 0))
mainPath.curve(to: NSPoint(x: 15.5, y: 0.48), controlPoint1: NSPoint(x: 15.28, y: 0), controlPoint2: NSPoint(x: 15.5, y: 0.21))
mainPath.line(to: NSPoint(x: 15.5, y: 1.58))
mainPath.line(to: NSPoint(x: 16.48, y: 1.03))
mainPath.curve(to: NSPoint(x: 17.17, y: 1.21), controlPoint1: NSPoint(x: 16.72, y: 0.9), controlPoint2: NSPoint(x: 17.03, y: 0.99))
mainPath.curve(to: NSPoint(x: 16.98, y: 1.87), controlPoint1: NSPoint(x: 17.3, y: 1.44), controlPoint2: NSPoint(x: 17.23, y: 1.73))
mainPath.line(to: NSPoint(x: 16, y: 2.42))
mainPath.line(to: NSPoint(x: 16.98, y: 2.97))
mainPath.curve(to: NSPoint(x: 17.17, y: 3.63), controlPoint1: NSPoint(x: 17.22, y: 3.1), controlPoint2: NSPoint(x: 17.3, y: 3.4))
mainPath.curve(to: NSPoint(x: 16.48, y: 3.81), controlPoint1: NSPoint(x: 17.03, y: 3.86), controlPoint2: NSPoint(x: 16.73, y: 3.94))
mainPath.line(to: NSPoint(x: 15.5, y: 3.26))
mainPath.line(to: NSPoint(x: 15.5, y: 3.26))
mainPath.line(to: NSPoint(x: 15.5, y: 3.26))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 30))
mainPath.curve(to: NSPoint(x: 17.5, y: 29.52), controlPoint1: NSPoint(x: 17.72, y: 30), controlPoint2: NSPoint(x: 17.5, y: 29.79))
mainPath.line(to: NSPoint(x: 17.5, y: 27.58))
mainPath.curve(to: NSPoint(x: 18, y: 27.1), controlPoint1: NSPoint(x: 17.5, y: 27.31), controlPoint2: NSPoint(x: 17.73, y: 27.1))
mainPath.curve(to: NSPoint(x: 18.5, y: 27.58), controlPoint1: NSPoint(x: 18.28, y: 27.1), controlPoint2: NSPoint(x: 18.5, y: 27.31))
mainPath.line(to: NSPoint(x: 18.5, y: 29.52))
mainPath.curve(to: NSPoint(x: 18, y: 30), controlPoint1: NSPoint(x: 18.5, y: 29.79), controlPoint2: NSPoint(x: 18.27, y: 30))
mainPath.line(to: NSPoint(x: 18, y: 30))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.73, y: 27.3))
mainPath.curve(to: NSPoint(x: 24.03, y: 27.3), controlPoint1: NSPoint(x: 24.54, y: 27.49), controlPoint2: NSPoint(x: 24.23, y: 27.5))
mainPath.line(to: NSPoint(x: 22.61, y: 25.93))
mainPath.curve(to: NSPoint(x: 22.61, y: 25.25), controlPoint1: NSPoint(x: 22.42, y: 25.74), controlPoint2: NSPoint(x: 22.42, y: 25.43))
mainPath.curve(to: NSPoint(x: 23.32, y: 25.24), controlPoint1: NSPoint(x: 22.81, y: 25.06), controlPoint2: NSPoint(x: 23.12, y: 25.05))
mainPath.line(to: NSPoint(x: 24.74, y: 26.62))
mainPath.curve(to: NSPoint(x: 24.73, y: 27.3), controlPoint1: NSPoint(x: 24.93, y: 26.81), controlPoint2: NSPoint(x: 24.92, y: 27.12))
mainPath.line(to: NSPoint(x: 24.73, y: 27.3))
mainPath.close()
mainPath.move(to: NSPoint(x: 27.52, y: 20.79))
mainPath.curve(to: NSPoint(x: 27.03, y: 21.27), controlPoint1: NSPoint(x: 27.52, y: 21.05), controlPoint2: NSPoint(x: 27.31, y: 21.27))
mainPath.line(to: NSPoint(x: 25.02, y: 21.27))
mainPath.curve(to: NSPoint(x: 24.52, y: 20.79), controlPoint1: NSPoint(x: 24.74, y: 21.27), controlPoint2: NSPoint(x: 24.52, y: 21.04))
mainPath.curve(to: NSPoint(x: 25.02, y: 20.3), controlPoint1: NSPoint(x: 24.52, y: 20.52), controlPoint2: NSPoint(x: 24.74, y: 20.3))
mainPath.line(to: NSPoint(x: 27.03, y: 20.3))
mainPath.curve(to: NSPoint(x: 27.52, y: 20.79), controlPoint1: NSPoint(x: 27.3, y: 20.3), controlPoint2: NSPoint(x: 27.52, y: 20.53))
mainPath.line(to: NSPoint(x: 27.52, y: 20.79))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.27, y: 27.3))
mainPath.curve(to: NSPoint(x: 11.26, y: 26.62), controlPoint1: NSPoint(x: 11.07, y: 27.11), controlPoint2: NSPoint(x: 11.07, y: 26.81))
mainPath.line(to: NSPoint(x: 12.68, y: 25.24))
mainPath.curve(to: NSPoint(x: 13.39, y: 25.25), controlPoint1: NSPoint(x: 12.88, y: 25.06), controlPoint2: NSPoint(x: 13.2, y: 25.06))
mainPath.curve(to: NSPoint(x: 13.39, y: 25.93), controlPoint1: NSPoint(x: 13.58, y: 25.44), controlPoint2: NSPoint(x: 13.59, y: 25.74))
mainPath.line(to: NSPoint(x: 11.97, y: 27.3))
mainPath.curve(to: NSPoint(x: 11.27, y: 27.3), controlPoint1: NSPoint(x: 11.78, y: 27.49), controlPoint2: NSPoint(x: 11.46, y: 27.48))
mainPath.line(to: NSPoint(x: 11.27, y: 27.3))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudMoonSnowflakes(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 15.9))
mainPath.curve(to: NSPoint(x: 2.5, y: 12.01), controlPoint1: NSPoint(x: 3.82, y: 15.49), controlPoint2: NSPoint(x: 2.5, y: 13.9))
mainPath.curve(to: NSPoint(x: 6.5, y: 8.01), controlPoint1: NSPoint(x: 2.5, y: 9.8), controlPoint2: NSPoint(x: 4.3, y: 8.01))
mainPath.line(to: NSPoint(x: 23.5, y: 8.01))
mainPath.curve(to: NSPoint(x: 27.5, y: 12.01), controlPoint1: NSPoint(x: 25.71, y: 8.01), controlPoint2: NSPoint(x: 27.5, y: 9.8))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.89), controlPoint1: NSPoint(x: 27.5, y: 13.88), controlPoint2: NSPoint(x: 26.2, y: 15.46))
mainPath.line(to: NSPoint(x: 24.46, y: 15.89))
mainPath.curve(to: NSPoint(x: 24.5, y: 16.51), controlPoint1: NSPoint(x: 24.49, y: 16.09), controlPoint2: NSPoint(x: 24.5, y: 16.3))
mainPath.curve(to: NSPoint(x: 20, y: 21.01), controlPoint1: NSPoint(x: 24.5, y: 18.99), controlPoint2: NSPoint(x: 22.49, y: 21.01))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.72), controlPoint1: NSPoint(x: 18.77, y: 21.01), controlPoint2: NSPoint(x: 17.66, y: 20.52))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.01), controlPoint1: NSPoint(x: 15.86, y: 21.67), controlPoint2: NSPoint(x: 13.84, y: 23.01))
mainPath.curve(to: NSPoint(x: 5.5, y: 17.01), controlPoint1: NSPoint(x: 8.19, y: 23.01), controlPoint2: NSPoint(x: 5.5, y: 20.32))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.9), controlPoint1: NSPoint(x: 5.5, y: 16.63), controlPoint2: NSPoint(x: 5.53, y: 16.26))
mainPath.line(to: NSPoint(x: 5.6, y: 15.9))
mainPath.close()
mainPath.move(to: NSPoint(x: 23.77, y: 20.51))
mainPath.curve(to: NSPoint(x: 25.34, y: 23.17), controlPoint1: NSPoint(x: 24.53, y: 21.21), controlPoint2: NSPoint(x: 25.08, y: 22.13))
mainPath.curve(to: NSPoint(x: 25.49, y: 24.26), controlPoint1: NSPoint(x: 25.42, y: 23.52), controlPoint2: NSPoint(x: 25.48, y: 23.89))
mainPath.curve(to: NSPoint(x: 24, y: 24.01), controlPoint1: NSPoint(x: 25.03, y: 24.09), controlPoint2: NSPoint(x: 24.52, y: 24.01))
mainPath.curve(to: NSPoint(x: 19.5, y: 28.51), controlPoint1: NSPoint(x: 21.51, y: 24.01), controlPoint2: NSPoint(x: 19.5, y: 26.02))
mainPath.curve(to: NSPoint(x: 19.75, y: 30), controlPoint1: NSPoint(x: 19.5, y: 29.03), controlPoint2: NSPoint(x: 19.59, y: 29.53))
mainPath.curve(to: NSPoint(x: 18.66, y: 29.84), controlPoint1: NSPoint(x: 19.38, y: 29.98), controlPoint2: NSPoint(x: 19.01, y: 29.93))
mainPath.curve(to: NSPoint(x: 14.5, y: 24.51), controlPoint1: NSPoint(x: 16.27, y: 29.24), controlPoint2: NSPoint(x: 14.5, y: 27.08))
mainPath.curve(to: NSPoint(x: 14.64, y: 23.26), controlPoint1: NSPoint(x: 14.5, y: 24.08), controlPoint2: NSPoint(x: 14.55, y: 23.66))
mainPath.curve(to: NSPoint(x: 11.5, y: 24.01), controlPoint1: NSPoint(x: 13.7, y: 23.74), controlPoint2: NSPoint(x: 12.63, y: 24.01))
mainPath.curve(to: NSPoint(x: 4.5, y: 17.01), controlPoint1: NSPoint(x: 7.63, y: 24.01), controlPoint2: NSPoint(x: 4.5, y: 20.87))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.59), controlPoint1: NSPoint(x: 4.5, y: 16.87), controlPoint2: NSPoint(x: 4.5, y: 16.73))
mainPath.curve(to: NSPoint(x: 1.5, y: 12.01), controlPoint1: NSPoint(x: 2.74, y: 15.82), controlPoint2: NSPoint(x: 1.5, y: 14.06))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.01), controlPoint1: NSPoint(x: 1.5, y: 9.24), controlPoint2: NSPoint(x: 3.73, y: 7.01))
mainPath.line(to: NSPoint(x: 23.5, y: 7.01))
mainPath.curve(to: NSPoint(x: 28.5, y: 12.01), controlPoint1: NSPoint(x: 26.26, y: 7.01), controlPoint2: NSPoint(x: 28.5, y: 9.25))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.59), controlPoint1: NSPoint(x: 28.5, y: 14.06), controlPoint2: NSPoint(x: 27.27, y: 15.82))
mainPath.curve(to: NSPoint(x: 23.77, y: 20.51), controlPoint1: NSPoint(x: 25.48, y: 18.13), controlPoint2: NSPoint(x: 24.82, y: 19.52))
mainPath.line(to: NSPoint(x: 23.77, y: 20.51))
mainPath.line(to: NSPoint(x: 23.77, y: 20.51))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.98, y: 21.13))
mainPath.curve(to: NSPoint(x: 24.25, y: 23.01), controlPoint1: NSPoint(x: 23.55, y: 21.63), controlPoint2: NSPoint(x: 23.99, y: 22.28))
mainPath.curve(to: NSPoint(x: 24, y: 23.01), controlPoint1: NSPoint(x: 24.16, y: 23.01), controlPoint2: NSPoint(x: 24.08, y: 23.01))
mainPath.curve(to: NSPoint(x: 18.5, y: 28.51), controlPoint1: NSPoint(x: 20.96, y: 23.01), controlPoint2: NSPoint(x: 18.5, y: 25.47))
mainPath.curve(to: NSPoint(x: 18.51, y: 28.75), controlPoint1: NSPoint(x: 18.5, y: 28.59), controlPoint2: NSPoint(x: 18.5, y: 28.67))
mainPath.curve(to: NSPoint(x: 15.5, y: 24.51), controlPoint1: NSPoint(x: 16.75, y: 28.14), controlPoint2: NSPoint(x: 15.5, y: 26.47))
mainPath.curve(to: NSPoint(x: 16.07, y: 22.3), controlPoint1: NSPoint(x: 15.5, y: 23.71), controlPoint2: NSPoint(x: 15.71, y: 22.96))
mainPath.curve(to: NSPoint(x: 17.11, y: 21.19), controlPoint1: NSPoint(x: 16.46, y: 21.97), controlPoint2: NSPoint(x: 16.81, y: 21.6))
mainPath.curve(to: NSPoint(x: 20, y: 22.01), controlPoint1: NSPoint(x: 17.95, y: 21.71), controlPoint2: NSPoint(x: 18.94, y: 22.01))
mainPath.curve(to: NSPoint(x: 22.98, y: 21.13), controlPoint1: NSPoint(x: 21.1, y: 22.01), controlPoint2: NSPoint(x: 22.12, y: 21.68))
mainPath.line(to: NSPoint(x: 22.98, y: 21.13))
mainPath.line(to: NSPoint(x: 22.98, y: 21.13))
mainPath.close()
mainPath.move(to: NSPoint(x: 9.5, y: 4.37))
mainPath.line(to: NSPoint(x: 9.5, y: 5.5))
mainPath.curve(to: NSPoint(x: 9, y: 6), controlPoint1: NSPoint(x: 9.5, y: 5.78), controlPoint2: NSPoint(x: 9.27, y: 6))
mainPath.curve(to: NSPoint(x: 8.5, y: 5.5), controlPoint1: NSPoint(x: 8.72, y: 6), controlPoint2: NSPoint(x: 8.5, y: 5.79))
mainPath.line(to: NSPoint(x: 8.5, y: 4.37))
mainPath.line(to: NSPoint(x: 8.5, y: 4.37))
mainPath.line(to: NSPoint(x: 7.52, y: 4.93))
mainPath.curve(to: NSPoint(x: 6.83, y: 4.75), controlPoint1: NSPoint(x: 7.28, y: 5.07), controlPoint2: NSPoint(x: 6.97, y: 4.98))
mainPath.curve(to: NSPoint(x: 7.02, y: 4.07), controlPoint1: NSPoint(x: 6.7, y: 4.51), controlPoint2: NSPoint(x: 6.77, y: 4.21))
mainPath.line(to: NSPoint(x: 8, y: 3.5))
mainPath.line(to: NSPoint(x: 7.02, y: 2.93))
mainPath.curve(to: NSPoint(x: 6.83, y: 2.25), controlPoint1: NSPoint(x: 6.78, y: 2.79), controlPoint2: NSPoint(x: 6.7, y: 2.48))
mainPath.curve(to: NSPoint(x: 7.52, y: 2.07), controlPoint1: NSPoint(x: 6.97, y: 2.01), controlPoint2: NSPoint(x: 7.27, y: 1.92))
mainPath.line(to: NSPoint(x: 8.5, y: 2.63))
mainPath.line(to: NSPoint(x: 8.5, y: 1.5))
mainPath.curve(to: NSPoint(x: 9, y: 1), controlPoint1: NSPoint(x: 8.5, y: 1.22), controlPoint2: NSPoint(x: 8.73, y: 1))
mainPath.curve(to: NSPoint(x: 9.5, y: 1.5), controlPoint1: NSPoint(x: 9.28, y: 1), controlPoint2: NSPoint(x: 9.5, y: 1.21))
mainPath.line(to: NSPoint(x: 9.5, y: 2.63))
mainPath.line(to: NSPoint(x: 10.48, y: 2.07))
mainPath.curve(to: NSPoint(x: 11.17, y: 2.25), controlPoint1: NSPoint(x: 10.72, y: 1.93), controlPoint2: NSPoint(x: 11.03, y: 2.02))
mainPath.curve(to: NSPoint(x: 10.98, y: 2.93), controlPoint1: NSPoint(x: 11.3, y: 2.49), controlPoint2: NSPoint(x: 11.23, y: 2.79))
mainPath.line(to: NSPoint(x: 10, y: 3.5))
mainPath.line(to: NSPoint(x: 10.98, y: 4.07))
mainPath.curve(to: NSPoint(x: 11.17, y: 4.75), controlPoint1: NSPoint(x: 11.22, y: 4.21), controlPoint2: NSPoint(x: 11.3, y: 4.52))
mainPath.curve(to: NSPoint(x: 10.48, y: 4.93), controlPoint1: NSPoint(x: 11.03, y: 4.99), controlPoint2: NSPoint(x: 10.73, y: 5.08))
mainPath.line(to: NSPoint(x: 9.5, y: 4.37))
mainPath.line(to: NSPoint(x: 9.5, y: 4.37))
mainPath.line(to: NSPoint(x: 9.5, y: 4.37))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.5, y: 4.37))
mainPath.line(to: NSPoint(x: 21.5, y: 5.5))
mainPath.curve(to: NSPoint(x: 21, y: 6), controlPoint1: NSPoint(x: 21.5, y: 5.78), controlPoint2: NSPoint(x: 21.27, y: 6))
mainPath.curve(to: NSPoint(x: 20.5, y: 5.5), controlPoint1: NSPoint(x: 20.72, y: 6), controlPoint2: NSPoint(x: 20.5, y: 5.79))
mainPath.line(to: NSPoint(x: 20.5, y: 4.37))
mainPath.line(to: NSPoint(x: 20.5, y: 4.37))
mainPath.line(to: NSPoint(x: 19.52, y: 4.93))
mainPath.curve(to: NSPoint(x: 18.83, y: 4.75), controlPoint1: NSPoint(x: 19.28, y: 5.07), controlPoint2: NSPoint(x: 18.97, y: 4.98))
mainPath.curve(to: NSPoint(x: 19.02, y: 4.07), controlPoint1: NSPoint(x: 18.7, y: 4.51), controlPoint2: NSPoint(x: 18.77, y: 4.21))
mainPath.line(to: NSPoint(x: 20, y: 3.5))
mainPath.line(to: NSPoint(x: 19.02, y: 2.93))
mainPath.curve(to: NSPoint(x: 18.83, y: 2.25), controlPoint1: NSPoint(x: 18.78, y: 2.79), controlPoint2: NSPoint(x: 18.7, y: 2.48))
mainPath.curve(to: NSPoint(x: 19.52, y: 2.07), controlPoint1: NSPoint(x: 18.97, y: 2.01), controlPoint2: NSPoint(x: 19.27, y: 1.92))
mainPath.line(to: NSPoint(x: 20.5, y: 2.63))
mainPath.line(to: NSPoint(x: 20.5, y: 1.5))
mainPath.curve(to: NSPoint(x: 21, y: 1), controlPoint1: NSPoint(x: 20.5, y: 1.22), controlPoint2: NSPoint(x: 20.73, y: 1))
mainPath.curve(to: NSPoint(x: 21.5, y: 1.5), controlPoint1: NSPoint(x: 21.28, y: 1), controlPoint2: NSPoint(x: 21.5, y: 1.21))
mainPath.line(to: NSPoint(x: 21.5, y: 2.63))
mainPath.line(to: NSPoint(x: 22.48, y: 2.07))
mainPath.curve(to: NSPoint(x: 23.17, y: 2.25), controlPoint1: NSPoint(x: 22.72, y: 1.93), controlPoint2: NSPoint(x: 23.03, y: 2.02))
mainPath.curve(to: NSPoint(x: 22.98, y: 2.93), controlPoint1: NSPoint(x: 23.3, y: 2.49), controlPoint2: NSPoint(x: 23.23, y: 2.79))
mainPath.line(to: NSPoint(x: 22, y: 3.5))
mainPath.line(to: NSPoint(x: 22.98, y: 4.07))
mainPath.curve(to: NSPoint(x: 23.17, y: 4.75), controlPoint1: NSPoint(x: 23.22, y: 4.21), controlPoint2: NSPoint(x: 23.3, y: 4.52))
mainPath.curve(to: NSPoint(x: 22.48, y: 4.93), controlPoint1: NSPoint(x: 23.03, y: 4.99), controlPoint2: NSPoint(x: 22.73, y: 5.08))
mainPath.line(to: NSPoint(x: 21.5, y: 4.37))
mainPath.line(to: NSPoint(x: 21.5, y: 4.37))
mainPath.line(to: NSPoint(x: 21.5, y: 4.37))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.5, y: 3.37))
mainPath.line(to: NSPoint(x: 15.5, y: 4.5))
mainPath.curve(to: NSPoint(x: 15, y: 5), controlPoint1: NSPoint(x: 15.5, y: 4.78), controlPoint2: NSPoint(x: 15.27, y: 5))
mainPath.curve(to: NSPoint(x: 14.5, y: 4.5), controlPoint1: NSPoint(x: 14.72, y: 5), controlPoint2: NSPoint(x: 14.5, y: 4.79))
mainPath.line(to: NSPoint(x: 14.5, y: 3.37))
mainPath.line(to: NSPoint(x: 14.5, y: 3.37))
mainPath.line(to: NSPoint(x: 13.52, y: 3.93))
mainPath.curve(to: NSPoint(x: 12.83, y: 3.75), controlPoint1: NSPoint(x: 13.28, y: 4.07), controlPoint2: NSPoint(x: 12.97, y: 3.98))
mainPath.curve(to: NSPoint(x: 13.02, y: 3.07), controlPoint1: NSPoint(x: 12.7, y: 3.51), controlPoint2: NSPoint(x: 12.77, y: 3.21))
mainPath.line(to: NSPoint(x: 14, y: 2.5))
mainPath.line(to: NSPoint(x: 13.02, y: 1.93))
mainPath.curve(to: NSPoint(x: 12.83, y: 1.25), controlPoint1: NSPoint(x: 12.78, y: 1.79), controlPoint2: NSPoint(x: 12.7, y: 1.48))
mainPath.curve(to: NSPoint(x: 13.52, y: 1.07), controlPoint1: NSPoint(x: 12.97, y: 1.01), controlPoint2: NSPoint(x: 13.27, y: 0.92))
mainPath.line(to: NSPoint(x: 14.5, y: 1.63))
mainPath.line(to: NSPoint(x: 14.5, y: 0.5))
mainPath.curve(to: NSPoint(x: 15, y: 0), controlPoint1: NSPoint(x: 14.5, y: 0.22), controlPoint2: NSPoint(x: 14.73, y: 0))
mainPath.curve(to: NSPoint(x: 15.5, y: 0.5), controlPoint1: NSPoint(x: 15.28, y: 0), controlPoint2: NSPoint(x: 15.5, y: 0.21))
mainPath.line(to: NSPoint(x: 15.5, y: 1.63))
mainPath.line(to: NSPoint(x: 16.48, y: 1.07))
mainPath.curve(to: NSPoint(x: 17.17, y: 1.25), controlPoint1: NSPoint(x: 16.72, y: 0.93), controlPoint2: NSPoint(x: 17.03, y: 1.02))
mainPath.curve(to: NSPoint(x: 16.98, y: 1.93), controlPoint1: NSPoint(x: 17.3, y: 1.49), controlPoint2: NSPoint(x: 17.23, y: 1.79))
mainPath.line(to: NSPoint(x: 16, y: 2.5))
mainPath.line(to: NSPoint(x: 16.98, y: 3.07))
mainPath.curve(to: NSPoint(x: 17.17, y: 3.75), controlPoint1: NSPoint(x: 17.22, y: 3.21), controlPoint2: NSPoint(x: 17.3, y: 3.52))
mainPath.curve(to: NSPoint(x: 16.48, y: 3.93), controlPoint1: NSPoint(x: 17.03, y: 3.99), controlPoint2: NSPoint(x: 16.73, y: 4.08))
mainPath.line(to: NSPoint(x: 15.5, y: 3.37))
mainPath.line(to: NSPoint(x: 15.5, y: 3.37))
mainPath.line(to: NSPoint(x: 15.5, y: 3.37))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawClouds(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 6.77, y: 7.5))
mainPath.line(to: NSPoint(x: 6.01, y: 7.5))
mainPath.curve(to: NSPoint(x: 4.5, y: 6), controlPoint1: NSPoint(x: 5.17, y: 7.5), controlPoint2: NSPoint(x: 4.5, y: 6.83))
mainPath.curve(to: NSPoint(x: 6.01, y: 4.5), controlPoint1: NSPoint(x: 4.5, y: 5.17), controlPoint2: NSPoint(x: 5.17, y: 4.5))
mainPath.line(to: NSPoint(x: 13.99, y: 4.5))
mainPath.curve(to: NSPoint(x: 15.5, y: 6), controlPoint1: NSPoint(x: 14.83, y: 4.5), controlPoint2: NSPoint(x: 15.5, y: 5.17))
mainPath.curve(to: NSPoint(x: 13.99, y: 7.5), controlPoint1: NSPoint(x: 15.5, y: 6.83), controlPoint2: NSPoint(x: 14.83, y: 7.5))
mainPath.line(to: NSPoint(x: 13.5, y: 7.5))
mainPath.curve(to: NSPoint(x: 11.5, y: 9.5), controlPoint1: NSPoint(x: 13.5, y: 8.6), controlPoint2: NSPoint(x: 12.6, y: 9.5))
mainPath.curve(to: NSPoint(x: 10.39, y: 9.16), controlPoint1: NSPoint(x: 11.09, y: 9.5), controlPoint2: NSPoint(x: 10.71, y: 9.38))
mainPath.curve(to: NSPoint(x: 8.5, y: 10.5), controlPoint1: NSPoint(x: 10.11, y: 9.94), controlPoint2: NSPoint(x: 9.37, y: 10.5))
mainPath.curve(to: NSPoint(x: 6.5, y: 8.5), controlPoint1: NSPoint(x: 7.4, y: 10.5), controlPoint2: NSPoint(x: 6.5, y: 9.6))
mainPath.curve(to: NSPoint(x: 6.77, y: 7.5), controlPoint1: NSPoint(x: 6.5, y: 8.14), controlPoint2: NSPoint(x: 6.6, y: 7.79))
mainPath.line(to: NSPoint(x: 6.77, y: 7.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 14.34, y: 8.48))
mainPath.curve(to: NSPoint(x: 16, y: 7.5), controlPoint1: NSPoint(x: 15.02, y: 8.38), controlPoint2: NSPoint(x: 15.61, y: 8.02))
mainPath.line(to: NSPoint(x: 23.5, y: 7.5))
mainPath.curve(to: NSPoint(x: 27.5, y: 11.5), controlPoint1: NSPoint(x: 25.71, y: 7.5), controlPoint2: NSPoint(x: 27.5, y: 9.3))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.38), controlPoint1: NSPoint(x: 27.5, y: 13.38), controlPoint2: NSPoint(x: 26.2, y: 14.95))
mainPath.line(to: NSPoint(x: 24.46, y: 15.38))
mainPath.curve(to: NSPoint(x: 24.5, y: 16), controlPoint1: NSPoint(x: 24.49, y: 15.59), controlPoint2: NSPoint(x: 24.5, y: 15.79))
mainPath.curve(to: NSPoint(x: 20, y: 20.5), controlPoint1: NSPoint(x: 24.5, y: 18.49), controlPoint2: NSPoint(x: 22.49, y: 20.5))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.22), controlPoint1: NSPoint(x: 18.77, y: 20.5), controlPoint2: NSPoint(x: 17.66, y: 20.01))
mainPath.curve(to: NSPoint(x: 11.5, y: 22.5), controlPoint1: NSPoint(x: 15.86, y: 21.16), controlPoint2: NSPoint(x: 13.84, y: 22.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 16.5), controlPoint1: NSPoint(x: 8.19, y: 22.5), controlPoint2: NSPoint(x: 5.5, y: 19.81))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.4), controlPoint1: NSPoint(x: 5.5, y: 16.12), controlPoint2: NSPoint(x: 5.53, y: 15.76))
mainPath.line(to: NSPoint(x: 5.6, y: 15.4))
mainPath.curve(to: NSPoint(x: 2.5, y: 11.5), controlPoint1: NSPoint(x: 3.82, y: 14.99), controlPoint2: NSPoint(x: 2.5, y: 13.4))
mainPath.curve(to: NSPoint(x: 4.53, y: 8.02), controlPoint1: NSPoint(x: 2.5, y: 10.01), controlPoint2: NSPoint(x: 3.32, y: 8.71))
mainPath.line(to: NSPoint(x: 4.53, y: 8.02))
mainPath.curve(to: NSPoint(x: 5.5, y: 8.45), controlPoint1: NSPoint(x: 4.81, y: 8.23), controlPoint2: NSPoint(x: 5.14, y: 8.38))
mainPath.curve(to: NSPoint(x: 5.5, y: 8.5), controlPoint1: NSPoint(x: 5.5, y: 8.47), controlPoint2: NSPoint(x: 5.5, y: 8.48))
mainPath.curve(to: NSPoint(x: 8.5, y: 11.5), controlPoint1: NSPoint(x: 5.5, y: 10.16), controlPoint2: NSPoint(x: 6.84, y: 11.5))
mainPath.curve(to: NSPoint(x: 10.81, y: 10.42), controlPoint1: NSPoint(x: 9.43, y: 11.5), controlPoint2: NSPoint(x: 10.26, y: 11.08))
mainPath.curve(to: NSPoint(x: 11.5, y: 10.5), controlPoint1: NSPoint(x: 11.03, y: 10.47), controlPoint2: NSPoint(x: 11.26, y: 10.5))
mainPath.curve(to: NSPoint(x: 14.34, y: 8.48), controlPoint1: NSPoint(x: 12.81, y: 10.5), controlPoint2: NSPoint(x: 13.93, y: 9.65))
mainPath.line(to: NSPoint(x: 14.34, y: 8.48))
mainPath.line(to: NSPoint(x: 14.34, y: 8.48))
mainPath.close()
mainPath.move(to: NSPoint(x: 3.84, y: 7.26))
mainPath.curve(to: NSPoint(x: 1.5, y: 11.5), controlPoint1: NSPoint(x: 2.43, y: 8.15), controlPoint2: NSPoint(x: 1.5, y: 9.71))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.09), controlPoint1: NSPoint(x: 1.5, y: 13.55), controlPoint2: NSPoint(x: 2.74, y: 15.32))
mainPath.curve(to: NSPoint(x: 4.5, y: 16.5), controlPoint1: NSPoint(x: 4.5, y: 16.22), controlPoint2: NSPoint(x: 4.5, y: 16.36))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.5), controlPoint1: NSPoint(x: 4.5, y: 20.37), controlPoint2: NSPoint(x: 7.63, y: 23.5))
mainPath.curve(to: NSPoint(x: 15.03, y: 22.54), controlPoint1: NSPoint(x: 12.79, y: 23.5), controlPoint2: NSPoint(x: 14, y: 23.15))
mainPath.curve(to: NSPoint(x: 16.5, y: 23.45), controlPoint1: NSPoint(x: 15.39, y: 23), controlPoint2: NSPoint(x: 15.91, y: 23.33))
mainPath.line(to: NSPoint(x: 16.5, y: 23.45))
mainPath.curve(to: NSPoint(x: 16.5, y: 23.5), controlPoint1: NSPoint(x: 16.5, y: 23.47), controlPoint2: NSPoint(x: 16.5, y: 23.48))
mainPath.curve(to: NSPoint(x: 19.5, y: 26.5), controlPoint1: NSPoint(x: 16.5, y: 25.16), controlPoint2: NSPoint(x: 17.84, y: 26.5))
mainPath.curve(to: NSPoint(x: 21.81, y: 25.42), controlPoint1: NSPoint(x: 20.43, y: 26.5), controlPoint2: NSPoint(x: 21.26, y: 26.08))
mainPath.curve(to: NSPoint(x: 22.5, y: 25.5), controlPoint1: NSPoint(x: 22.03, y: 25.47), controlPoint2: NSPoint(x: 22.26, y: 25.5))
mainPath.curve(to: NSPoint(x: 25.34, y: 23.48), controlPoint1: NSPoint(x: 23.81, y: 25.5), controlPoint2: NSPoint(x: 24.93, y: 24.65))
mainPath.line(to: NSPoint(x: 25.34, y: 23.48))
mainPath.curve(to: NSPoint(x: 27.5, y: 21), controlPoint1: NSPoint(x: 26.56, y: 23.31), controlPoint2: NSPoint(x: 27.5, y: 22.26))
mainPath.curve(to: NSPoint(x: 24.99, y: 18.5), controlPoint1: NSPoint(x: 27.5, y: 19.61), controlPoint2: NSPoint(x: 26.38, y: 18.5))
mainPath.line(to: NSPoint(x: 24.9, y: 18.5))
mainPath.line(to: NSPoint(x: 24.9, y: 18.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.09), controlPoint1: NSPoint(x: 25.27, y: 17.77), controlPoint2: NSPoint(x: 25.49, y: 16.95))
mainPath.curve(to: NSPoint(x: 28.5, y: 11.5), controlPoint1: NSPoint(x: 27.27, y: 15.31), controlPoint2: NSPoint(x: 28.5, y: 13.55))
mainPath.curve(to: NSPoint(x: 23.5, y: 6.5), controlPoint1: NSPoint(x: 28.5, y: 8.74), controlPoint2: NSPoint(x: 26.26, y: 6.5))
mainPath.line(to: NSPoint(x: 16.45, y: 6.5))
mainPath.curve(to: NSPoint(x: 16.5, y: 6), controlPoint1: NSPoint(x: 16.48, y: 6.34), controlPoint2: NSPoint(x: 16.5, y: 6.17))
mainPath.curve(to: NSPoint(x: 13.99, y: 3.5), controlPoint1: NSPoint(x: 16.5, y: 4.61), controlPoint2: NSPoint(x: 15.38, y: 3.5))
mainPath.line(to: NSPoint(x: 6.01, y: 3.5))
mainPath.curve(to: NSPoint(x: 3.5, y: 6), controlPoint1: NSPoint(x: 4.62, y: 3.5), controlPoint2: NSPoint(x: 3.5, y: 4.62))
mainPath.curve(to: NSPoint(x: 3.84, y: 7.26), controlPoint1: NSPoint(x: 3.5, y: 6.46), controlPoint2: NSPoint(x: 3.62, y: 6.89))
mainPath.line(to: NSPoint(x: 3.84, y: 7.26))
mainPath.line(to: NSPoint(x: 3.84, y: 7.26))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.24, y: 19.5))
mainPath.line(to: NSPoint(x: 24.99, y: 19.5))
mainPath.curve(to: NSPoint(x: 26.5, y: 21), controlPoint1: NSPoint(x: 25.83, y: 19.5), controlPoint2: NSPoint(x: 26.5, y: 20.17))
mainPath.curve(to: NSPoint(x: 24.99, y: 22.5), controlPoint1: NSPoint(x: 26.5, y: 21.83), controlPoint2: NSPoint(x: 25.83, y: 22.5))
mainPath.line(to: NSPoint(x: 24.5, y: 22.5))
mainPath.curve(to: NSPoint(x: 22.5, y: 24.5), controlPoint1: NSPoint(x: 24.5, y: 23.6), controlPoint2: NSPoint(x: 23.6, y: 24.5))
mainPath.curve(to: NSPoint(x: 21.39, y: 24.16), controlPoint1: NSPoint(x: 22.09, y: 24.5), controlPoint2: NSPoint(x: 21.71, y: 24.38))
mainPath.curve(to: NSPoint(x: 19.5, y: 25.5), controlPoint1: NSPoint(x: 21.11, y: 24.94), controlPoint2: NSPoint(x: 20.37, y: 25.5))
mainPath.curve(to: NSPoint(x: 17.5, y: 23.5), controlPoint1: NSPoint(x: 18.4, y: 25.5), controlPoint2: NSPoint(x: 17.5, y: 24.6))
mainPath.curve(to: NSPoint(x: 17.77, y: 22.5), controlPoint1: NSPoint(x: 17.5, y: 23.14), controlPoint2: NSPoint(x: 17.6, y: 22.79))
mainPath.line(to: NSPoint(x: 17.77, y: 22.5))
mainPath.line(to: NSPoint(x: 17.01, y: 22.5))
mainPath.curve(to: NSPoint(x: 15.86, y: 21.98), controlPoint1: NSPoint(x: 16.55, y: 22.5), controlPoint2: NSPoint(x: 16.14, y: 22.3))
mainPath.line(to: NSPoint(x: 15.86, y: 21.98))
mainPath.curve(to: NSPoint(x: 17.11, y: 20.68), controlPoint1: NSPoint(x: 16.33, y: 21.6), controlPoint2: NSPoint(x: 16.75, y: 21.17))
mainPath.curve(to: NSPoint(x: 20, y: 21.5), controlPoint1: NSPoint(x: 17.95, y: 21.2), controlPoint2: NSPoint(x: 18.94, y: 21.5))
mainPath.curve(to: NSPoint(x: 24.24, y: 19.5), controlPoint1: NSPoint(x: 21.71, y: 21.5), controlPoint2: NSPoint(x: 23.23, y: 20.72))
mainPath.line(to: NSPoint(x: 24.24, y: 19.5))
mainPath.line(to: NSPoint(x: 24.24, y: 19.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudAdd(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 14.5, y: 13.5))
mainPath.line(to: NSPoint(x: 14.5, y: 16))
mainPath.curve(to: NSPoint(x: 15, y: 16.5), controlPoint1: NSPoint(x: 14.5, y: 16.27), controlPoint2: NSPoint(x: 14.72, y: 16.5))
mainPath.curve(to: NSPoint(x: 15.5, y: 16), controlPoint1: NSPoint(x: 15.27, y: 16.5), controlPoint2: NSPoint(x: 15.5, y: 16.27))
mainPath.line(to: NSPoint(x: 15.5, y: 13.5))
mainPath.line(to: NSPoint(x: 18, y: 13.5))
mainPath.curve(to: NSPoint(x: 18.5, y: 13), controlPoint1: NSPoint(x: 18.27, y: 13.5), controlPoint2: NSPoint(x: 18.5, y: 13.28))
mainPath.curve(to: NSPoint(x: 18, y: 12.5), controlPoint1: NSPoint(x: 18.5, y: 12.73), controlPoint2: NSPoint(x: 18.27, y: 12.5))
mainPath.line(to: NSPoint(x: 15.5, y: 12.5))
mainPath.line(to: NSPoint(x: 15.5, y: 10))
mainPath.curve(to: NSPoint(x: 15, y: 9.5), controlPoint1: NSPoint(x: 15.5, y: 9.73), controlPoint2: NSPoint(x: 15.28, y: 9.5))
mainPath.curve(to: NSPoint(x: 14.5, y: 10), controlPoint1: NSPoint(x: 14.73, y: 9.5), controlPoint2: NSPoint(x: 14.5, y: 9.73))
mainPath.line(to: NSPoint(x: 14.5, y: 12.5))
mainPath.line(to: NSPoint(x: 12, y: 12.5))
mainPath.curve(to: NSPoint(x: 11.5, y: 13), controlPoint1: NSPoint(x: 11.73, y: 12.5), controlPoint2: NSPoint(x: 11.5, y: 12.72))
mainPath.curve(to: NSPoint(x: 12, y: 13.5), controlPoint1: NSPoint(x: 11.5, y: 13.27), controlPoint2: NSPoint(x: 11.73, y: 13.5))
mainPath.line(to: NSPoint(x: 14.5, y: 13.5))
mainPath.line(to: NSPoint(x: 14.5, y: 13.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.6, y: 15.4))
mainPath.curve(to: NSPoint(x: 2.5, y: 11.5), controlPoint1: NSPoint(x: 3.82, y: 14.99), controlPoint2: NSPoint(x: 2.5, y: 13.4))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.5), controlPoint1: NSPoint(x: 2.5, y: 9.29), controlPoint2: NSPoint(x: 4.3, y: 7.5))
mainPath.line(to: NSPoint(x: 23.5, y: 7.5))
mainPath.curve(to: NSPoint(x: 27.5, y: 11.5), controlPoint1: NSPoint(x: 25.71, y: 7.5), controlPoint2: NSPoint(x: 27.5, y: 9.3))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.38), controlPoint1: NSPoint(x: 27.5, y: 13.38), controlPoint2: NSPoint(x: 26.2, y: 14.95))
mainPath.line(to: NSPoint(x: 24.46, y: 15.38))
mainPath.curve(to: NSPoint(x: 24.5, y: 16), controlPoint1: NSPoint(x: 24.49, y: 15.59), controlPoint2: NSPoint(x: 24.5, y: 15.79))
mainPath.curve(to: NSPoint(x: 20, y: 20.5), controlPoint1: NSPoint(x: 24.5, y: 18.49), controlPoint2: NSPoint(x: 22.49, y: 20.5))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.22), controlPoint1: NSPoint(x: 18.77, y: 20.5), controlPoint2: NSPoint(x: 17.66, y: 20.01))
mainPath.curve(to: NSPoint(x: 11.5, y: 22.5), controlPoint1: NSPoint(x: 15.86, y: 21.16), controlPoint2: NSPoint(x: 13.84, y: 22.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 16.5), controlPoint1: NSPoint(x: 8.19, y: 22.5), controlPoint2: NSPoint(x: 5.5, y: 19.81))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.4), controlPoint1: NSPoint(x: 5.5, y: 16.12), controlPoint2: NSPoint(x: 5.53, y: 15.76))
mainPath.line(to: NSPoint(x: 5.6, y: 15.4))
mainPath.line(to: NSPoint(x: 5.6, y: 15.4))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.5, y: 16.09))
mainPath.curve(to: NSPoint(x: 28.5, y: 11.5), controlPoint1: NSPoint(x: 27.27, y: 15.31), controlPoint2: NSPoint(x: 28.5, y: 13.55))
mainPath.curve(to: NSPoint(x: 23.5, y: 6.5), controlPoint1: NSPoint(x: 28.5, y: 8.74), controlPoint2: NSPoint(x: 26.26, y: 6.5))
mainPath.line(to: NSPoint(x: 6.5, y: 6.5))
mainPath.curve(to: NSPoint(x: 1.5, y: 11.5), controlPoint1: NSPoint(x: 3.73, y: 6.5), controlPoint2: NSPoint(x: 1.5, y: 8.74))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.09), controlPoint1: NSPoint(x: 1.5, y: 13.55), controlPoint2: NSPoint(x: 2.74, y: 15.32))
mainPath.line(to: NSPoint(x: 4.51, y: 16.09))
mainPath.curve(to: NSPoint(x: 4.5, y: 16.5), controlPoint1: NSPoint(x: 4.5, y: 16.22), controlPoint2: NSPoint(x: 4.5, y: 16.36))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.5), controlPoint1: NSPoint(x: 4.5, y: 20.37), controlPoint2: NSPoint(x: 7.63, y: 23.5))
mainPath.curve(to: NSPoint(x: 17.11, y: 20.68), controlPoint1: NSPoint(x: 13.8, y: 23.5), controlPoint2: NSPoint(x: 15.84, y: 22.39))
mainPath.curve(to: NSPoint(x: 20, y: 21.5), controlPoint1: NSPoint(x: 17.95, y: 21.2), controlPoint2: NSPoint(x: 18.94, y: 21.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.09), controlPoint1: NSPoint(x: 23.01, y: 21.5), controlPoint2: NSPoint(x: 25.45, y: 19.08))
mainPath.line(to: NSPoint(x: 25.5, y: 16.09))
mainPath.line(to: NSPoint(x: 25.5, y: 16.09))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudRemove(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 15.4))
mainPath.curve(to: NSPoint(x: 2.5, y: 11.5), controlPoint1: NSPoint(x: 3.82, y: 14.99), controlPoint2: NSPoint(x: 2.5, y: 13.4))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.5), controlPoint1: NSPoint(x: 2.5, y: 9.29), controlPoint2: NSPoint(x: 4.3, y: 7.5))
mainPath.line(to: NSPoint(x: 23.5, y: 7.5))
mainPath.curve(to: NSPoint(x: 27.5, y: 11.5), controlPoint1: NSPoint(x: 25.71, y: 7.5), controlPoint2: NSPoint(x: 27.5, y: 9.3))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.38), controlPoint1: NSPoint(x: 27.5, y: 13.38), controlPoint2: NSPoint(x: 26.2, y: 14.95))
mainPath.line(to: NSPoint(x: 24.46, y: 15.38))
mainPath.curve(to: NSPoint(x: 24.5, y: 16), controlPoint1: NSPoint(x: 24.49, y: 15.59), controlPoint2: NSPoint(x: 24.5, y: 15.79))
mainPath.curve(to: NSPoint(x: 20, y: 20.5), controlPoint1: NSPoint(x: 24.5, y: 18.49), controlPoint2: NSPoint(x: 22.49, y: 20.5))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.22), controlPoint1: NSPoint(x: 18.77, y: 20.5), controlPoint2: NSPoint(x: 17.66, y: 20.01))
mainPath.curve(to: NSPoint(x: 11.5, y: 22.5), controlPoint1: NSPoint(x: 15.86, y: 21.16), controlPoint2: NSPoint(x: 13.84, y: 22.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 16.5), controlPoint1: NSPoint(x: 8.19, y: 22.5), controlPoint2: NSPoint(x: 5.5, y: 19.81))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.4), controlPoint1: NSPoint(x: 5.5, y: 16.12), controlPoint2: NSPoint(x: 5.53, y: 15.76))
mainPath.line(to: NSPoint(x: 5.6, y: 15.4))
mainPath.line(to: NSPoint(x: 5.6, y: 15.4))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.5, y: 16.09))
mainPath.curve(to: NSPoint(x: 28.5, y: 11.5), controlPoint1: NSPoint(x: 27.27, y: 15.31), controlPoint2: NSPoint(x: 28.5, y: 13.55))
mainPath.curve(to: NSPoint(x: 23.5, y: 6.5), controlPoint1: NSPoint(x: 28.5, y: 8.74), controlPoint2: NSPoint(x: 26.26, y: 6.5))
mainPath.line(to: NSPoint(x: 6.5, y: 6.5))
mainPath.curve(to: NSPoint(x: 1.5, y: 11.5), controlPoint1: NSPoint(x: 3.73, y: 6.5), controlPoint2: NSPoint(x: 1.5, y: 8.74))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.09), controlPoint1: NSPoint(x: 1.5, y: 13.55), controlPoint2: NSPoint(x: 2.74, y: 15.32))
mainPath.line(to: NSPoint(x: 4.51, y: 16.09))
mainPath.curve(to: NSPoint(x: 4.5, y: 16.5), controlPoint1: NSPoint(x: 4.5, y: 16.22), controlPoint2: NSPoint(x: 4.5, y: 16.36))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.5), controlPoint1: NSPoint(x: 4.5, y: 20.37), controlPoint2: NSPoint(x: 7.63, y: 23.5))
mainPath.curve(to: NSPoint(x: 17.11, y: 20.68), controlPoint1: NSPoint(x: 13.8, y: 23.5), controlPoint2: NSPoint(x: 15.84, y: 22.39))
mainPath.curve(to: NSPoint(x: 20, y: 21.5), controlPoint1: NSPoint(x: 17.95, y: 21.2), controlPoint2: NSPoint(x: 18.94, y: 21.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.09), controlPoint1: NSPoint(x: 23.01, y: 21.5), controlPoint2: NSPoint(x: 25.45, y: 19.08))
mainPath.line(to: NSPoint(x: 25.5, y: 16.09))
mainPath.line(to: NSPoint(x: 25.5, y: 16.09))
mainPath.close()
mainPath.move(to: NSPoint(x: 12, y: 13.5))
mainPath.curve(to: NSPoint(x: 11.5, y: 13), controlPoint1: NSPoint(x: 11.73, y: 13.5), controlPoint2: NSPoint(x: 11.5, y: 13.27))
mainPath.curve(to: NSPoint(x: 12, y: 12.5), controlPoint1: NSPoint(x: 11.5, y: 12.72), controlPoint2: NSPoint(x: 11.73, y: 12.5))
mainPath.line(to: NSPoint(x: 18, y: 12.5))
mainPath.curve(to: NSPoint(x: 18.5, y: 13), controlPoint1: NSPoint(x: 18.27, y: 12.5), controlPoint2: NSPoint(x: 18.5, y: 12.73))
mainPath.curve(to: NSPoint(x: 18, y: 13.5), controlPoint1: NSPoint(x: 18.5, y: 13.28), controlPoint2: NSPoint(x: 18.27, y: 13.5))
mainPath.line(to: NSPoint(x: 12, y: 13.5))
mainPath.line(to: NSPoint(x: 12, y: 13.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudError1(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 5.6, y: 15.4))
mainPath.curve(to: NSPoint(x: 2.5, y: 11.5), controlPoint1: NSPoint(x: 3.82, y: 14.99), controlPoint2: NSPoint(x: 2.5, y: 13.4))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.5), controlPoint1: NSPoint(x: 2.5, y: 9.29), controlPoint2: NSPoint(x: 4.3, y: 7.5))
mainPath.line(to: NSPoint(x: 23.5, y: 7.5))
mainPath.curve(to: NSPoint(x: 27.5, y: 11.5), controlPoint1: NSPoint(x: 25.71, y: 7.5), controlPoint2: NSPoint(x: 27.5, y: 9.3))
mainPath.curve(to: NSPoint(x: 24.46, y: 15.38), controlPoint1: NSPoint(x: 27.5, y: 13.38), controlPoint2: NSPoint(x: 26.2, y: 14.95))
mainPath.line(to: NSPoint(x: 24.46, y: 15.38))
mainPath.curve(to: NSPoint(x: 24.5, y: 16), controlPoint1: NSPoint(x: 24.49, y: 15.59), controlPoint2: NSPoint(x: 24.5, y: 15.79))
mainPath.curve(to: NSPoint(x: 20, y: 20.5), controlPoint1: NSPoint(x: 24.5, y: 18.49), controlPoint2: NSPoint(x: 22.49, y: 20.5))
mainPath.curve(to: NSPoint(x: 16.85, y: 19.22), controlPoint1: NSPoint(x: 18.77, y: 20.5), controlPoint2: NSPoint(x: 17.66, y: 20.01))
mainPath.curve(to: NSPoint(x: 11.5, y: 22.5), controlPoint1: NSPoint(x: 15.86, y: 21.16), controlPoint2: NSPoint(x: 13.84, y: 22.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 16.5), controlPoint1: NSPoint(x: 8.19, y: 22.5), controlPoint2: NSPoint(x: 5.5, y: 19.81))
mainPath.curve(to: NSPoint(x: 5.6, y: 15.4), controlPoint1: NSPoint(x: 5.5, y: 16.12), controlPoint2: NSPoint(x: 5.53, y: 15.76))
mainPath.line(to: NSPoint(x: 5.6, y: 15.4))
mainPath.line(to: NSPoint(x: 5.6, y: 15.4))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.5, y: 16.09))
mainPath.curve(to: NSPoint(x: 28.5, y: 11.5), controlPoint1: NSPoint(x: 27.27, y: 15.31), controlPoint2: NSPoint(x: 28.5, y: 13.55))
mainPath.curve(to: NSPoint(x: 23.5, y: 6.5), controlPoint1: NSPoint(x: 28.5, y: 8.74), controlPoint2: NSPoint(x: 26.26, y: 6.5))
mainPath.line(to: NSPoint(x: 6.5, y: 6.5))
mainPath.curve(to: NSPoint(x: 1.5, y: 11.5), controlPoint1: NSPoint(x: 3.73, y: 6.5), controlPoint2: NSPoint(x: 1.5, y: 8.74))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.09), controlPoint1: NSPoint(x: 1.5, y: 13.55), controlPoint2: NSPoint(x: 2.74, y: 15.32))
mainPath.line(to: NSPoint(x: 4.51, y: 16.09))
mainPath.curve(to: NSPoint(x: 4.5, y: 16.5), controlPoint1: NSPoint(x: 4.5, y: 16.22), controlPoint2: NSPoint(x: 4.5, y: 16.36))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.5), controlPoint1: NSPoint(x: 4.5, y: 20.37), controlPoint2: NSPoint(x: 7.63, y: 23.5))
mainPath.curve(to: NSPoint(x: 17.11, y: 20.68), controlPoint1: NSPoint(x: 13.8, y: 23.5), controlPoint2: NSPoint(x: 15.84, y: 22.39))
mainPath.curve(to: NSPoint(x: 20, y: 21.5), controlPoint1: NSPoint(x: 17.95, y: 21.2), controlPoint2: NSPoint(x: 18.94, y: 21.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.09), controlPoint1: NSPoint(x: 23.01, y: 21.5), controlPoint2: NSPoint(x: 25.45, y: 19.08))
mainPath.line(to: NSPoint(x: 25.5, y: 16.09))
mainPath.line(to: NSPoint(x: 25.5, y: 16.09))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 17.5))
mainPath.curve(to: NSPoint(x: 14.5, y: 17.01), controlPoint1: NSPoint(x: 14.72, y: 17.5), controlPoint2: NSPoint(x: 14.5, y: 17.27))
mainPath.line(to: NSPoint(x: 14.5, y: 11.99))
mainPath.curve(to: NSPoint(x: 15, y: 11.5), controlPoint1: NSPoint(x: 14.5, y: 11.72), controlPoint2: NSPoint(x: 14.73, y: 11.5))
mainPath.curve(to: NSPoint(x: 15.5, y: 11.99), controlPoint1: NSPoint(x: 15.28, y: 11.5), controlPoint2: NSPoint(x: 15.5, y: 11.73))
mainPath.line(to: NSPoint(x: 15.5, y: 17.01))
mainPath.curve(to: NSPoint(x: 15, y: 17.5), controlPoint1: NSPoint(x: 15.5, y: 17.28), controlPoint2: NSPoint(x: 15.27, y: 17.5))
mainPath.line(to: NSPoint(x: 15, y: 17.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 9.5))
mainPath.curve(to: NSPoint(x: 14.5, y: 10), controlPoint1: NSPoint(x: 14.72, y: 9.5), controlPoint2: NSPoint(x: 14.5, y: 9.73))
mainPath.curve(to: NSPoint(x: 15, y: 10.5), controlPoint1: NSPoint(x: 14.5, y: 10.28), controlPoint2: NSPoint(x: 14.73, y: 10.5))
mainPath.curve(to: NSPoint(x: 15.5, y: 10), controlPoint1: NSPoint(x: 15.28, y: 10.5), controlPoint2: NSPoint(x: 15.5, y: 10.27))
mainPath.curve(to: NSPoint(x: 15, y: 9.5), controlPoint1: NSPoint(x: 15.5, y: 9.72), controlPoint2: NSPoint(x: 15.27, y: 9.5))
mainPath.line(to: NSPoint(x: 15, y: 9.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudFog(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 1.51, y: 11.12))
mainPath.curve(to: NSPoint(x: 1.5, y: 11.5), controlPoint1: NSPoint(x: 1.5, y: 11.24), controlPoint2: NSPoint(x: 1.5, y: 11.37))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.09), controlPoint1: NSPoint(x: 1.5, y: 13.55), controlPoint2: NSPoint(x: 2.74, y: 15.32))
mainPath.line(to: NSPoint(x: 4.51, y: 16.09))
mainPath.curve(to: NSPoint(x: 4.5, y: 16.5), controlPoint1: NSPoint(x: 4.5, y: 16.22), controlPoint2: NSPoint(x: 4.5, y: 16.36))
mainPath.curve(to: NSPoint(x: 4.51, y: 16.9), controlPoint1: NSPoint(x: 4.5, y: 16.63), controlPoint2: NSPoint(x: 4.5, y: 16.76))
mainPath.line(to: NSPoint(x: 4.51, y: 16.9))
mainPath.curve(to: NSPoint(x: 4.5, y: 17), controlPoint1: NSPoint(x: 4.5, y: 16.93), controlPoint2: NSPoint(x: 4.5, y: 16.96))
mainPath.curve(to: NSPoint(x: 4.53, y: 17.17), controlPoint1: NSPoint(x: 4.5, y: 17.06), controlPoint2: NSPoint(x: 4.51, y: 17.12))
mainPath.curve(to: NSPoint(x: 11.5, y: 23.5), controlPoint1: NSPoint(x: 4.87, y: 20.72), controlPoint2: NSPoint(x: 7.86, y: 23.5))
mainPath.curve(to: NSPoint(x: 17.11, y: 20.68), controlPoint1: NSPoint(x: 13.8, y: 23.5), controlPoint2: NSPoint(x: 15.84, y: 22.39))
mainPath.curve(to: NSPoint(x: 20, y: 21.5), controlPoint1: NSPoint(x: 17.95, y: 21.2), controlPoint2: NSPoint(x: 18.94, y: 21.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 16.09), controlPoint1: NSPoint(x: 23.01, y: 21.5), controlPoint2: NSPoint(x: 25.45, y: 19.08))
mainPath.line(to: NSPoint(x: 25.5, y: 16.09))
mainPath.curve(to: NSPoint(x: 28.5, y: 11.5), controlPoint1: NSPoint(x: 27.27, y: 15.31), controlPoint2: NSPoint(x: 28.5, y: 13.55))
mainPath.curve(to: NSPoint(x: 28.49, y: 11.12), controlPoint1: NSPoint(x: 28.5, y: 11.37), controlPoint2: NSPoint(x: 28.5, y: 11.24))
mainPath.curve(to: NSPoint(x: 28.5, y: 11), controlPoint1: NSPoint(x: 28.49, y: 11.08), controlPoint2: NSPoint(x: 28.5, y: 11.04))
mainPath.curve(to: NSPoint(x: 28.45, y: 10.78), controlPoint1: NSPoint(x: 28.5, y: 10.92), controlPoint2: NSPoint(x: 28.48, y: 10.85))
mainPath.curve(to: NSPoint(x: 23.5, y: 6.5), controlPoint1: NSPoint(x: 28.1, y: 8.36), controlPoint2: NSPoint(x: 26.02, y: 6.5))
mainPath.line(to: NSPoint(x: 6.5, y: 6.5))
mainPath.curve(to: NSPoint(x: 1.55, y: 10.78), controlPoint1: NSPoint(x: 3.98, y: 6.5), controlPoint2: NSPoint(x: 1.9, y: 8.36))
mainPath.curve(to: NSPoint(x: 1.5, y: 11), controlPoint1: NSPoint(x: 1.52, y: 10.85), controlPoint2: NSPoint(x: 1.5, y: 10.92))
mainPath.curve(to: NSPoint(x: 1.51, y: 11.12), controlPoint1: NSPoint(x: 1.5, y: 11.04), controlPoint2: NSPoint(x: 1.5, y: 11.08))
mainPath.line(to: NSPoint(x: 1.51, y: 11.12))
mainPath.close()
mainPath.move(to: NSPoint(x: 2.5, y: 11.5))
mainPath.curve(to: NSPoint(x: 2.63, y: 12.5), controlPoint1: NSPoint(x: 2.5, y: 11.85), controlPoint2: NSPoint(x: 2.54, y: 12.18))
mainPath.line(to: NSPoint(x: 2.63, y: 12.5))
mainPath.line(to: NSPoint(x: 27.37, y: 12.5))
mainPath.curve(to: NSPoint(x: 27.5, y: 11.5), controlPoint1: NSPoint(x: 27.46, y: 12.18), controlPoint2: NSPoint(x: 27.5, y: 11.85))
mainPath.line(to: NSPoint(x: 2.5, y: 11.5))
mainPath.line(to: NSPoint(x: 2.5, y: 11.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 2.63, y: 10.5))
mainPath.curve(to: NSPoint(x: 3.04, y: 9.5), controlPoint1: NSPoint(x: 2.72, y: 10.15), controlPoint2: NSPoint(x: 2.86, y: 9.81))
mainPath.line(to: NSPoint(x: 3.04, y: 9.5))
mainPath.line(to: NSPoint(x: 26.96, y: 9.5))
mainPath.curve(to: NSPoint(x: 27.37, y: 10.5), controlPoint1: NSPoint(x: 27.14, y: 9.81), controlPoint2: NSPoint(x: 27.28, y: 10.15))
mainPath.line(to: NSPoint(x: 2.63, y: 10.5))
mainPath.line(to: NSPoint(x: 2.63, y: 10.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 7.03, y: 20.5))
mainPath.curve(to: NSPoint(x: 6.3, y: 19.5), controlPoint1: NSPoint(x: 6.75, y: 20.19), controlPoint2: NSPoint(x: 6.51, y: 19.86))
mainPath.line(to: NSPoint(x: 6.3, y: 19.5))
mainPath.line(to: NSPoint(x: 16.7, y: 19.5))
mainPath.curve(to: NSPoint(x: 15.97, y: 20.5), controlPoint1: NSPoint(x: 16.49, y: 19.86), controlPoint2: NSPoint(x: 16.25, y: 20.19))
mainPath.line(to: NSPoint(x: 7.03, y: 20.5))
mainPath.line(to: NSPoint(x: 7.03, y: 20.5))
mainPath.line(to: NSPoint(x: 7.03, y: 20.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.18, y: 21.5))
mainPath.curve(to: NSPoint(x: 11.5, y: 22.5), controlPoint1: NSPoint(x: 9.13, y: 22.13), controlPoint2: NSPoint(x: 10.27, y: 22.5))
mainPath.curve(to: NSPoint(x: 14.82, y: 21.5), controlPoint1: NSPoint(x: 12.73, y: 22.5), controlPoint2: NSPoint(x: 13.87, y: 22.13))
mainPath.line(to: NSPoint(x: 8.18, y: 21.5))
mainPath.line(to: NSPoint(x: 8.18, y: 21.5))
mainPath.line(to: NSPoint(x: 8.18, y: 21.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.85, y: 18.52))
mainPath.curve(to: NSPoint(x: 5.58, y: 17.5), controlPoint1: NSPoint(x: 5.73, y: 18.2), controlPoint2: NSPoint(x: 5.64, y: 17.85))
mainPath.line(to: NSPoint(x: 5.58, y: 17.5))
mainPath.line(to: NSPoint(x: 24.24, y: 17.5))
mainPath.curve(to: NSPoint(x: 23.74, y: 18.5), controlPoint1: NSPoint(x: 24.12, y: 17.86), controlPoint2: NSPoint(x: 23.95, y: 18.19))
mainPath.line(to: NSPoint(x: 6.01, y: 18.5))
mainPath.curve(to: NSPoint(x: 5.85, y: 18.52), controlPoint1: NSPoint(x: 5.95, y: 18.5), controlPoint2: NSPoint(x: 5.9, y: 18.51))
mainPath.line(to: NSPoint(x: 5.85, y: 18.52))
mainPath.line(to: NSPoint(x: 5.85, y: 18.52))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.17, y: 19.5))
mainPath.curve(to: NSPoint(x: 20, y: 20.5), controlPoint1: NSPoint(x: 17.94, y: 20.13), controlPoint2: NSPoint(x: 18.93, y: 20.5))
mainPath.curve(to: NSPoint(x: 22.83, y: 19.5), controlPoint1: NSPoint(x: 21.07, y: 20.5), controlPoint2: NSPoint(x: 22.06, y: 20.13))
mainPath.line(to: NSPoint(x: 17.17, y: 19.5))
mainPath.line(to: NSPoint(x: 17.17, y: 19.5))
mainPath.line(to: NSPoint(x: 17.17, y: 19.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.5, y: 16.5))
mainPath.curve(to: NSPoint(x: 5.58, y: 15.5), controlPoint1: NSPoint(x: 5.5, y: 16.16), controlPoint2: NSPoint(x: 5.53, y: 15.83))
mainPath.line(to: NSPoint(x: 5.58, y: 15.5))
mainPath.line(to: NSPoint(x: 24.47, y: 15.5))
mainPath.curve(to: NSPoint(x: 24.5, y: 16), controlPoint1: NSPoint(x: 24.49, y: 15.66), controlPoint2: NSPoint(x: 24.5, y: 15.83))
mainPath.curve(to: NSPoint(x: 24.47, y: 16.5), controlPoint1: NSPoint(x: 24.5, y: 16.17), controlPoint2: NSPoint(x: 24.49, y: 16.34))
mainPath.line(to: NSPoint(x: 5.5, y: 16.5))
mainPath.line(to: NSPoint(x: 5.5, y: 16.5))
mainPath.line(to: NSPoint(x: 5.5, y: 16.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 3.88, y: 14.52))
mainPath.curve(to: NSPoint(x: 3.04, y: 13.5), controlPoint1: NSPoint(x: 3.54, y: 14.23), controlPoint2: NSPoint(x: 3.26, y: 13.88))
mainPath.line(to: NSPoint(x: 3.04, y: 13.5))
mainPath.line(to: NSPoint(x: 26.96, y: 13.5))
mainPath.curve(to: NSPoint(x: 26.12, y: 14.52), controlPoint1: NSPoint(x: 26.74, y: 13.88), controlPoint2: NSPoint(x: 26.46, y: 14.23))
mainPath.curve(to: NSPoint(x: 26, y: 14.5), controlPoint1: NSPoint(x: 26.08, y: 14.51), controlPoint2: NSPoint(x: 26.04, y: 14.5))
mainPath.line(to: NSPoint(x: 4, y: 14.5))
mainPath.curve(to: NSPoint(x: 3.88, y: 14.52), controlPoint1: NSPoint(x: 3.96, y: 14.5), controlPoint2: NSPoint(x: 3.92, y: 14.51))
mainPath.line(to: NSPoint(x: 3.88, y: 14.52))
mainPath.line(to: NSPoint(x: 3.88, y: 14.52))
mainPath.close()
mainPath.move(to: NSPoint(x: 3.86, y: 8.5))
mainPath.curve(to: NSPoint(x: 6.5, y: 7.5), controlPoint1: NSPoint(x: 4.56, y: 7.88), controlPoint2: NSPoint(x: 5.49, y: 7.5))
mainPath.line(to: NSPoint(x: 23.5, y: 7.5))
mainPath.curve(to: NSPoint(x: 26.14, y: 8.5), controlPoint1: NSPoint(x: 24.51, y: 7.5), controlPoint2: NSPoint(x: 25.44, y: 7.88))
mainPath.line(to: NSPoint(x: 3.86, y: 8.5))
mainPath.line(to: NSPoint(x: 3.86, y: 8.5))
mainPath.line(to: NSPoint(x: 3.86, y: 8.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudSunFog(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 28.49, y: 7.62))
mainPath.curve(to: NSPoint(x: 28.5, y: 8), controlPoint1: NSPoint(x: 28.5, y: 7.74), controlPoint2: NSPoint(x: 28.5, y: 7.87))
mainPath.curve(to: NSPoint(x: 25.5, y: 12.59), controlPoint1: NSPoint(x: 28.5, y: 10.05), controlPoint2: NSPoint(x: 27.27, y: 11.81))
mainPath.curve(to: NSPoint(x: 23.45, y: 16.78), controlPoint1: NSPoint(x: 25.47, y: 14.28), controlPoint2: NSPoint(x: 24.68, y: 15.79))
mainPath.line(to: NSPoint(x: 23.45, y: 16.78))
mainPath.curve(to: NSPoint(x: 23.5, y: 17.5), controlPoint1: NSPoint(x: 23.48, y: 17.02), controlPoint2: NSPoint(x: 23.5, y: 17.26))
mainPath.curve(to: NSPoint(x: 18, y: 23), controlPoint1: NSPoint(x: 23.5, y: 20.54), controlPoint2: NSPoint(x: 21.04, y: 23))
mainPath.curve(to: NSPoint(x: 13.02, y: 19.83), controlPoint1: NSPoint(x: 15.8, y: 23), controlPoint2: NSPoint(x: 13.9, y: 21.71))
mainPath.line(to: NSPoint(x: 13.02, y: 19.83))
mainPath.curve(to: NSPoint(x: 11.5, y: 20), controlPoint1: NSPoint(x: 12.53, y: 19.94), controlPoint2: NSPoint(x: 12.02, y: 20))
mainPath.curve(to: NSPoint(x: 4.53, y: 13.67), controlPoint1: NSPoint(x: 7.86, y: 20), controlPoint2: NSPoint(x: 4.87, y: 17.22))
mainPath.line(to: NSPoint(x: 4.53, y: 13.67))
mainPath.curve(to: NSPoint(x: 4.5, y: 13.5), controlPoint1: NSPoint(x: 4.51, y: 13.62), controlPoint2: NSPoint(x: 4.5, y: 13.56))
mainPath.curve(to: NSPoint(x: 4.51, y: 13.4), controlPoint1: NSPoint(x: 4.5, y: 13.46), controlPoint2: NSPoint(x: 4.5, y: 13.43))
mainPath.curve(to: NSPoint(x: 4.5, y: 13), controlPoint1: NSPoint(x: 4.5, y: 13.26), controlPoint2: NSPoint(x: 4.5, y: 13.13))
mainPath.curve(to: NSPoint(x: 4.51, y: 12.59), controlPoint1: NSPoint(x: 4.5, y: 12.86), controlPoint2: NSPoint(x: 4.5, y: 12.72))
mainPath.curve(to: NSPoint(x: 1.5, y: 8), controlPoint1: NSPoint(x: 2.74, y: 11.82), controlPoint2: NSPoint(x: 1.5, y: 10.05))
mainPath.curve(to: NSPoint(x: 1.51, y: 7.62), controlPoint1: NSPoint(x: 1.5, y: 7.87), controlPoint2: NSPoint(x: 1.5, y: 7.74))
mainPath.curve(to: NSPoint(x: 1.5, y: 7.5), controlPoint1: NSPoint(x: 1.5, y: 7.58), controlPoint2: NSPoint(x: 1.5, y: 7.54))
mainPath.curve(to: NSPoint(x: 1.55, y: 7.28), controlPoint1: NSPoint(x: 1.5, y: 7.42), controlPoint2: NSPoint(x: 1.52, y: 7.35))
mainPath.curve(to: NSPoint(x: 6.5, y: 3), controlPoint1: NSPoint(x: 1.9, y: 4.86), controlPoint2: NSPoint(x: 3.98, y: 3))
mainPath.line(to: NSPoint(x: 23.5, y: 3))
mainPath.curve(to: NSPoint(x: 28.45, y: 7.28), controlPoint1: NSPoint(x: 26.02, y: 3), controlPoint2: NSPoint(x: 28.1, y: 4.86))
mainPath.curve(to: NSPoint(x: 28.5, y: 7.5), controlPoint1: NSPoint(x: 28.48, y: 7.35), controlPoint2: NSPoint(x: 28.5, y: 7.42))
mainPath.curve(to: NSPoint(x: 28.49, y: 7.62), controlPoint1: NSPoint(x: 28.5, y: 7.54), controlPoint2: NSPoint(x: 28.49, y: 7.58))
mainPath.line(to: NSPoint(x: 28.49, y: 7.62))
mainPath.close()
mainPath.move(to: NSPoint(x: 2.5, y: 8))
mainPath.curve(to: NSPoint(x: 2.63, y: 9), controlPoint1: NSPoint(x: 2.5, y: 8.35), controlPoint2: NSPoint(x: 2.54, y: 8.68))
mainPath.line(to: NSPoint(x: 2.63, y: 9))
mainPath.line(to: NSPoint(x: 27.37, y: 9))
mainPath.curve(to: NSPoint(x: 27.5, y: 8), controlPoint1: NSPoint(x: 27.46, y: 8.68), controlPoint2: NSPoint(x: 27.5, y: 8.35))
mainPath.line(to: NSPoint(x: 2.5, y: 8))
mainPath.line(to: NSPoint(x: 2.5, y: 8))
mainPath.close()
mainPath.move(to: NSPoint(x: 2.63, y: 7))
mainPath.curve(to: NSPoint(x: 3.04, y: 6), controlPoint1: NSPoint(x: 2.72, y: 6.65), controlPoint2: NSPoint(x: 2.86, y: 6.31))
mainPath.line(to: NSPoint(x: 3.04, y: 6))
mainPath.line(to: NSPoint(x: 26.96, y: 6))
mainPath.curve(to: NSPoint(x: 27.37, y: 7), controlPoint1: NSPoint(x: 27.14, y: 6.31), controlPoint2: NSPoint(x: 27.28, y: 6.65))
mainPath.line(to: NSPoint(x: 2.63, y: 7))
mainPath.line(to: NSPoint(x: 2.63, y: 7))
mainPath.close()
mainPath.move(to: NSPoint(x: 7.03, y: 17))
mainPath.curve(to: NSPoint(x: 6.3, y: 16), controlPoint1: NSPoint(x: 6.75, y: 16.69), controlPoint2: NSPoint(x: 6.51, y: 16.36))
mainPath.line(to: NSPoint(x: 6.3, y: 16))
mainPath.line(to: NSPoint(x: 16.7, y: 16))
mainPath.curve(to: NSPoint(x: 15.97, y: 17), controlPoint1: NSPoint(x: 16.49, y: 16.36), controlPoint2: NSPoint(x: 16.25, y: 16.69))
mainPath.line(to: NSPoint(x: 7.03, y: 17))
mainPath.line(to: NSPoint(x: 7.03, y: 17))
mainPath.line(to: NSPoint(x: 7.03, y: 17))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.18, y: 18))
mainPath.curve(to: NSPoint(x: 11.5, y: 19), controlPoint1: NSPoint(x: 9.13, y: 18.63), controlPoint2: NSPoint(x: 10.27, y: 19))
mainPath.curve(to: NSPoint(x: 14.82, y: 18), controlPoint1: NSPoint(x: 12.73, y: 19), controlPoint2: NSPoint(x: 13.87, y: 18.63))
mainPath.line(to: NSPoint(x: 8.18, y: 18))
mainPath.line(to: NSPoint(x: 8.18, y: 18))
mainPath.line(to: NSPoint(x: 8.18, y: 18))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.85, y: 15.02))
mainPath.curve(to: NSPoint(x: 5.58, y: 14), controlPoint1: NSPoint(x: 5.73, y: 14.7), controlPoint2: NSPoint(x: 5.64, y: 14.35))
mainPath.line(to: NSPoint(x: 5.58, y: 14))
mainPath.line(to: NSPoint(x: 24.24, y: 14))
mainPath.curve(to: NSPoint(x: 23.74, y: 15), controlPoint1: NSPoint(x: 24.12, y: 14.36), controlPoint2: NSPoint(x: 23.95, y: 14.69))
mainPath.line(to: NSPoint(x: 6.01, y: 15))
mainPath.curve(to: NSPoint(x: 5.85, y: 15.02), controlPoint1: NSPoint(x: 5.95, y: 15), controlPoint2: NSPoint(x: 5.9, y: 15.01))
mainPath.line(to: NSPoint(x: 5.85, y: 15.02))
mainPath.line(to: NSPoint(x: 5.85, y: 15.02))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.17, y: 16))
mainPath.curve(to: NSPoint(x: 20, y: 17), controlPoint1: NSPoint(x: 17.94, y: 16.63), controlPoint2: NSPoint(x: 18.93, y: 17))
mainPath.curve(to: NSPoint(x: 22.83, y: 16), controlPoint1: NSPoint(x: 21.07, y: 17), controlPoint2: NSPoint(x: 22.06, y: 16.63))
mainPath.line(to: NSPoint(x: 17.17, y: 16))
mainPath.line(to: NSPoint(x: 17.17, y: 16))
mainPath.line(to: NSPoint(x: 17.17, y: 16))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.5, y: 13))
mainPath.curve(to: NSPoint(x: 5.58, y: 12), controlPoint1: NSPoint(x: 5.5, y: 12.66), controlPoint2: NSPoint(x: 5.53, y: 12.33))
mainPath.line(to: NSPoint(x: 5.58, y: 12))
mainPath.line(to: NSPoint(x: 24.47, y: 12))
mainPath.curve(to: NSPoint(x: 24.5, y: 12.5), controlPoint1: NSPoint(x: 24.49, y: 12.16), controlPoint2: NSPoint(x: 24.5, y: 12.33))
mainPath.curve(to: NSPoint(x: 24.47, y: 13), controlPoint1: NSPoint(x: 24.5, y: 12.67), controlPoint2: NSPoint(x: 24.49, y: 12.84))
mainPath.line(to: NSPoint(x: 5.5, y: 13))
mainPath.line(to: NSPoint(x: 5.5, y: 13))
mainPath.line(to: NSPoint(x: 5.5, y: 13))
mainPath.close()
mainPath.move(to: NSPoint(x: 3.88, y: 11.02))
mainPath.curve(to: NSPoint(x: 3.04, y: 10), controlPoint1: NSPoint(x: 3.54, y: 10.73), controlPoint2: NSPoint(x: 3.26, y: 10.38))
mainPath.line(to: NSPoint(x: 3.04, y: 10))
mainPath.line(to: NSPoint(x: 26.96, y: 10))
mainPath.curve(to: NSPoint(x: 26.12, y: 11.02), controlPoint1: NSPoint(x: 26.74, y: 10.38), controlPoint2: NSPoint(x: 26.46, y: 10.73))
mainPath.curve(to: NSPoint(x: 26, y: 11), controlPoint1: NSPoint(x: 26.08, y: 11.01), controlPoint2: NSPoint(x: 26.04, y: 11))
mainPath.line(to: NSPoint(x: 4, y: 11))
mainPath.curve(to: NSPoint(x: 3.88, y: 11.02), controlPoint1: NSPoint(x: 3.96, y: 11), controlPoint2: NSPoint(x: 3.92, y: 11.01))
mainPath.line(to: NSPoint(x: 3.88, y: 11.02))
mainPath.line(to: NSPoint(x: 3.88, y: 11.02))
mainPath.close()
mainPath.move(to: NSPoint(x: 3.86, y: 5))
mainPath.curve(to: NSPoint(x: 6.5, y: 4), controlPoint1: NSPoint(x: 4.56, y: 4.38), controlPoint2: NSPoint(x: 5.49, y: 4))
mainPath.line(to: NSPoint(x: 23.5, y: 4))
mainPath.curve(to: NSPoint(x: 26.14, y: 5), controlPoint1: NSPoint(x: 24.51, y: 4), controlPoint2: NSPoint(x: 25.44, y: 4.38))
mainPath.line(to: NSPoint(x: 3.86, y: 5))
mainPath.line(to: NSPoint(x: 3.86, y: 5))
mainPath.line(to: NSPoint(x: 3.86, y: 5))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.5, y: 17.4))
mainPath.curve(to: NSPoint(x: 22.5, y: 17.5), controlPoint1: NSPoint(x: 22.5, y: 17.43), controlPoint2: NSPoint(x: 22.5, y: 17.47))
mainPath.curve(to: NSPoint(x: 18, y: 22), controlPoint1: NSPoint(x: 22.5, y: 19.99), controlPoint2: NSPoint(x: 20.49, y: 22))
mainPath.curve(to: NSPoint(x: 13.99, y: 19.54), controlPoint1: NSPoint(x: 16.25, y: 22), controlPoint2: NSPoint(x: 14.73, y: 21))
mainPath.curve(to: NSPoint(x: 17.11, y: 17.18), controlPoint1: NSPoint(x: 15.24, y: 19.07), controlPoint2: NSPoint(x: 16.32, y: 18.24))
mainPath.curve(to: NSPoint(x: 20, y: 18), controlPoint1: NSPoint(x: 17.95, y: 17.7), controlPoint2: NSPoint(x: 18.94, y: 18))
mainPath.curve(to: NSPoint(x: 22.5, y: 17.4), controlPoint1: NSPoint(x: 20.9, y: 18), controlPoint2: NSPoint(x: 21.75, y: 17.78))
mainPath.line(to: NSPoint(x: 22.5, y: 17.4))
mainPath.line(to: NSPoint(x: 22.5, y: 17.4))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 27))
mainPath.curve(to: NSPoint(x: 17.5, y: 26.5), controlPoint1: NSPoint(x: 17.72, y: 27), controlPoint2: NSPoint(x: 17.5, y: 26.78))
mainPath.line(to: NSPoint(x: 17.5, y: 24.5))
mainPath.curve(to: NSPoint(x: 18, y: 24), controlPoint1: NSPoint(x: 17.5, y: 24.22), controlPoint2: NSPoint(x: 17.73, y: 24))
mainPath.curve(to: NSPoint(x: 18.5, y: 24.5), controlPoint1: NSPoint(x: 18.28, y: 24), controlPoint2: NSPoint(x: 18.5, y: 24.22))
mainPath.line(to: NSPoint(x: 18.5, y: 26.5))
mainPath.curve(to: NSPoint(x: 18, y: 27), controlPoint1: NSPoint(x: 18.5, y: 26.78), controlPoint2: NSPoint(x: 18.27, y: 27))
mainPath.line(to: NSPoint(x: 18, y: 27))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.73, y: 24.21))
mainPath.curve(to: NSPoint(x: 24.03, y: 24.21), controlPoint1: NSPoint(x: 24.54, y: 24.41), controlPoint2: NSPoint(x: 24.23, y: 24.41))
mainPath.line(to: NSPoint(x: 22.61, y: 22.79))
mainPath.curve(to: NSPoint(x: 22.61, y: 22.09), controlPoint1: NSPoint(x: 22.42, y: 22.6), controlPoint2: NSPoint(x: 22.42, y: 22.28))
mainPath.curve(to: NSPoint(x: 23.32, y: 22.09), controlPoint1: NSPoint(x: 22.81, y: 21.89), controlPoint2: NSPoint(x: 23.12, y: 21.89))
mainPath.line(to: NSPoint(x: 24.74, y: 23.51))
mainPath.curve(to: NSPoint(x: 24.73, y: 24.21), controlPoint1: NSPoint(x: 24.93, y: 23.7), controlPoint2: NSPoint(x: 24.92, y: 24.02))
mainPath.line(to: NSPoint(x: 24.73, y: 24.21))
mainPath.close()
mainPath.move(to: NSPoint(x: 27.52, y: 17.48))
mainPath.curve(to: NSPoint(x: 27.03, y: 17.98), controlPoint1: NSPoint(x: 27.52, y: 17.75), controlPoint2: NSPoint(x: 27.31, y: 17.98))
mainPath.line(to: NSPoint(x: 25.02, y: 17.98))
mainPath.curve(to: NSPoint(x: 24.52, y: 17.48), controlPoint1: NSPoint(x: 24.74, y: 17.98), controlPoint2: NSPoint(x: 24.52, y: 17.75))
mainPath.curve(to: NSPoint(x: 25.02, y: 16.98), controlPoint1: NSPoint(x: 24.52, y: 17.2), controlPoint2: NSPoint(x: 24.74, y: 16.98))
mainPath.line(to: NSPoint(x: 27.03, y: 16.98))
mainPath.curve(to: NSPoint(x: 27.52, y: 17.48), controlPoint1: NSPoint(x: 27.3, y: 16.98), controlPoint2: NSPoint(x: 27.52, y: 17.21))
mainPath.line(to: NSPoint(x: 27.52, y: 17.48))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.27, y: 24.21))
mainPath.curve(to: NSPoint(x: 11.26, y: 23.51), controlPoint1: NSPoint(x: 11.07, y: 24.02), controlPoint2: NSPoint(x: 11.07, y: 23.7))
mainPath.line(to: NSPoint(x: 12.68, y: 22.09))
mainPath.curve(to: NSPoint(x: 13.39, y: 22.09), controlPoint1: NSPoint(x: 12.88, y: 21.89), controlPoint2: NSPoint(x: 13.2, y: 21.9))
mainPath.curve(to: NSPoint(x: 13.39, y: 22.79), controlPoint1: NSPoint(x: 13.58, y: 22.29), controlPoint2: NSPoint(x: 13.59, y: 22.6))
mainPath.line(to: NSPoint(x: 11.97, y: 24.21))
mainPath.curve(to: NSPoint(x: 11.27, y: 24.21), controlPoint1: NSPoint(x: 11.78, y: 24.41), controlPoint2: NSPoint(x: 11.46, y: 24.4))
mainPath.line(to: NSPoint(x: 11.27, y: 24.21))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCloudMoonFog(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 28.49, y: 8.12))
mainPath.curve(to: NSPoint(x: 28.5, y: 8.5), controlPoint1: NSPoint(x: 28.5, y: 8.24), controlPoint2: NSPoint(x: 28.5, y: 8.37))
mainPath.curve(to: NSPoint(x: 25.5, y: 13.09), controlPoint1: NSPoint(x: 28.5, y: 10.55), controlPoint2: NSPoint(x: 27.27, y: 12.31))
mainPath.curve(to: NSPoint(x: 23.77, y: 17), controlPoint1: NSPoint(x: 25.48, y: 14.63), controlPoint2: NSPoint(x: 24.82, y: 16.02))
mainPath.line(to: NSPoint(x: 23.77, y: 17))
mainPath.curve(to: NSPoint(x: 25.34, y: 19.66), controlPoint1: NSPoint(x: 24.53, y: 17.71), controlPoint2: NSPoint(x: 25.08, y: 18.63))
mainPath.curve(to: NSPoint(x: 25.49, y: 20.75), controlPoint1: NSPoint(x: 25.42, y: 20.01), controlPoint2: NSPoint(x: 25.48, y: 20.38))
mainPath.curve(to: NSPoint(x: 24, y: 20.5), controlPoint1: NSPoint(x: 25.03, y: 20.59), controlPoint2: NSPoint(x: 24.52, y: 20.5))
mainPath.curve(to: NSPoint(x: 19.5, y: 25), controlPoint1: NSPoint(x: 21.51, y: 20.5), controlPoint2: NSPoint(x: 19.5, y: 22.51))
mainPath.curve(to: NSPoint(x: 19.75, y: 26.49), controlPoint1: NSPoint(x: 19.5, y: 25.52), controlPoint2: NSPoint(x: 19.59, y: 26.03))
mainPath.curve(to: NSPoint(x: 18.66, y: 26.34), controlPoint1: NSPoint(x: 19.38, y: 26.48), controlPoint2: NSPoint(x: 19.01, y: 26.42))
mainPath.curve(to: NSPoint(x: 14.5, y: 21), controlPoint1: NSPoint(x: 16.27, y: 25.74), controlPoint2: NSPoint(x: 14.5, y: 23.58))
mainPath.curve(to: NSPoint(x: 14.64, y: 19.76), controlPoint1: NSPoint(x: 14.5, y: 20.57), controlPoint2: NSPoint(x: 14.55, y: 20.16))
mainPath.curve(to: NSPoint(x: 11.5, y: 20.5), controlPoint1: NSPoint(x: 13.7, y: 20.23), controlPoint2: NSPoint(x: 12.63, y: 20.5))
mainPath.curve(to: NSPoint(x: 4.53, y: 14.17), controlPoint1: NSPoint(x: 7.86, y: 20.5), controlPoint2: NSPoint(x: 4.87, y: 17.72))
mainPath.line(to: NSPoint(x: 4.53, y: 14.17))
mainPath.curve(to: NSPoint(x: 4.5, y: 14), controlPoint1: NSPoint(x: 4.51, y: 14.12), controlPoint2: NSPoint(x: 4.5, y: 14.06))
mainPath.curve(to: NSPoint(x: 4.51, y: 13.9), controlPoint1: NSPoint(x: 4.5, y: 13.96), controlPoint2: NSPoint(x: 4.5, y: 13.93))
mainPath.curve(to: NSPoint(x: 4.5, y: 13.5), controlPoint1: NSPoint(x: 4.5, y: 13.76), controlPoint2: NSPoint(x: 4.5, y: 13.63))
mainPath.curve(to: NSPoint(x: 4.51, y: 13.09), controlPoint1: NSPoint(x: 4.5, y: 13.36), controlPoint2: NSPoint(x: 4.5, y: 13.22))
mainPath.curve(to: NSPoint(x: 1.5, y: 8.5), controlPoint1: NSPoint(x: 2.74, y: 12.32), controlPoint2: NSPoint(x: 1.5, y: 10.55))
mainPath.curve(to: NSPoint(x: 1.51, y: 8.12), controlPoint1: NSPoint(x: 1.5, y: 8.37), controlPoint2: NSPoint(x: 1.5, y: 8.24))
mainPath.curve(to: NSPoint(x: 1.5, y: 8), controlPoint1: NSPoint(x: 1.5, y: 8.08), controlPoint2: NSPoint(x: 1.5, y: 8.04))
mainPath.curve(to: NSPoint(x: 1.55, y: 7.78), controlPoint1: NSPoint(x: 1.5, y: 7.92), controlPoint2: NSPoint(x: 1.52, y: 7.85))
mainPath.curve(to: NSPoint(x: 6.5, y: 3.5), controlPoint1: NSPoint(x: 1.9, y: 5.36), controlPoint2: NSPoint(x: 3.98, y: 3.5))
mainPath.line(to: NSPoint(x: 23.5, y: 3.5))
mainPath.curve(to: NSPoint(x: 28.45, y: 7.78), controlPoint1: NSPoint(x: 26.02, y: 3.5), controlPoint2: NSPoint(x: 28.1, y: 5.36))
mainPath.curve(to: NSPoint(x: 28.5, y: 8), controlPoint1: NSPoint(x: 28.48, y: 7.85), controlPoint2: NSPoint(x: 28.5, y: 7.92))
mainPath.curve(to: NSPoint(x: 28.49, y: 8.12), controlPoint1: NSPoint(x: 28.5, y: 8.04), controlPoint2: NSPoint(x: 28.49, y: 8.08))
mainPath.line(to: NSPoint(x: 28.49, y: 8.12))
mainPath.close()
mainPath.move(to: NSPoint(x: 2.5, y: 8.5))
mainPath.curve(to: NSPoint(x: 2.63, y: 9.5), controlPoint1: NSPoint(x: 2.5, y: 8.85), controlPoint2: NSPoint(x: 2.54, y: 9.18))
mainPath.line(to: NSPoint(x: 2.63, y: 9.5))
mainPath.line(to: NSPoint(x: 27.37, y: 9.5))
mainPath.curve(to: NSPoint(x: 27.5, y: 8.5), controlPoint1: NSPoint(x: 27.46, y: 9.18), controlPoint2: NSPoint(x: 27.5, y: 8.85))
mainPath.line(to: NSPoint(x: 2.5, y: 8.5))
mainPath.line(to: NSPoint(x: 2.5, y: 8.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 2.63, y: 7.5))
mainPath.curve(to: NSPoint(x: 3.04, y: 6.5), controlPoint1: NSPoint(x: 2.72, y: 7.15), controlPoint2: NSPoint(x: 2.86, y: 6.81))
mainPath.line(to: NSPoint(x: 3.04, y: 6.5))
mainPath.line(to: NSPoint(x: 26.96, y: 6.5))
mainPath.curve(to: NSPoint(x: 27.37, y: 7.5), controlPoint1: NSPoint(x: 27.14, y: 6.81), controlPoint2: NSPoint(x: 27.28, y: 7.15))
mainPath.line(to: NSPoint(x: 2.63, y: 7.5))
mainPath.line(to: NSPoint(x: 2.63, y: 7.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 7.03, y: 17.5))
mainPath.curve(to: NSPoint(x: 6.3, y: 16.5), controlPoint1: NSPoint(x: 6.75, y: 17.19), controlPoint2: NSPoint(x: 6.51, y: 16.86))
mainPath.line(to: NSPoint(x: 6.3, y: 16.5))
mainPath.line(to: NSPoint(x: 16.7, y: 16.5))
mainPath.curve(to: NSPoint(x: 15.97, y: 17.5), controlPoint1: NSPoint(x: 16.49, y: 16.86), controlPoint2: NSPoint(x: 16.25, y: 17.19))
mainPath.line(to: NSPoint(x: 7.03, y: 17.5))
mainPath.line(to: NSPoint(x: 7.03, y: 17.5))
mainPath.line(to: NSPoint(x: 7.03, y: 17.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.18, y: 18.5))
mainPath.curve(to: NSPoint(x: 11.5, y: 19.5), controlPoint1: NSPoint(x: 9.13, y: 19.13), controlPoint2: NSPoint(x: 10.27, y: 19.5))
mainPath.curve(to: NSPoint(x: 14.82, y: 18.5), controlPoint1: NSPoint(x: 12.73, y: 19.5), controlPoint2: NSPoint(x: 13.87, y: 19.13))
mainPath.line(to: NSPoint(x: 8.18, y: 18.5))
mainPath.line(to: NSPoint(x: 8.18, y: 18.5))
mainPath.line(to: NSPoint(x: 8.18, y: 18.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.85, y: 15.52))
mainPath.curve(to: NSPoint(x: 5.58, y: 14.5), controlPoint1: NSPoint(x: 5.73, y: 15.2), controlPoint2: NSPoint(x: 5.64, y: 14.85))
mainPath.line(to: NSPoint(x: 5.58, y: 14.5))
mainPath.line(to: NSPoint(x: 24.24, y: 14.5))
mainPath.curve(to: NSPoint(x: 23.74, y: 15.5), controlPoint1: NSPoint(x: 24.12, y: 14.86), controlPoint2: NSPoint(x: 23.95, y: 15.19))
mainPath.line(to: NSPoint(x: 6.01, y: 15.5))
mainPath.curve(to: NSPoint(x: 5.85, y: 15.52), controlPoint1: NSPoint(x: 5.95, y: 15.5), controlPoint2: NSPoint(x: 5.9, y: 15.51))
mainPath.line(to: NSPoint(x: 5.85, y: 15.52))
mainPath.line(to: NSPoint(x: 5.85, y: 15.52))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.17, y: 16.5))
mainPath.curve(to: NSPoint(x: 20, y: 17.5), controlPoint1: NSPoint(x: 17.94, y: 17.13), controlPoint2: NSPoint(x: 18.93, y: 17.5))
mainPath.curve(to: NSPoint(x: 22.83, y: 16.5), controlPoint1: NSPoint(x: 21.07, y: 17.5), controlPoint2: NSPoint(x: 22.06, y: 17.13))
mainPath.line(to: NSPoint(x: 17.17, y: 16.5))
mainPath.line(to: NSPoint(x: 17.17, y: 16.5))
mainPath.line(to: NSPoint(x: 17.17, y: 16.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.5, y: 13.5))
mainPath.curve(to: NSPoint(x: 5.58, y: 12.5), controlPoint1: NSPoint(x: 5.5, y: 13.16), controlPoint2: NSPoint(x: 5.53, y: 12.83))
mainPath.line(to: NSPoint(x: 5.58, y: 12.5))
mainPath.line(to: NSPoint(x: 24.47, y: 12.5))
mainPath.curve(to: NSPoint(x: 24.5, y: 13), controlPoint1: NSPoint(x: 24.49, y: 12.66), controlPoint2: NSPoint(x: 24.5, y: 12.83))
mainPath.curve(to: NSPoint(x: 24.47, y: 13.5), controlPoint1: NSPoint(x: 24.5, y: 13.17), controlPoint2: NSPoint(x: 24.49, y: 13.34))
mainPath.line(to: NSPoint(x: 5.5, y: 13.5))
mainPath.line(to: NSPoint(x: 5.5, y: 13.5))
mainPath.line(to: NSPoint(x: 5.5, y: 13.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 3.88, y: 11.52))
mainPath.curve(to: NSPoint(x: 3.04, y: 10.5), controlPoint1: NSPoint(x: 3.54, y: 11.23), controlPoint2: NSPoint(x: 3.26, y: 10.88))
mainPath.line(to: NSPoint(x: 3.04, y: 10.5))
mainPath.line(to: NSPoint(x: 26.96, y: 10.5))
mainPath.curve(to: NSPoint(x: 26.12, y: 11.52), controlPoint1: NSPoint(x: 26.74, y: 10.88), controlPoint2: NSPoint(x: 26.46, y: 11.23))
mainPath.curve(to: NSPoint(x: 26, y: 11.5), controlPoint1: NSPoint(x: 26.08, y: 11.51), controlPoint2: NSPoint(x: 26.04, y: 11.5))
mainPath.line(to: NSPoint(x: 4, y: 11.5))
mainPath.curve(to: NSPoint(x: 3.88, y: 11.52), controlPoint1: NSPoint(x: 3.96, y: 11.5), controlPoint2: NSPoint(x: 3.92, y: 11.51))
mainPath.line(to: NSPoint(x: 3.88, y: 11.52))
mainPath.line(to: NSPoint(x: 3.88, y: 11.52))
mainPath.close()
mainPath.move(to: NSPoint(x: 3.86, y: 5.5))
mainPath.curve(to: NSPoint(x: 6.5, y: 4.5), controlPoint1: NSPoint(x: 4.56, y: 4.88), controlPoint2: NSPoint(x: 5.49, y: 4.5))
mainPath.line(to: NSPoint(x: 23.5, y: 4.5))
mainPath.curve(to: NSPoint(x: 26.14, y: 5.5), controlPoint1: NSPoint(x: 24.51, y: 4.5), controlPoint2: NSPoint(x: 25.44, y: 4.88))
mainPath.line(to: NSPoint(x: 3.86, y: 5.5))
mainPath.line(to: NSPoint(x: 3.86, y: 5.5))
mainPath.line(to: NSPoint(x: 3.86, y: 5.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.98, y: 17.63))
mainPath.curve(to: NSPoint(x: 24.25, y: 19.51), controlPoint1: NSPoint(x: 23.55, y: 18.13), controlPoint2: NSPoint(x: 23.99, y: 18.77))
mainPath.curve(to: NSPoint(x: 24, y: 19.5), controlPoint1: NSPoint(x: 24.16, y: 19.5), controlPoint2: NSPoint(x: 24.08, y: 19.5))
mainPath.curve(to: NSPoint(x: 18.5, y: 25), controlPoint1: NSPoint(x: 20.96, y: 19.5), controlPoint2: NSPoint(x: 18.5, y: 21.96))
mainPath.curve(to: NSPoint(x: 18.51, y: 25.25), controlPoint1: NSPoint(x: 18.5, y: 25.08), controlPoint2: NSPoint(x: 18.5, y: 25.16))
mainPath.curve(to: NSPoint(x: 15.5, y: 21), controlPoint1: NSPoint(x: 16.75, y: 24.63), controlPoint2: NSPoint(x: 15.5, y: 22.96))
mainPath.curve(to: NSPoint(x: 16.07, y: 18.8), controlPoint1: NSPoint(x: 15.5, y: 20.2), controlPoint2: NSPoint(x: 15.71, y: 19.45))
mainPath.curve(to: NSPoint(x: 17.11, y: 17.68), controlPoint1: NSPoint(x: 16.46, y: 18.47), controlPoint2: NSPoint(x: 16.81, y: 18.09))
mainPath.curve(to: NSPoint(x: 20, y: 18.5), controlPoint1: NSPoint(x: 17.95, y: 18.2), controlPoint2: NSPoint(x: 18.94, y: 18.5))
mainPath.curve(to: NSPoint(x: 22.98, y: 17.63), controlPoint1: NSPoint(x: 21.1, y: 18.5), controlPoint2: NSPoint(x: 22.12, y: 18.18))
mainPath.line(to: NSPoint(x: 22.98, y: 17.63))
mainPath.line(to: NSPoint(x: 22.98, y: 17.63))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoonStars(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 16.91, y: 19.93))
mainPath.line(to: NSPoint(x: 15.7, y: 16.69))
mainPath.line(to: NSPoint(x: 14.49, y: 19.93))
mainPath.line(to: NSPoint(x: 12.2, y: 20.69))
mainPath.line(to: NSPoint(x: 14.49, y: 21.46))
mainPath.line(to: NSPoint(x: 15.7, y: 24.69))
mainPath.line(to: NSPoint(x: 16.91, y: 21.46))
mainPath.line(to: NSPoint(x: 19.2, y: 20.69))
mainPath.line(to: NSPoint(x: 16.91, y: 19.93))
mainPath.line(to: NSPoint(x: 16.91, y: 19.93))
mainPath.line(to: NSPoint(x: 16.91, y: 19.93))
mainPath.close()
mainPath.move(to: NSPoint(x: 20.91, y: 13.46))
mainPath.line(to: NSPoint(x: 19.7, y: 16.69))
mainPath.line(to: NSPoint(x: 18.49, y: 13.46))
mainPath.line(to: NSPoint(x: 16.2, y: 12.69))
mainPath.line(to: NSPoint(x: 18.49, y: 11.93))
mainPath.line(to: NSPoint(x: 19.7, y: 8.69))
mainPath.line(to: NSPoint(x: 20.91, y: 11.93))
mainPath.line(to: NSPoint(x: 23.2, y: 12.69))
mainPath.line(to: NSPoint(x: 20.91, y: 13.46))
mainPath.line(to: NSPoint(x: 20.91, y: 13.46))
mainPath.line(to: NSPoint(x: 20.91, y: 13.46))
mainPath.close()
mainPath.move(to: NSPoint(x: 13.54, y: 9.36))
mainPath.curve(to: NSPoint(x: 8.2, y: 5.2), controlPoint1: NSPoint(x: 12.94, y: 6.97), controlPoint2: NSPoint(x: 10.78, y: 5.2))
mainPath.curve(to: NSPoint(x: 2.7, y: 10.7), controlPoint1: NSPoint(x: 5.16, y: 5.2), controlPoint2: NSPoint(x: 2.7, y: 7.66))
mainPath.curve(to: NSPoint(x: 6.86, y: 16.04), controlPoint1: NSPoint(x: 2.7, y: 13.28), controlPoint2: NSPoint(x: 4.47, y: 15.44))
mainPath.curve(to: NSPoint(x: 7.95, y: 16.19), controlPoint1: NSPoint(x: 7.21, y: 16.12), controlPoint2: NSPoint(x: 7.58, y: 16.18))
mainPath.curve(to: NSPoint(x: 7.7, y: 14.7), controlPoint1: NSPoint(x: 7.79, y: 15.73), controlPoint2: NSPoint(x: 7.7, y: 15.22))
mainPath.curve(to: NSPoint(x: 12.2, y: 10.2), controlPoint1: NSPoint(x: 7.7, y: 12.21), controlPoint2: NSPoint(x: 9.71, y: 10.2))
mainPath.curve(to: NSPoint(x: 13.69, y: 10.45), controlPoint1: NSPoint(x: 12.72, y: 10.2), controlPoint2: NSPoint(x: 13.23, y: 10.29))
mainPath.curve(to: NSPoint(x: 13.54, y: 9.36), controlPoint1: NSPoint(x: 13.68, y: 10.08), controlPoint2: NSPoint(x: 13.62, y: 9.71))
mainPath.line(to: NSPoint(x: 13.54, y: 9.36))
mainPath.close()
mainPath.move(to: NSPoint(x: 3.7, y: 10.7))
mainPath.curve(to: NSPoint(x: 6.71, y: 14.95), controlPoint1: NSPoint(x: 3.7, y: 12.66), controlPoint2: NSPoint(x: 4.95, y: 14.33))
mainPath.curve(to: NSPoint(x: 6.7, y: 14.7), controlPoint1: NSPoint(x: 6.7, y: 14.86), controlPoint2: NSPoint(x: 6.7, y: 14.78))
mainPath.curve(to: NSPoint(x: 12.2, y: 9.2), controlPoint1: NSPoint(x: 6.7, y: 11.66), controlPoint2: NSPoint(x: 9.16, y: 9.2))
mainPath.curve(to: NSPoint(x: 12.45, y: 9.21), controlPoint1: NSPoint(x: 12.28, y: 9.2), controlPoint2: NSPoint(x: 12.36, y: 9.2))
mainPath.curve(to: NSPoint(x: 8.2, y: 6.2), controlPoint1: NSPoint(x: 11.83, y: 7.45), controlPoint2: NSPoint(x: 10.16, y: 6.2))
mainPath.curve(to: NSPoint(x: 3.7, y: 10.7), controlPoint1: NSPoint(x: 5.71, y: 6.2), controlPoint2: NSPoint(x: 3.7, y: 8.21))
mainPath.line(to: NSPoint(x: 3.7, y: 10.7))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.57, y: 19.27))
mainPath.line(to: NSPoint(x: 27.2, y: 18.69))
mainPath.line(to: NSPoint(x: 25.57, y: 18.12))
mainPath.line(to: NSPoint(x: 24.7, y: 15.69))
mainPath.line(to: NSPoint(x: 23.83, y: 18.12))
mainPath.line(to: NSPoint(x: 22.2, y: 18.69))
mainPath.line(to: NSPoint(x: 23.83, y: 19.27))
mainPath.line(to: NSPoint(x: 24.7, y: 21.69))
mainPath.line(to: NSPoint(x: 25.57, y: 19.27))
mainPath.line(to: NSPoint(x: 25.57, y: 19.27))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoon(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 20.34, y: 13.66))
mainPath.curve(to: NSPoint(x: 15, y: 9.5), controlPoint1: NSPoint(x: 19.74, y: 11.27), controlPoint2: NSPoint(x: 17.58, y: 9.5))
mainPath.curve(to: NSPoint(x: 9.5, y: 15), controlPoint1: NSPoint(x: 11.96, y: 9.5), controlPoint2: NSPoint(x: 9.5, y: 11.96))
mainPath.curve(to: NSPoint(x: 13.66, y: 20.34), controlPoint1: NSPoint(x: 9.5, y: 17.58), controlPoint2: NSPoint(x: 11.27, y: 19.74))
mainPath.curve(to: NSPoint(x: 14.75, y: 20.49), controlPoint1: NSPoint(x: 14.01, y: 20.42), controlPoint2: NSPoint(x: 14.38, y: 20.48))
mainPath.curve(to: NSPoint(x: 14.5, y: 19), controlPoint1: NSPoint(x: 14.59, y: 20.03), controlPoint2: NSPoint(x: 14.5, y: 19.52))
mainPath.curve(to: NSPoint(x: 19, y: 14.5), controlPoint1: NSPoint(x: 14.5, y: 16.51), controlPoint2: NSPoint(x: 16.51, y: 14.5))
mainPath.curve(to: NSPoint(x: 20.49, y: 14.75), controlPoint1: NSPoint(x: 19.52, y: 14.5), controlPoint2: NSPoint(x: 20.03, y: 14.59))
mainPath.curve(to: NSPoint(x: 20.34, y: 13.66), controlPoint1: NSPoint(x: 20.48, y: 14.38), controlPoint2: NSPoint(x: 20.42, y: 14.01))
mainPath.line(to: NSPoint(x: 20.34, y: 13.66))
mainPath.close()
mainPath.move(to: NSPoint(x: 10.5, y: 15))
mainPath.curve(to: NSPoint(x: 13.51, y: 19.25), controlPoint1: NSPoint(x: 10.5, y: 16.96), controlPoint2: NSPoint(x: 11.75, y: 18.63))
mainPath.curve(to: NSPoint(x: 13.5, y: 19), controlPoint1: NSPoint(x: 13.5, y: 19.16), controlPoint2: NSPoint(x: 13.5, y: 19.08))
mainPath.curve(to: NSPoint(x: 19, y: 13.5), controlPoint1: NSPoint(x: 13.5, y: 15.96), controlPoint2: NSPoint(x: 15.96, y: 13.5))
mainPath.curve(to: NSPoint(x: 19.25, y: 13.51), controlPoint1: NSPoint(x: 19.08, y: 13.5), controlPoint2: NSPoint(x: 19.16, y: 13.5))
mainPath.curve(to: NSPoint(x: 15, y: 10.5), controlPoint1: NSPoint(x: 18.63, y: 11.75), controlPoint2: NSPoint(x: 16.96, y: 10.5))
mainPath.curve(to: NSPoint(x: 10.5, y: 15), controlPoint1: NSPoint(x: 12.51, y: 10.5), controlPoint2: NSPoint(x: 10.5, y: 12.51))
mainPath.line(to: NSPoint(x: 10.5, y: 15))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawSun(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15.03, y: 9.56))
mainPath.curve(to: NSPoint(x: 20.53, y: 15.06), controlPoint1: NSPoint(x: 18.07, y: 9.56), controlPoint2: NSPoint(x: 20.53, y: 12.02))
mainPath.curve(to: NSPoint(x: 15.03, y: 20.56), controlPoint1: NSPoint(x: 20.53, y: 18.1), controlPoint2: NSPoint(x: 18.07, y: 20.56))
mainPath.curve(to: NSPoint(x: 9.53, y: 15.06), controlPoint1: NSPoint(x: 11.99, y: 20.56), controlPoint2: NSPoint(x: 9.53, y: 18.1))
mainPath.curve(to: NSPoint(x: 15.03, y: 9.56), controlPoint1: NSPoint(x: 9.53, y: 12.02), controlPoint2: NSPoint(x: 11.99, y: 9.56))
mainPath.line(to: NSPoint(x: 15.03, y: 9.56))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.03, y: 10.56))
mainPath.curve(to: NSPoint(x: 19.53, y: 15.06), controlPoint1: NSPoint(x: 17.51, y: 10.56), controlPoint2: NSPoint(x: 19.53, y: 12.57))
mainPath.curve(to: NSPoint(x: 15.03, y: 19.56), controlPoint1: NSPoint(x: 19.53, y: 17.54), controlPoint2: NSPoint(x: 17.51, y: 19.56))
mainPath.curve(to: NSPoint(x: 10.53, y: 15.06), controlPoint1: NSPoint(x: 12.54, y: 19.56), controlPoint2: NSPoint(x: 10.53, y: 17.54))
mainPath.curve(to: NSPoint(x: 15.03, y: 10.56), controlPoint1: NSPoint(x: 10.53, y: 12.57), controlPoint2: NSPoint(x: 12.54, y: 10.56))
mainPath.line(to: NSPoint(x: 15.03, y: 10.56))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.03, y: 24.56))
mainPath.curve(to: NSPoint(x: 14.53, y: 24.06), controlPoint1: NSPoint(x: 14.75, y: 24.56), controlPoint2: NSPoint(x: 14.53, y: 24.34))
mainPath.line(to: NSPoint(x: 14.53, y: 22.05))
mainPath.curve(to: NSPoint(x: 15.03, y: 21.56), controlPoint1: NSPoint(x: 14.53, y: 21.78), controlPoint2: NSPoint(x: 14.76, y: 21.56))
mainPath.curve(to: NSPoint(x: 15.53, y: 22.05), controlPoint1: NSPoint(x: 15.31, y: 21.56), controlPoint2: NSPoint(x: 15.53, y: 21.77))
mainPath.line(to: NSPoint(x: 15.53, y: 24.06))
mainPath.curve(to: NSPoint(x: 15.03, y: 24.56), controlPoint1: NSPoint(x: 15.53, y: 24.34), controlPoint2: NSPoint(x: 15.3, y: 24.56))
mainPath.line(to: NSPoint(x: 15.03, y: 24.56))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.77, y: 21.77))
mainPath.curve(to: NSPoint(x: 21.06, y: 21.77), controlPoint1: NSPoint(x: 21.57, y: 21.96), controlPoint2: NSPoint(x: 21.26, y: 21.97))
mainPath.line(to: NSPoint(x: 19.64, y: 20.35))
mainPath.curve(to: NSPoint(x: 19.65, y: 19.65), controlPoint1: NSPoint(x: 19.45, y: 20.16), controlPoint2: NSPoint(x: 19.46, y: 19.84))
mainPath.curve(to: NSPoint(x: 20.35, y: 19.64), controlPoint1: NSPoint(x: 19.84, y: 19.45), controlPoint2: NSPoint(x: 20.15, y: 19.44))
mainPath.line(to: NSPoint(x: 21.77, y: 21.06))
mainPath.curve(to: NSPoint(x: 21.77, y: 21.77), controlPoint1: NSPoint(x: 21.96, y: 21.26), controlPoint2: NSPoint(x: 21.96, y: 21.58))
mainPath.line(to: NSPoint(x: 21.77, y: 21.77))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.56, y: 15.03))
mainPath.curve(to: NSPoint(x: 24.06, y: 15.53), controlPoint1: NSPoint(x: 24.56, y: 15.31), controlPoint2: NSPoint(x: 24.34, y: 15.53))
mainPath.line(to: NSPoint(x: 22.05, y: 15.53))
mainPath.curve(to: NSPoint(x: 21.56, y: 15.03), controlPoint1: NSPoint(x: 21.78, y: 15.53), controlPoint2: NSPoint(x: 21.56, y: 15.3))
mainPath.curve(to: NSPoint(x: 22.05, y: 14.53), controlPoint1: NSPoint(x: 21.56, y: 14.75), controlPoint2: NSPoint(x: 21.77, y: 14.53))
mainPath.line(to: NSPoint(x: 24.06, y: 14.53))
mainPath.curve(to: NSPoint(x: 24.56, y: 15.03), controlPoint1: NSPoint(x: 24.34, y: 14.53), controlPoint2: NSPoint(x: 24.56, y: 14.76))
mainPath.line(to: NSPoint(x: 24.56, y: 15.03))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.77, y: 8.29))
mainPath.curve(to: NSPoint(x: 21.77, y: 8.99), controlPoint1: NSPoint(x: 21.96, y: 8.49), controlPoint2: NSPoint(x: 21.97, y: 8.8))
mainPath.line(to: NSPoint(x: 20.35, y: 10.42))
mainPath.curve(to: NSPoint(x: 19.65, y: 10.41), controlPoint1: NSPoint(x: 20.16, y: 10.61), controlPoint2: NSPoint(x: 19.84, y: 10.6))
mainPath.curve(to: NSPoint(x: 19.64, y: 9.71), controlPoint1: NSPoint(x: 19.45, y: 10.22), controlPoint2: NSPoint(x: 19.44, y: 9.91))
mainPath.line(to: NSPoint(x: 21.06, y: 8.29))
mainPath.curve(to: NSPoint(x: 21.77, y: 8.29), controlPoint1: NSPoint(x: 21.26, y: 8.09), controlPoint2: NSPoint(x: 21.58, y: 8.1))
mainPath.line(to: NSPoint(x: 21.77, y: 8.29))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.03, y: 5.5))
mainPath.curve(to: NSPoint(x: 15.53, y: 6), controlPoint1: NSPoint(x: 15.31, y: 5.5), controlPoint2: NSPoint(x: 15.53, y: 5.72))
mainPath.line(to: NSPoint(x: 15.53, y: 8))
mainPath.curve(to: NSPoint(x: 15.03, y: 8.5), controlPoint1: NSPoint(x: 15.53, y: 8.28), controlPoint2: NSPoint(x: 15.3, y: 8.5))
mainPath.curve(to: NSPoint(x: 14.53, y: 8), controlPoint1: NSPoint(x: 14.75, y: 8.5), controlPoint2: NSPoint(x: 14.53, y: 8.28))
mainPath.line(to: NSPoint(x: 14.53, y: 6))
mainPath.curve(to: NSPoint(x: 15.03, y: 5.5), controlPoint1: NSPoint(x: 14.53, y: 5.72), controlPoint2: NSPoint(x: 14.76, y: 5.5))
mainPath.line(to: NSPoint(x: 15.03, y: 5.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.29, y: 8.29))
mainPath.curve(to: NSPoint(x: 8.99, y: 8.29), controlPoint1: NSPoint(x: 8.49, y: 8.1), controlPoint2: NSPoint(x: 8.8, y: 8.09))
mainPath.line(to: NSPoint(x: 10.42, y: 9.71))
mainPath.curve(to: NSPoint(x: 10.41, y: 10.41), controlPoint1: NSPoint(x: 10.61, y: 9.9), controlPoint2: NSPoint(x: 10.6, y: 10.22))
mainPath.curve(to: NSPoint(x: 9.71, y: 10.42), controlPoint1: NSPoint(x: 10.22, y: 10.61), controlPoint2: NSPoint(x: 9.91, y: 10.61))
mainPath.line(to: NSPoint(x: 8.29, y: 8.99))
mainPath.curve(to: NSPoint(x: 8.29, y: 8.29), controlPoint1: NSPoint(x: 8.09, y: 8.8), controlPoint2: NSPoint(x: 8.1, y: 8.48))
mainPath.line(to: NSPoint(x: 8.29, y: 8.29))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.5, y: 15.03))
mainPath.curve(to: NSPoint(x: 6, y: 14.53), controlPoint1: NSPoint(x: 5.5, y: 14.75), controlPoint2: NSPoint(x: 5.72, y: 14.53))
mainPath.line(to: NSPoint(x: 8, y: 14.53))
mainPath.curve(to: NSPoint(x: 8.5, y: 15.03), controlPoint1: NSPoint(x: 8.28, y: 14.53), controlPoint2: NSPoint(x: 8.5, y: 14.76))
mainPath.curve(to: NSPoint(x: 8, y: 15.53), controlPoint1: NSPoint(x: 8.5, y: 15.31), controlPoint2: NSPoint(x: 8.28, y: 15.53))
mainPath.line(to: NSPoint(x: 6, y: 15.53))
mainPath.curve(to: NSPoint(x: 5.5, y: 15.03), controlPoint1: NSPoint(x: 5.72, y: 15.53), controlPoint2: NSPoint(x: 5.5, y: 15.3))
mainPath.line(to: NSPoint(x: 5.5, y: 15.03))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.29, y: 21.77))
mainPath.curve(to: NSPoint(x: 8.29, y: 21.06), controlPoint1: NSPoint(x: 8.1, y: 21.57), controlPoint2: NSPoint(x: 8.09, y: 21.26))
mainPath.line(to: NSPoint(x: 9.71, y: 19.64))
mainPath.curve(to: NSPoint(x: 10.41, y: 19.65), controlPoint1: NSPoint(x: 9.9, y: 19.45), controlPoint2: NSPoint(x: 10.22, y: 19.46))
mainPath.curve(to: NSPoint(x: 10.42, y: 20.35), controlPoint1: NSPoint(x: 10.61, y: 19.84), controlPoint2: NSPoint(x: 10.61, y: 20.15))
mainPath.line(to: NSPoint(x: 8.99, y: 21.77))
mainPath.curve(to: NSPoint(x: 8.29, y: 21.77), controlPoint1: NSPoint(x: 8.8, y: 21.96), controlPoint2: NSPoint(x: 8.48, y: 21.96))
mainPath.line(to: NSPoint(x: 8.29, y: 21.77))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawSunrise(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 6.04, y: 9.8))
mainPath.curve(to: NSPoint(x: 5.53, y: 9.3), controlPoint1: NSPoint(x: 5.76, y: 9.8), controlPoint2: NSPoint(x: 5.53, y: 9.57))
mainPath.curve(to: NSPoint(x: 6.04, y: 8.8), controlPoint1: NSPoint(x: 5.53, y: 9.02), controlPoint2: NSPoint(x: 5.76, y: 8.8))
mainPath.line(to: NSPoint(x: 12.11, y: 8.8))
mainPath.line(to: NSPoint(x: 13.28, y: 9.8))
mainPath.line(to: NSPoint(x: 15.03, y: 11.3))
mainPath.line(to: NSPoint(x: 16.78, y: 9.8))
mainPath.line(to: NSPoint(x: 17.95, y: 8.8))
mainPath.line(to: NSPoint(x: 24.02, y: 8.8))
mainPath.curve(to: NSPoint(x: 24.53, y: 9.3), controlPoint1: NSPoint(x: 24.3, y: 8.8), controlPoint2: NSPoint(x: 24.53, y: 9.03))
mainPath.curve(to: NSPoint(x: 24.02, y: 9.8), controlPoint1: NSPoint(x: 24.53, y: 9.58), controlPoint2: NSPoint(x: 24.3, y: 9.8))
mainPath.line(to: NSPoint(x: 18.53, y: 9.8))
mainPath.line(to: NSPoint(x: 15.03, y: 12.8))
mainPath.line(to: NSPoint(x: 11.53, y: 9.8))
mainPath.line(to: NSPoint(x: 6.04, y: 9.8))
mainPath.line(to: NSPoint(x: 6.04, y: 9.8))
mainPath.close()
mainPath.move(to: NSPoint(x: 20.48, y: 11.8))
mainPath.curve(to: NSPoint(x: 20.5, y: 12.3), controlPoint1: NSPoint(x: 20.49, y: 11.96), controlPoint2: NSPoint(x: 20.5, y: 12.13))
mainPath.curve(to: NSPoint(x: 15, y: 17.8), controlPoint1: NSPoint(x: 20.5, y: 15.34), controlPoint2: NSPoint(x: 18.04, y: 17.8))
mainPath.curve(to: NSPoint(x: 9.5, y: 12.3), controlPoint1: NSPoint(x: 11.96, y: 17.8), controlPoint2: NSPoint(x: 9.5, y: 15.34))
mainPath.curve(to: NSPoint(x: 9.52, y: 11.8), controlPoint1: NSPoint(x: 9.5, y: 12.13), controlPoint2: NSPoint(x: 9.51, y: 11.96))
mainPath.line(to: NSPoint(x: 10.53, y: 11.8))
mainPath.curve(to: NSPoint(x: 10.5, y: 12.3), controlPoint1: NSPoint(x: 10.51, y: 11.96), controlPoint2: NSPoint(x: 10.5, y: 12.13))
mainPath.curve(to: NSPoint(x: 15, y: 16.8), controlPoint1: NSPoint(x: 10.5, y: 14.79), controlPoint2: NSPoint(x: 12.51, y: 16.8))
mainPath.curve(to: NSPoint(x: 19.5, y: 12.3), controlPoint1: NSPoint(x: 17.49, y: 16.8), controlPoint2: NSPoint(x: 19.5, y: 14.79))
mainPath.curve(to: NSPoint(x: 19.47, y: 11.8), controlPoint1: NSPoint(x: 19.5, y: 12.13), controlPoint2: NSPoint(x: 19.49, y: 11.96))
mainPath.line(to: NSPoint(x: 20.48, y: 11.8))
mainPath.line(to: NSPoint(x: 20.48, y: 11.8))
mainPath.line(to: NSPoint(x: 20.48, y: 11.8))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.03, y: 21.8))
mainPath.curve(to: NSPoint(x: 14.53, y: 21.3), controlPoint1: NSPoint(x: 14.75, y: 21.8), controlPoint2: NSPoint(x: 14.53, y: 21.58))
mainPath.line(to: NSPoint(x: 14.53, y: 19.3))
mainPath.curve(to: NSPoint(x: 15.03, y: 18.8), controlPoint1: NSPoint(x: 14.53, y: 19.02), controlPoint2: NSPoint(x: 14.76, y: 18.8))
mainPath.curve(to: NSPoint(x: 15.53, y: 19.3), controlPoint1: NSPoint(x: 15.31, y: 18.8), controlPoint2: NSPoint(x: 15.53, y: 19.02))
mainPath.line(to: NSPoint(x: 15.53, y: 21.3))
mainPath.curve(to: NSPoint(x: 15.03, y: 21.8), controlPoint1: NSPoint(x: 15.53, y: 21.58), controlPoint2: NSPoint(x: 15.3, y: 21.8))
mainPath.line(to: NSPoint(x: 15.03, y: 21.8))
mainPath.line(to: NSPoint(x: 15.03, y: 21.8))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.77, y: 19.01))
mainPath.curve(to: NSPoint(x: 21.06, y: 19.01), controlPoint1: NSPoint(x: 21.57, y: 19.2), controlPoint2: NSPoint(x: 21.26, y: 19.21))
mainPath.line(to: NSPoint(x: 19.64, y: 17.59))
mainPath.curve(to: NSPoint(x: 19.65, y: 16.89), controlPoint1: NSPoint(x: 19.45, y: 17.4), controlPoint2: NSPoint(x: 19.46, y: 17.08))
mainPath.curve(to: NSPoint(x: 20.35, y: 16.88), controlPoint1: NSPoint(x: 19.84, y: 16.69), controlPoint2: NSPoint(x: 20.15, y: 16.69))
mainPath.line(to: NSPoint(x: 21.77, y: 18.31))
mainPath.curve(to: NSPoint(x: 21.77, y: 19.01), controlPoint1: NSPoint(x: 21.96, y: 18.5), controlPoint2: NSPoint(x: 21.96, y: 18.82))
mainPath.line(to: NSPoint(x: 21.77, y: 19.01))
mainPath.line(to: NSPoint(x: 21.77, y: 19.01))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.56, y: 12.27))
mainPath.curve(to: NSPoint(x: 24.06, y: 12.77), controlPoint1: NSPoint(x: 24.56, y: 12.55), controlPoint2: NSPoint(x: 24.34, y: 12.77))
mainPath.line(to: NSPoint(x: 22.05, y: 12.77))
mainPath.curve(to: NSPoint(x: 21.56, y: 12.27), controlPoint1: NSPoint(x: 21.78, y: 12.77), controlPoint2: NSPoint(x: 21.56, y: 12.54))
mainPath.curve(to: NSPoint(x: 22.05, y: 11.77), controlPoint1: NSPoint(x: 21.56, y: 11.99), controlPoint2: NSPoint(x: 21.77, y: 11.77))
mainPath.line(to: NSPoint(x: 24.06, y: 11.77))
mainPath.curve(to: NSPoint(x: 24.56, y: 12.27), controlPoint1: NSPoint(x: 24.34, y: 11.77), controlPoint2: NSPoint(x: 24.56, y: 12))
mainPath.line(to: NSPoint(x: 24.56, y: 12.27))
mainPath.line(to: NSPoint(x: 24.56, y: 12.27))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.5, y: 12.27))
mainPath.curve(to: NSPoint(x: 6, y: 11.77), controlPoint1: NSPoint(x: 5.5, y: 11.99), controlPoint2: NSPoint(x: 5.72, y: 11.77))
mainPath.line(to: NSPoint(x: 8, y: 11.77))
mainPath.curve(to: NSPoint(x: 8.5, y: 12.27), controlPoint1: NSPoint(x: 8.28, y: 11.77), controlPoint2: NSPoint(x: 8.5, y: 12))
mainPath.curve(to: NSPoint(x: 8, y: 12.77), controlPoint1: NSPoint(x: 8.5, y: 12.55), controlPoint2: NSPoint(x: 8.28, y: 12.77))
mainPath.line(to: NSPoint(x: 6, y: 12.77))
mainPath.curve(to: NSPoint(x: 5.5, y: 12.27), controlPoint1: NSPoint(x: 5.72, y: 12.77), controlPoint2: NSPoint(x: 5.5, y: 12.54))
mainPath.line(to: NSPoint(x: 5.5, y: 12.27))
mainPath.line(to: NSPoint(x: 5.5, y: 12.27))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.29, y: 19.01))
mainPath.curve(to: NSPoint(x: 8.29, y: 18.31), controlPoint1: NSPoint(x: 8.1, y: 18.81), controlPoint2: NSPoint(x: 8.09, y: 18.5))
mainPath.line(to: NSPoint(x: 9.71, y: 16.88))
mainPath.curve(to: NSPoint(x: 10.41, y: 16.89), controlPoint1: NSPoint(x: 9.9, y: 16.69), controlPoint2: NSPoint(x: 10.22, y: 16.7))
mainPath.curve(to: NSPoint(x: 10.42, y: 17.59), controlPoint1: NSPoint(x: 10.61, y: 17.08), controlPoint2: NSPoint(x: 10.61, y: 17.39))
mainPath.line(to: NSPoint(x: 8.99, y: 19.01))
mainPath.curve(to: NSPoint(x: 8.29, y: 19.01), controlPoint1: NSPoint(x: 8.8, y: 19.21), controlPoint2: NSPoint(x: 8.48, y: 19.2))
mainPath.line(to: NSPoint(x: 8.29, y: 19.01))
mainPath.line(to: NSPoint(x: 8.29, y: 19.01))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawSunset(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 20.51, y: 13))
mainPath.curve(to: NSPoint(x: 20.53, y: 13.5), controlPoint1: NSPoint(x: 20.52, y: 13.16), controlPoint2: NSPoint(x: 20.53, y: 13.33))
mainPath.curve(to: NSPoint(x: 15.03, y: 19), controlPoint1: NSPoint(x: 20.53, y: 16.54), controlPoint2: NSPoint(x: 18.07, y: 19))
mainPath.curve(to: NSPoint(x: 9.53, y: 13.5), controlPoint1: NSPoint(x: 11.99, y: 19), controlPoint2: NSPoint(x: 9.53, y: 16.54))
mainPath.curve(to: NSPoint(x: 9.55, y: 13), controlPoint1: NSPoint(x: 9.53, y: 13.33), controlPoint2: NSPoint(x: 9.54, y: 13.16))
mainPath.line(to: NSPoint(x: 10.56, y: 13))
mainPath.curve(to: NSPoint(x: 10.53, y: 13.5), controlPoint1: NSPoint(x: 10.54, y: 13.16), controlPoint2: NSPoint(x: 10.53, y: 13.33))
mainPath.curve(to: NSPoint(x: 15.03, y: 18), controlPoint1: NSPoint(x: 10.53, y: 15.99), controlPoint2: NSPoint(x: 12.54, y: 18))
mainPath.curve(to: NSPoint(x: 19.53, y: 13.5), controlPoint1: NSPoint(x: 17.51, y: 18), controlPoint2: NSPoint(x: 19.53, y: 15.99))
mainPath.curve(to: NSPoint(x: 19.5, y: 13), controlPoint1: NSPoint(x: 19.53, y: 13.33), controlPoint2: NSPoint(x: 19.52, y: 13.16))
mainPath.line(to: NSPoint(x: 20.51, y: 13))
mainPath.line(to: NSPoint(x: 20.51, y: 13))
mainPath.line(to: NSPoint(x: 20.51, y: 13))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.03, y: 23))
mainPath.curve(to: NSPoint(x: 14.53, y: 22.5), controlPoint1: NSPoint(x: 14.75, y: 23), controlPoint2: NSPoint(x: 14.53, y: 22.78))
mainPath.line(to: NSPoint(x: 14.53, y: 20.5))
mainPath.curve(to: NSPoint(x: 15.03, y: 20), controlPoint1: NSPoint(x: 14.53, y: 20.22), controlPoint2: NSPoint(x: 14.76, y: 20))
mainPath.curve(to: NSPoint(x: 15.53, y: 20.5), controlPoint1: NSPoint(x: 15.31, y: 20), controlPoint2: NSPoint(x: 15.53, y: 20.22))
mainPath.line(to: NSPoint(x: 15.53, y: 22.5))
mainPath.curve(to: NSPoint(x: 15.03, y: 23), controlPoint1: NSPoint(x: 15.53, y: 22.78), controlPoint2: NSPoint(x: 15.3, y: 23))
mainPath.line(to: NSPoint(x: 15.03, y: 23))
mainPath.line(to: NSPoint(x: 15.03, y: 23))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.77, y: 20.21))
mainPath.curve(to: NSPoint(x: 21.06, y: 20.21), controlPoint1: NSPoint(x: 21.57, y: 20.4), controlPoint2: NSPoint(x: 21.26, y: 20.41))
mainPath.line(to: NSPoint(x: 19.64, y: 18.79))
mainPath.curve(to: NSPoint(x: 19.65, y: 18.09), controlPoint1: NSPoint(x: 19.45, y: 18.6), controlPoint2: NSPoint(x: 19.46, y: 18.28))
mainPath.curve(to: NSPoint(x: 20.35, y: 18.08), controlPoint1: NSPoint(x: 19.84, y: 17.89), controlPoint2: NSPoint(x: 20.15, y: 17.89))
mainPath.line(to: NSPoint(x: 21.77, y: 19.51))
mainPath.curve(to: NSPoint(x: 21.77, y: 20.21), controlPoint1: NSPoint(x: 21.96, y: 19.7), controlPoint2: NSPoint(x: 21.96, y: 20.02))
mainPath.line(to: NSPoint(x: 21.77, y: 20.21))
mainPath.line(to: NSPoint(x: 21.77, y: 20.21))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.56, y: 13.47))
mainPath.curve(to: NSPoint(x: 24.06, y: 13.97), controlPoint1: NSPoint(x: 24.56, y: 13.75), controlPoint2: NSPoint(x: 24.34, y: 13.97))
mainPath.line(to: NSPoint(x: 22.05, y: 13.97))
mainPath.curve(to: NSPoint(x: 21.56, y: 13.47), controlPoint1: NSPoint(x: 21.78, y: 13.97), controlPoint2: NSPoint(x: 21.56, y: 13.74))
mainPath.curve(to: NSPoint(x: 22.05, y: 12.97), controlPoint1: NSPoint(x: 21.56, y: 13.19), controlPoint2: NSPoint(x: 21.77, y: 12.97))
mainPath.line(to: NSPoint(x: 24.06, y: 12.97))
mainPath.curve(to: NSPoint(x: 24.56, y: 13.47), controlPoint1: NSPoint(x: 24.34, y: 12.97), controlPoint2: NSPoint(x: 24.56, y: 13.2))
mainPath.line(to: NSPoint(x: 24.56, y: 13.47))
mainPath.line(to: NSPoint(x: 24.56, y: 13.47))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.5, y: 13.47))
mainPath.curve(to: NSPoint(x: 6, y: 12.97), controlPoint1: NSPoint(x: 5.5, y: 13.19), controlPoint2: NSPoint(x: 5.72, y: 12.97))
mainPath.line(to: NSPoint(x: 8, y: 12.97))
mainPath.curve(to: NSPoint(x: 8.5, y: 13.47), controlPoint1: NSPoint(x: 8.28, y: 12.97), controlPoint2: NSPoint(x: 8.5, y: 13.2))
mainPath.curve(to: NSPoint(x: 8, y: 13.97), controlPoint1: NSPoint(x: 8.5, y: 13.75), controlPoint2: NSPoint(x: 8.28, y: 13.97))
mainPath.line(to: NSPoint(x: 6, y: 13.97))
mainPath.curve(to: NSPoint(x: 5.5, y: 13.47), controlPoint1: NSPoint(x: 5.72, y: 13.97), controlPoint2: NSPoint(x: 5.5, y: 13.74))
mainPath.line(to: NSPoint(x: 5.5, y: 13.47))
mainPath.line(to: NSPoint(x: 5.5, y: 13.47))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.29, y: 20.21))
mainPath.curve(to: NSPoint(x: 8.29, y: 19.51), controlPoint1: NSPoint(x: 8.1, y: 20.01), controlPoint2: NSPoint(x: 8.09, y: 19.7))
mainPath.line(to: NSPoint(x: 9.71, y: 18.08))
mainPath.curve(to: NSPoint(x: 10.41, y: 18.09), controlPoint1: NSPoint(x: 9.9, y: 17.89), controlPoint2: NSPoint(x: 10.22, y: 17.9))
mainPath.curve(to: NSPoint(x: 10.42, y: 18.79), controlPoint1: NSPoint(x: 10.61, y: 18.28), controlPoint2: NSPoint(x: 10.61, y: 18.59))
mainPath.line(to: NSPoint(x: 8.99, y: 20.21))
mainPath.curve(to: NSPoint(x: 8.29, y: 20.21), controlPoint1: NSPoint(x: 8.8, y: 20.41), controlPoint2: NSPoint(x: 8.48, y: 20.4))
mainPath.line(to: NSPoint(x: 8.29, y: 20.21))
mainPath.line(to: NSPoint(x: 8.29, y: 20.21))
mainPath.close()
mainPath.move(to: NSPoint(x: 6.04, y: 10))
mainPath.curve(to: NSPoint(x: 5.53, y: 10.5), controlPoint1: NSPoint(x: 5.76, y: 10), controlPoint2: NSPoint(x: 5.53, y: 10.23))
mainPath.curve(to: NSPoint(x: 6.04, y: 11), controlPoint1: NSPoint(x: 5.53, y: 10.78), controlPoint2: NSPoint(x: 5.76, y: 11))
mainPath.line(to: NSPoint(x: 12.11, y: 11))
mainPath.line(to: NSPoint(x: 13.28, y: 10))
mainPath.line(to: NSPoint(x: 15.03, y: 8.5))
mainPath.line(to: NSPoint(x: 16.78, y: 10))
mainPath.line(to: NSPoint(x: 17.95, y: 11))
mainPath.line(to: NSPoint(x: 24.02, y: 11))
mainPath.curve(to: NSPoint(x: 24.53, y: 10.5), controlPoint1: NSPoint(x: 24.3, y: 11), controlPoint2: NSPoint(x: 24.53, y: 10.77))
mainPath.curve(to: NSPoint(x: 24.02, y: 10), controlPoint1: NSPoint(x: 24.53, y: 10.22), controlPoint2: NSPoint(x: 24.3, y: 10))
mainPath.line(to: NSPoint(x: 18.53, y: 10))
mainPath.line(to: NSPoint(x: 15.03, y: 7))
mainPath.line(to: NSPoint(x: 11.53, y: 10))
mainPath.line(to: NSPoint(x: 6.04, y: 10))
mainPath.line(to: NSPoint(x: 6.04, y: 10))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawSunset2(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 20.51, y: 11.5))
mainPath.curve(to: NSPoint(x: 20.53, y: 12), controlPoint1: NSPoint(x: 20.52, y: 11.66), controlPoint2: NSPoint(x: 20.53, y: 11.83))
mainPath.curve(to: NSPoint(x: 15.03, y: 17.5), controlPoint1: NSPoint(x: 20.53, y: 15.04), controlPoint2: NSPoint(x: 18.07, y: 17.5))
mainPath.curve(to: NSPoint(x: 9.53, y: 12), controlPoint1: NSPoint(x: 11.99, y: 17.5), controlPoint2: NSPoint(x: 9.53, y: 15.04))
mainPath.curve(to: NSPoint(x: 9.55, y: 11.5), controlPoint1: NSPoint(x: 9.53, y: 11.83), controlPoint2: NSPoint(x: 9.54, y: 11.66))
mainPath.line(to: NSPoint(x: 10.56, y: 11.5))
mainPath.curve(to: NSPoint(x: 10.53, y: 12), controlPoint1: NSPoint(x: 10.54, y: 11.66), controlPoint2: NSPoint(x: 10.53, y: 11.83))
mainPath.curve(to: NSPoint(x: 15.03, y: 16.5), controlPoint1: NSPoint(x: 10.53, y: 14.49), controlPoint2: NSPoint(x: 12.54, y: 16.5))
mainPath.curve(to: NSPoint(x: 19.53, y: 12), controlPoint1: NSPoint(x: 17.51, y: 16.5), controlPoint2: NSPoint(x: 19.53, y: 14.49))
mainPath.curve(to: NSPoint(x: 19.5, y: 11.5), controlPoint1: NSPoint(x: 19.53, y: 11.83), controlPoint2: NSPoint(x: 19.52, y: 11.66))
mainPath.line(to: NSPoint(x: 20.51, y: 11.5))
mainPath.line(to: NSPoint(x: 20.51, y: 11.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.03, y: 21.5))
mainPath.curve(to: NSPoint(x: 14.53, y: 21), controlPoint1: NSPoint(x: 14.75, y: 21.5), controlPoint2: NSPoint(x: 14.53, y: 21.28))
mainPath.line(to: NSPoint(x: 14.53, y: 19))
mainPath.curve(to: NSPoint(x: 15.03, y: 18.5), controlPoint1: NSPoint(x: 14.53, y: 18.72), controlPoint2: NSPoint(x: 14.76, y: 18.5))
mainPath.curve(to: NSPoint(x: 15.53, y: 19), controlPoint1: NSPoint(x: 15.31, y: 18.5), controlPoint2: NSPoint(x: 15.53, y: 18.72))
mainPath.line(to: NSPoint(x: 15.53, y: 21))
mainPath.curve(to: NSPoint(x: 15.03, y: 21.5), controlPoint1: NSPoint(x: 15.53, y: 21.28), controlPoint2: NSPoint(x: 15.3, y: 21.5))
mainPath.line(to: NSPoint(x: 15.03, y: 21.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.77, y: 18.71))
mainPath.curve(to: NSPoint(x: 21.06, y: 18.71), controlPoint1: NSPoint(x: 21.57, y: 18.9), controlPoint2: NSPoint(x: 21.26, y: 18.91))
mainPath.line(to: NSPoint(x: 19.64, y: 17.29))
mainPath.curve(to: NSPoint(x: 19.65, y: 16.59), controlPoint1: NSPoint(x: 19.45, y: 17.1), controlPoint2: NSPoint(x: 19.46, y: 16.78))
mainPath.curve(to: NSPoint(x: 20.35, y: 16.58), controlPoint1: NSPoint(x: 19.84, y: 16.39), controlPoint2: NSPoint(x: 20.15, y: 16.39))
mainPath.line(to: NSPoint(x: 21.77, y: 18.01))
mainPath.curve(to: NSPoint(x: 21.77, y: 18.71), controlPoint1: NSPoint(x: 21.96, y: 18.2), controlPoint2: NSPoint(x: 21.96, y: 18.52))
mainPath.line(to: NSPoint(x: 21.77, y: 18.71))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.56, y: 11.97))
mainPath.curve(to: NSPoint(x: 24.06, y: 12.47), controlPoint1: NSPoint(x: 24.56, y: 12.25), controlPoint2: NSPoint(x: 24.34, y: 12.47))
mainPath.line(to: NSPoint(x: 22.05, y: 12.47))
mainPath.curve(to: NSPoint(x: 21.56, y: 11.97), controlPoint1: NSPoint(x: 21.78, y: 12.47), controlPoint2: NSPoint(x: 21.56, y: 12.24))
mainPath.curve(to: NSPoint(x: 22.05, y: 11.47), controlPoint1: NSPoint(x: 21.56, y: 11.69), controlPoint2: NSPoint(x: 21.77, y: 11.47))
mainPath.line(to: NSPoint(x: 24.06, y: 11.47))
mainPath.curve(to: NSPoint(x: 24.56, y: 11.97), controlPoint1: NSPoint(x: 24.34, y: 11.47), controlPoint2: NSPoint(x: 24.56, y: 11.7))
mainPath.line(to: NSPoint(x: 24.56, y: 11.97))
mainPath.close()
mainPath.move(to: NSPoint(x: 5.5, y: 11.97))
mainPath.curve(to: NSPoint(x: 6, y: 11.47), controlPoint1: NSPoint(x: 5.5, y: 11.69), controlPoint2: NSPoint(x: 5.72, y: 11.47))
mainPath.line(to: NSPoint(x: 8, y: 11.47))
mainPath.curve(to: NSPoint(x: 8.5, y: 11.97), controlPoint1: NSPoint(x: 8.28, y: 11.47), controlPoint2: NSPoint(x: 8.5, y: 11.7))
mainPath.curve(to: NSPoint(x: 8, y: 12.47), controlPoint1: NSPoint(x: 8.5, y: 12.25), controlPoint2: NSPoint(x: 8.28, y: 12.47))
mainPath.line(to: NSPoint(x: 6, y: 12.47))
mainPath.curve(to: NSPoint(x: 5.5, y: 11.97), controlPoint1: NSPoint(x: 5.72, y: 12.47), controlPoint2: NSPoint(x: 5.5, y: 12.24))
mainPath.line(to: NSPoint(x: 5.5, y: 11.97))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.29, y: 18.71))
mainPath.curve(to: NSPoint(x: 8.29, y: 18.01), controlPoint1: NSPoint(x: 8.1, y: 18.51), controlPoint2: NSPoint(x: 8.09, y: 18.2))
mainPath.line(to: NSPoint(x: 9.71, y: 16.58))
mainPath.curve(to: NSPoint(x: 10.41, y: 16.59), controlPoint1: NSPoint(x: 9.9, y: 16.39), controlPoint2: NSPoint(x: 10.22, y: 16.4))
mainPath.curve(to: NSPoint(x: 10.42, y: 17.29), controlPoint1: NSPoint(x: 10.61, y: 16.78), controlPoint2: NSPoint(x: 10.61, y: 17.09))
mainPath.line(to: NSPoint(x: 8.99, y: 18.71))
mainPath.curve(to: NSPoint(x: 8.29, y: 18.71), controlPoint1: NSPoint(x: 8.8, y: 18.91), controlPoint2: NSPoint(x: 8.48, y: 18.9))
mainPath.line(to: NSPoint(x: 8.29, y: 18.71))
mainPath.close()
mainPath.move(to: NSPoint(x: 6.04, y: 9.5))
mainPath.curve(to: NSPoint(x: 5.53, y: 9), controlPoint1: NSPoint(x: 5.76, y: 9.5), controlPoint2: NSPoint(x: 5.53, y: 9.27))
mainPath.line(to: NSPoint(x: 5.53, y: 9))
mainPath.curve(to: NSPoint(x: 6.04, y: 8.5), controlPoint1: NSPoint(x: 5.53, y: 8.72), controlPoint2: NSPoint(x: 5.76, y: 8.5))
mainPath.line(to: NSPoint(x: 24.02, y: 8.5))
mainPath.curve(to: NSPoint(x: 24.53, y: 9), controlPoint1: NSPoint(x: 24.3, y: 8.5), controlPoint2: NSPoint(x: 24.53, y: 8.73))
mainPath.line(to: NSPoint(x: 24.53, y: 9))
mainPath.curve(to: NSPoint(x: 24.02, y: 9.5), controlPoint1: NSPoint(x: 24.53, y: 9.28), controlPoint2: NSPoint(x: 24.3, y: 9.5))
mainPath.line(to: NSPoint(x: 6.04, y: 9.5))
mainPath.line(to: NSPoint(x: 6.04, y: 9.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawSunset3(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 20.29, y: 12.5))
mainPath.curve(to: NSPoint(x: 15, y: 16.5), controlPoint1: NSPoint(x: 19.64, y: 14.81), controlPoint2: NSPoint(x: 17.52, y: 16.5))
mainPath.curve(to: NSPoint(x: 9.71, y: 12.5), controlPoint1: NSPoint(x: 12.48, y: 16.5), controlPoint2: NSPoint(x: 10.36, y: 14.81))
mainPath.line(to: NSPoint(x: 10.76, y: 12.5))
mainPath.curve(to: NSPoint(x: 15, y: 15.5), controlPoint1: NSPoint(x: 11.37, y: 14.25), controlPoint2: NSPoint(x: 13.04, y: 15.5))
mainPath.curve(to: NSPoint(x: 19.24, y: 12.5), controlPoint1: NSPoint(x: 16.96, y: 15.5), controlPoint2: NSPoint(x: 18.63, y: 14.25))
mainPath.line(to: NSPoint(x: 20.29, y: 12.5))
mainPath.line(to: NSPoint(x: 20.29, y: 12.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 20.5))
mainPath.curve(to: NSPoint(x: 14.5, y: 20), controlPoint1: NSPoint(x: 14.72, y: 20.5), controlPoint2: NSPoint(x: 14.5, y: 20.28))
mainPath.line(to: NSPoint(x: 14.5, y: 18))
mainPath.curve(to: NSPoint(x: 15, y: 17.5), controlPoint1: NSPoint(x: 14.5, y: 17.72), controlPoint2: NSPoint(x: 14.73, y: 17.5))
mainPath.curve(to: NSPoint(x: 15.5, y: 18), controlPoint1: NSPoint(x: 15.28, y: 17.5), controlPoint2: NSPoint(x: 15.5, y: 17.72))
mainPath.line(to: NSPoint(x: 15.5, y: 20))
mainPath.curve(to: NSPoint(x: 15, y: 20.5), controlPoint1: NSPoint(x: 15.5, y: 20.28), controlPoint2: NSPoint(x: 15.27, y: 20.5))
mainPath.line(to: NSPoint(x: 15, y: 20.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.74, y: 17.71))
mainPath.curve(to: NSPoint(x: 21.03, y: 17.71), controlPoint1: NSPoint(x: 21.54, y: 17.9), controlPoint2: NSPoint(x: 21.23, y: 17.91))
mainPath.line(to: NSPoint(x: 19.61, y: 16.29))
mainPath.curve(to: NSPoint(x: 19.62, y: 15.59), controlPoint1: NSPoint(x: 19.42, y: 16.1), controlPoint2: NSPoint(x: 19.43, y: 15.78))
mainPath.curve(to: NSPoint(x: 20.32, y: 15.58), controlPoint1: NSPoint(x: 19.81, y: 15.39), controlPoint2: NSPoint(x: 20.12, y: 15.39))
mainPath.line(to: NSPoint(x: 21.74, y: 17.01))
mainPath.curve(to: NSPoint(x: 21.74, y: 17.71), controlPoint1: NSPoint(x: 21.93, y: 17.2), controlPoint2: NSPoint(x: 21.93, y: 17.52))
mainPath.line(to: NSPoint(x: 21.74, y: 17.71))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.26, y: 17.71))
mainPath.curve(to: NSPoint(x: 8.26, y: 17.01), controlPoint1: NSPoint(x: 8.07, y: 17.51), controlPoint2: NSPoint(x: 8.06, y: 17.2))
mainPath.line(to: NSPoint(x: 9.68, y: 15.58))
mainPath.curve(to: NSPoint(x: 10.38, y: 15.59), controlPoint1: NSPoint(x: 9.87, y: 15.39), controlPoint2: NSPoint(x: 10.19, y: 15.4))
mainPath.curve(to: NSPoint(x: 10.39, y: 16.29), controlPoint1: NSPoint(x: 10.58, y: 15.78), controlPoint2: NSPoint(x: 10.58, y: 16.09))
mainPath.line(to: NSPoint(x: 8.97, y: 17.71))
mainPath.curve(to: NSPoint(x: 8.26, y: 17.71), controlPoint1: NSPoint(x: 8.77, y: 17.91), controlPoint2: NSPoint(x: 8.45, y: 17.9))
mainPath.line(to: NSPoint(x: 8.26, y: 17.71))
mainPath.close()
mainPath.move(to: NSPoint(x: 6.01, y: 10.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 10), controlPoint1: NSPoint(x: 5.73, y: 10.5), controlPoint2: NSPoint(x: 5.5, y: 10.27))
mainPath.line(to: NSPoint(x: 5.5, y: 10))
mainPath.curve(to: NSPoint(x: 6.01, y: 9.5), controlPoint1: NSPoint(x: 5.5, y: 9.72), controlPoint2: NSPoint(x: 5.73, y: 9.5))
mainPath.line(to: NSPoint(x: 23.99, y: 9.5))
mainPath.curve(to: NSPoint(x: 24.5, y: 10), controlPoint1: NSPoint(x: 24.27, y: 9.5), controlPoint2: NSPoint(x: 24.5, y: 9.73))
mainPath.line(to: NSPoint(x: 24.5, y: 10))
mainPath.curve(to: NSPoint(x: 23.99, y: 10.5), controlPoint1: NSPoint(x: 24.5, y: 10.28), controlPoint2: NSPoint(x: 24.27, y: 10.5))
mainPath.line(to: NSPoint(x: 6.01, y: 10.5))
mainPath.line(to: NSPoint(x: 6.01, y: 10.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawRainbow(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15, y: 19.81))
mainPath.curve(to: NSPoint(x: 29.99, y: 5.01), controlPoint1: NSPoint(x: 23.1, y: 19.81), controlPoint2: NSPoint(x: 29.69, y: 13.23))
mainPath.curve(to: NSPoint(x: 30, y: 4.9), controlPoint1: NSPoint(x: 30, y: 4.97), controlPoint2: NSPoint(x: 30, y: 4.94))
mainPath.curve(to: NSPoint(x: 29.53, y: 4.42), controlPoint1: NSPoint(x: 30, y: 4.64), controlPoint2: NSPoint(x: 29.79, y: 4.42))
mainPath.curve(to: NSPoint(x: 29.06, y: 4.9), controlPoint1: NSPoint(x: 29.27, y: 4.42), controlPoint2: NSPoint(x: 29.06, y: 4.64))
mainPath.curve(to: NSPoint(x: 15, y: 18.85), controlPoint1: NSPoint(x: 28.81, y: 12.65), controlPoint2: NSPoint(x: 22.61, y: 18.85))
mainPath.curve(to: NSPoint(x: 0.95, y: 4.9), controlPoint1: NSPoint(x: 7.39, y: 18.85), controlPoint2: NSPoint(x: 1.19, y: 12.65))
mainPath.curve(to: NSPoint(x: 0.47, y: 4.42), controlPoint1: NSPoint(x: 0.94, y: 4.64), controlPoint2: NSPoint(x: 0.73, y: 4.42))
mainPath.curve(to: NSPoint(x: 0, y: 4.9), controlPoint1: NSPoint(x: 0.21, y: 4.42), controlPoint2: NSPoint(x: 0, y: 4.64))
mainPath.curve(to: NSPoint(x: 0.01, y: 5.01), controlPoint1: NSPoint(x: 0, y: 4.94), controlPoint2: NSPoint(x: 0, y: 4.97))
mainPath.curve(to: NSPoint(x: 15, y: 19.81), controlPoint1: NSPoint(x: 0.31, y: 13.23), controlPoint2: NSPoint(x: 6.91, y: 19.81))
mainPath.line(to: NSPoint(x: 15, y: 19.81))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 17.88))
mainPath.curve(to: NSPoint(x: 28.11, y: 5.01), controlPoint1: NSPoint(x: 22.06, y: 17.88), controlPoint2: NSPoint(x: 27.81, y: 12.17))
mainPath.curve(to: NSPoint(x: 28.13, y: 4.9), controlPoint1: NSPoint(x: 28.12, y: 4.98), controlPoint2: NSPoint(x: 28.13, y: 4.94))
mainPath.curve(to: NSPoint(x: 27.66, y: 4.42), controlPoint1: NSPoint(x: 28.13, y: 4.64), controlPoint2: NSPoint(x: 27.92, y: 4.42))
mainPath.curve(to: NSPoint(x: 27.19, y: 4.9), controlPoint1: NSPoint(x: 27.4, y: 4.42), controlPoint2: NSPoint(x: 27.19, y: 4.64))
mainPath.curve(to: NSPoint(x: 15, y: 16.92), controlPoint1: NSPoint(x: 26.93, y: 11.58), controlPoint2: NSPoint(x: 21.58, y: 16.92))
mainPath.curve(to: NSPoint(x: 2.82, y: 4.9), controlPoint1: NSPoint(x: 8.43, y: 16.92), controlPoint2: NSPoint(x: 3.07, y: 11.58))
mainPath.curve(to: NSPoint(x: 2.34, y: 4.42), controlPoint1: NSPoint(x: 2.81, y: 4.64), controlPoint2: NSPoint(x: 2.6, y: 4.42))
mainPath.curve(to: NSPoint(x: 1.88, y: 4.9), controlPoint1: NSPoint(x: 2.08, y: 4.42), controlPoint2: NSPoint(x: 1.88, y: 4.64))
mainPath.curve(to: NSPoint(x: 1.89, y: 5.01), controlPoint1: NSPoint(x: 1.88, y: 4.94), controlPoint2: NSPoint(x: 1.88, y: 4.98))
mainPath.curve(to: NSPoint(x: 15, y: 17.88), controlPoint1: NSPoint(x: 2.19, y: 12.17), controlPoint2: NSPoint(x: 7.94, y: 17.88))
mainPath.line(to: NSPoint(x: 15, y: 17.88))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 15.96))
mainPath.curve(to: NSPoint(x: 26.24, y: 5.03), controlPoint1: NSPoint(x: 21.02, y: 15.96), controlPoint2: NSPoint(x: 25.93, y: 11.12))
mainPath.curve(to: NSPoint(x: 26.25, y: 4.9), controlPoint1: NSPoint(x: 26.25, y: 4.99), controlPoint2: NSPoint(x: 26.25, y: 4.95))
mainPath.curve(to: NSPoint(x: 25.78, y: 4.42), controlPoint1: NSPoint(x: 26.25, y: 4.64), controlPoint2: NSPoint(x: 26.04, y: 4.42))
mainPath.curve(to: NSPoint(x: 25.31, y: 4.9), controlPoint1: NSPoint(x: 25.52, y: 4.42), controlPoint2: NSPoint(x: 25.31, y: 4.64))
mainPath.curve(to: NSPoint(x: 15, y: 15), controlPoint1: NSPoint(x: 25.06, y: 10.52), controlPoint2: NSPoint(x: 20.54, y: 15))
mainPath.curve(to: NSPoint(x: 4.7, y: 4.9), controlPoint1: NSPoint(x: 9.46, y: 15), controlPoint2: NSPoint(x: 4.94, y: 10.52))
mainPath.curve(to: NSPoint(x: 4.22, y: 4.42), controlPoint1: NSPoint(x: 4.69, y: 4.64), controlPoint2: NSPoint(x: 4.48, y: 4.42))
mainPath.curve(to: NSPoint(x: 3.75, y: 4.9), controlPoint1: NSPoint(x: 3.96, y: 4.42), controlPoint2: NSPoint(x: 3.75, y: 4.64))
mainPath.curve(to: NSPoint(x: 3.77, y: 5.03), controlPoint1: NSPoint(x: 3.75, y: 4.95), controlPoint2: NSPoint(x: 3.76, y: 4.99))
mainPath.curve(to: NSPoint(x: 15, y: 15.96), controlPoint1: NSPoint(x: 4.07, y: 11.12), controlPoint2: NSPoint(x: 8.98, y: 15.96))
mainPath.line(to: NSPoint(x: 15, y: 15.96))
mainPath.close()
mainPath.move(to: NSPoint(x: 0.47, y: 3.46))
mainPath.curve(to: NSPoint(x: 0, y: 2.98), controlPoint1: NSPoint(x: 0.21, y: 3.46), controlPoint2: NSPoint(x: 0, y: 3.24))
mainPath.curve(to: NSPoint(x: 0.47, y: 2.5), controlPoint1: NSPoint(x: 0, y: 2.72), controlPoint2: NSPoint(x: 0.21, y: 2.5))
mainPath.line(to: NSPoint(x: 29.53, y: 2.5))
mainPath.curve(to: NSPoint(x: 30, y: 2.98), controlPoint1: NSPoint(x: 29.79, y: 2.5), controlPoint2: NSPoint(x: 30, y: 2.72))
mainPath.curve(to: NSPoint(x: 29.53, y: 3.46), controlPoint1: NSPoint(x: 30, y: 3.25), controlPoint2: NSPoint(x: 29.79, y: 3.46))
mainPath.line(to: NSPoint(x: 0.47, y: 3.46))
mainPath.line(to: NSPoint(x: 0.47, y: 3.46))
mainPath.close()
mainPath.move(to: NSPoint(x: 26.25, y: 18.37))
mainPath.curve(to: NSPoint(x: 21.1, y: 23.65), controlPoint1: NSPoint(x: 26.25, y: 21.29), controlPoint2: NSPoint(x: 23.94, y: 23.65))
mainPath.curve(to: NSPoint(x: 16.47, y: 20.7), controlPoint1: NSPoint(x: 19.06, y: 23.65), controlPoint2: NSPoint(x: 17.31, y: 22.45))
mainPath.curve(to: NSPoint(x: 17.47, y: 20.57), controlPoint1: NSPoint(x: 16.8, y: 20.67), controlPoint2: NSPoint(x: 17.14, y: 20.63))
mainPath.curve(to: NSPoint(x: 21.1, y: 22.69), controlPoint1: NSPoint(x: 18.2, y: 21.84), controlPoint2: NSPoint(x: 19.55, y: 22.69))
mainPath.curve(to: NSPoint(x: 25.31, y: 18.37), controlPoint1: NSPoint(x: 23.43, y: 22.69), controlPoint2: NSPoint(x: 25.31, y: 20.76))
mainPath.curve(to: NSPoint(x: 25.12, y: 17.06), controlPoint1: NSPoint(x: 25.31, y: 17.91), controlPoint2: NSPoint(x: 25.25, y: 17.47))
mainPath.curve(to: NSPoint(x: 25.87, y: 16.38), controlPoint1: NSPoint(x: 25.38, y: 16.84), controlPoint2: NSPoint(x: 25.63, y: 16.61))
mainPath.curve(to: NSPoint(x: 26.25, y: 18.37), controlPoint1: NSPoint(x: 26.12, y: 16.99), controlPoint2: NSPoint(x: 26.25, y: 17.66))
mainPath.line(to: NSPoint(x: 26.25, y: 18.37))
mainPath.close()
mainPath.move(to: NSPoint(x: 20.63, y: 27.02))
mainPath.line(to: NSPoint(x: 20.63, y: 25.09))
mainPath.curve(to: NSPoint(x: 21.1, y: 24.62), controlPoint1: NSPoint(x: 20.63, y: 24.83), controlPoint2: NSPoint(x: 20.84, y: 24.62))
mainPath.curve(to: NSPoint(x: 21.56, y: 25.09), controlPoint1: NSPoint(x: 21.35, y: 24.62), controlPoint2: NSPoint(x: 21.56, y: 24.82))
mainPath.line(to: NSPoint(x: 21.56, y: 27.02))
mainPath.curve(to: NSPoint(x: 21.1, y: 27.5), controlPoint1: NSPoint(x: 21.56, y: 27.29), controlPoint2: NSPoint(x: 21.35, y: 27.5))
mainPath.curve(to: NSPoint(x: 20.63, y: 27.02), controlPoint1: NSPoint(x: 20.84, y: 27.5), controlPoint2: NSPoint(x: 20.63, y: 27.29))
mainPath.line(to: NSPoint(x: 20.63, y: 27.02))
mainPath.close()
mainPath.move(to: NSPoint(x: 26.75, y: 24.82))
mainPath.line(to: NSPoint(x: 25.42, y: 23.45))
mainPath.curve(to: NSPoint(x: 25.42, y: 22.78), controlPoint1: NSPoint(x: 25.24, y: 23.27), controlPoint2: NSPoint(x: 25.25, y: 22.96))
mainPath.curve(to: NSPoint(x: 26.08, y: 22.77), controlPoint1: NSPoint(x: 25.61, y: 22.59), controlPoint2: NSPoint(x: 25.9, y: 22.58))
mainPath.line(to: NSPoint(x: 27.42, y: 24.14))
mainPath.curve(to: NSPoint(x: 27.41, y: 24.82), controlPoint1: NSPoint(x: 27.6, y: 24.33), controlPoint2: NSPoint(x: 27.59, y: 24.63))
mainPath.curve(to: NSPoint(x: 26.75, y: 24.82), controlPoint1: NSPoint(x: 27.23, y: 25), controlPoint2: NSPoint(x: 26.94, y: 25.01))
mainPath.line(to: NSPoint(x: 26.75, y: 24.82))
mainPath.close()
mainPath.move(to: NSPoint(x: 29.56, y: 18.82))
mainPath.line(to: NSPoint(x: 27.68, y: 18.82))
mainPath.curve(to: NSPoint(x: 27.22, y: 18.34), controlPoint1: NSPoint(x: 27.42, y: 18.82), controlPoint2: NSPoint(x: 27.22, y: 18.6))
mainPath.curve(to: NSPoint(x: 27.68, y: 17.86), controlPoint1: NSPoint(x: 27.22, y: 18.07), controlPoint2: NSPoint(x: 27.42, y: 17.86))
mainPath.line(to: NSPoint(x: 29.56, y: 17.86))
mainPath.curve(to: NSPoint(x: 30.03, y: 18.34), controlPoint1: NSPoint(x: 29.82, y: 17.86), controlPoint2: NSPoint(x: 30.03, y: 18.08))
mainPath.curve(to: NSPoint(x: 29.56, y: 18.82), controlPoint1: NSPoint(x: 30.03, y: 18.6), controlPoint2: NSPoint(x: 29.83, y: 18.82))
mainPath.line(to: NSPoint(x: 29.56, y: 18.82))
mainPath.close()
mainPath.move(to: NSPoint(x: 14.77, y: 24.14))
mainPath.line(to: NSPoint(x: 16.11, y: 22.77))
mainPath.curve(to: NSPoint(x: 16.77, y: 22.78), controlPoint1: NSPoint(x: 16.29, y: 22.59), controlPoint2: NSPoint(x: 16.59, y: 22.59))
mainPath.curve(to: NSPoint(x: 16.77, y: 23.45), controlPoint1: NSPoint(x: 16.95, y: 22.96), controlPoint2: NSPoint(x: 16.96, y: 23.26))
mainPath.line(to: NSPoint(x: 15.44, y: 24.82))
mainPath.curve(to: NSPoint(x: 14.78, y: 24.82), controlPoint1: NSPoint(x: 15.26, y: 25.01), controlPoint2: NSPoint(x: 14.96, y: 25))
mainPath.curve(to: NSPoint(x: 14.77, y: 24.14), controlPoint1: NSPoint(x: 14.59, y: 24.63), controlPoint2: NSPoint(x: 14.59, y: 24.33))
mainPath.line(to: NSPoint(x: 14.77, y: 24.14))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawUmbrella(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 27.58, y: 19))
mainPath.curve(to: NSPoint(x: 30, y: 17), controlPoint1: NSPoint(x: 28.92, y: 19), controlPoint2: NSPoint(x: 30, y: 18.1))
mainPath.curve(to: NSPoint(x: 15.48, y: 26.99), controlPoint1: NSPoint(x: 30, y: 22.41), controlPoint2: NSPoint(x: 23.54, y: 26.82))
mainPath.line(to: NSPoint(x: 15.48, y: 28.5))
mainPath.curve(to: NSPoint(x: 15, y: 29), controlPoint1: NSPoint(x: 15.48, y: 28.78), controlPoint2: NSPoint(x: 15.26, y: 29))
mainPath.curve(to: NSPoint(x: 14.52, y: 28.5), controlPoint1: NSPoint(x: 14.73, y: 29), controlPoint2: NSPoint(x: 14.52, y: 28.78))
mainPath.line(to: NSPoint(x: 14.52, y: 26.99))
mainPath.curve(to: NSPoint(x: 0, y: 17), controlPoint1: NSPoint(x: 6.46, y: 26.82), controlPoint2: NSPoint(x: 0, y: 22.41))
mainPath.curve(to: NSPoint(x: 2.42, y: 19), controlPoint1: NSPoint(x: 0, y: 18.1), controlPoint2: NSPoint(x: 1.08, y: 19))
mainPath.curve(to: NSPoint(x: 4.84, y: 17), controlPoint1: NSPoint(x: 3.76, y: 19), controlPoint2: NSPoint(x: 4.84, y: 18.1))
mainPath.curve(to: NSPoint(x: 7.26, y: 19), controlPoint1: NSPoint(x: 4.84, y: 18.1), controlPoint2: NSPoint(x: 5.92, y: 19))
mainPath.curve(to: NSPoint(x: 9.68, y: 17), controlPoint1: NSPoint(x: 8.59, y: 19), controlPoint2: NSPoint(x: 9.68, y: 18.1))
mainPath.curve(to: NSPoint(x: 12.1, y: 19), controlPoint1: NSPoint(x: 9.68, y: 18.1), controlPoint2: NSPoint(x: 10.76, y: 19))
mainPath.curve(to: NSPoint(x: 14.52, y: 17), controlPoint1: NSPoint(x: 13.43, y: 19), controlPoint2: NSPoint(x: 14.52, y: 18.1))
mainPath.line(to: NSPoint(x: 14.52, y: 5.88))
mainPath.line(to: NSPoint(x: 14.52, y: 2.99))
mainPath.curve(to: NSPoint(x: 13.55, y: 2), controlPoint1: NSPoint(x: 14.52, y: 2.45), controlPoint2: NSPoint(x: 14.08, y: 2))
mainPath.curve(to: NSPoint(x: 12.58, y: 2.99), controlPoint1: NSPoint(x: 13.01, y: 2), controlPoint2: NSPoint(x: 12.58, y: 2.44))
mainPath.line(to: NSPoint(x: 12.58, y: 3.88))
mainPath.line(to: NSPoint(x: 12.58, y: 4.5))
mainPath.curve(to: NSPoint(x: 12.1, y: 5), controlPoint1: NSPoint(x: 12.58, y: 4.77), controlPoint2: NSPoint(x: 12.36, y: 5))
mainPath.curve(to: NSPoint(x: 11.61, y: 4.5), controlPoint1: NSPoint(x: 11.83, y: 5), controlPoint2: NSPoint(x: 11.61, y: 4.79))
mainPath.line(to: NSPoint(x: 11.61, y: 3.75))
mainPath.line(to: NSPoint(x: 11.61, y: 3))
mainPath.curve(to: NSPoint(x: 13.55, y: 1), controlPoint1: NSPoint(x: 11.61, y: 1.9), controlPoint2: NSPoint(x: 12.47, y: 1))
mainPath.curve(to: NSPoint(x: 15.48, y: 3), controlPoint1: NSPoint(x: 14.62, y: 1), controlPoint2: NSPoint(x: 15.48, y: 1.89))
mainPath.line(to: NSPoint(x: 15.48, y: 4.5))
mainPath.line(to: NSPoint(x: 15.48, y: 17))
mainPath.curve(to: NSPoint(x: 17.9, y: 19), controlPoint1: NSPoint(x: 15.48, y: 18.1), controlPoint2: NSPoint(x: 16.57, y: 19))
mainPath.curve(to: NSPoint(x: 20.32, y: 17), controlPoint1: NSPoint(x: 19.24, y: 19), controlPoint2: NSPoint(x: 20.32, y: 18.1))
mainPath.curve(to: NSPoint(x: 22.74, y: 19), controlPoint1: NSPoint(x: 20.32, y: 18.1), controlPoint2: NSPoint(x: 21.41, y: 19))
mainPath.curve(to: NSPoint(x: 25.16, y: 17), controlPoint1: NSPoint(x: 24.08, y: 19), controlPoint2: NSPoint(x: 25.16, y: 18.1))
mainPath.curve(to: NSPoint(x: 27.58, y: 19), controlPoint1: NSPoint(x: 25.16, y: 18.1), controlPoint2: NSPoint(x: 26.24, y: 19))
mainPath.line(to: NSPoint(x: 27.58, y: 19))
mainPath.close()
mainPath.move(to: NSPoint(x: 14.52, y: 19.1))
mainPath.curve(to: NSPoint(x: 12.1, y: 20), controlPoint1: NSPoint(x: 13.9, y: 19.66), controlPoint2: NSPoint(x: 13.04, y: 20))
mainPath.curve(to: NSPoint(x: 9.84, y: 19.24), controlPoint1: NSPoint(x: 11.23, y: 20), controlPoint2: NSPoint(x: 10.44, y: 19.71))
mainPath.line(to: NSPoint(x: 9.84, y: 19.24))
mainPath.curve(to: NSPoint(x: 14.52, y: 25.96), controlPoint1: NSPoint(x: 10.39, y: 22.87), controlPoint2: NSPoint(x: 12.25, y: 25.62))
mainPath.line(to: NSPoint(x: 14.52, y: 19.1))
mainPath.line(to: NSPoint(x: 14.52, y: 19.1))
mainPath.line(to: NSPoint(x: 14.52, y: 19.1))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.48, y: 19.1))
mainPath.curve(to: NSPoint(x: 17.9, y: 20), controlPoint1: NSPoint(x: 16.1, y: 19.66), controlPoint2: NSPoint(x: 16.96, y: 20))
mainPath.curve(to: NSPoint(x: 20.16, y: 19.24), controlPoint1: NSPoint(x: 18.77, y: 20), controlPoint2: NSPoint(x: 19.56, y: 19.71))
mainPath.curve(to: NSPoint(x: 15.48, y: 25.96), controlPoint1: NSPoint(x: 19.61, y: 22.87), controlPoint2: NSPoint(x: 17.75, y: 25.62))
mainPath.line(to: NSPoint(x: 15.48, y: 19.1))
mainPath.line(to: NSPoint(x: 15.48, y: 19.1))
mainPath.line(to: NSPoint(x: 15.48, y: 19.1))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.93, y: 19.61))
mainPath.curve(to: NSPoint(x: 7.26, y: 20), controlPoint1: NSPoint(x: 8.43, y: 19.86), controlPoint2: NSPoint(x: 7.86, y: 20))
mainPath.curve(to: NSPoint(x: 5.2, y: 19.38), controlPoint1: NSPoint(x: 6.48, y: 20), controlPoint2: NSPoint(x: 5.77, y: 19.77))
mainPath.line(to: NSPoint(x: 5.2, y: 19.38))
mainPath.curve(to: NSPoint(x: 11.7, y: 25.51), controlPoint1: NSPoint(x: 6.09, y: 22.25), controlPoint2: NSPoint(x: 8.54, y: 24.55))
mainPath.curve(to: NSPoint(x: 8.93, y: 19.61), controlPoint1: NSPoint(x: 10.36, y: 24.2), controlPoint2: NSPoint(x: 9.35, y: 22.09))
mainPath.line(to: NSPoint(x: 8.93, y: 19.61))
mainPath.line(to: NSPoint(x: 8.93, y: 19.61))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.07, y: 19.61))
mainPath.curve(to: NSPoint(x: 22.74, y: 20), controlPoint1: NSPoint(x: 21.57, y: 19.86), controlPoint2: NSPoint(x: 22.14, y: 20))
mainPath.curve(to: NSPoint(x: 24.8, y: 19.38), controlPoint1: NSPoint(x: 23.52, y: 20), controlPoint2: NSPoint(x: 24.23, y: 19.77))
mainPath.curve(to: NSPoint(x: 18.3, y: 25.51), controlPoint1: NSPoint(x: 23.91, y: 22.25), controlPoint2: NSPoint(x: 21.46, y: 24.55))
mainPath.curve(to: NSPoint(x: 21.07, y: 19.61), controlPoint1: NSPoint(x: 19.64, y: 24.2), controlPoint2: NSPoint(x: 20.65, y: 22.09))
mainPath.line(to: NSPoint(x: 21.07, y: 19.61))
mainPath.line(to: NSPoint(x: 21.07, y: 19.61))
mainPath.close()
mainPath.move(to: NSPoint(x: 4.23, y: 19.53))
mainPath.curve(to: NSPoint(x: 2.42, y: 20), controlPoint1: NSPoint(x: 3.71, y: 19.83), controlPoint2: NSPoint(x: 3.09, y: 20))
mainPath.curve(to: NSPoint(x: 1.73, y: 19.94), controlPoint1: NSPoint(x: 2.18, y: 20), controlPoint2: NSPoint(x: 1.95, y: 19.98))
mainPath.curve(to: NSPoint(x: 8.08, y: 24.83), controlPoint1: NSPoint(x: 2.85, y: 22.02), controlPoint2: NSPoint(x: 5.13, y: 23.76))
mainPath.curve(to: NSPoint(x: 4.23, y: 19.53), controlPoint1: NSPoint(x: 6.22, y: 23.5), controlPoint2: NSPoint(x: 4.85, y: 21.66))
mainPath.line(to: NSPoint(x: 4.23, y: 19.53))
mainPath.line(to: NSPoint(x: 4.23, y: 19.53))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.92, y: 24.83))
mainPath.curve(to: NSPoint(x: 28.27, y: 19.94), controlPoint1: NSPoint(x: 24.87, y: 23.76), controlPoint2: NSPoint(x: 27.15, y: 22.02))
mainPath.curve(to: NSPoint(x: 27.58, y: 20), controlPoint1: NSPoint(x: 28.05, y: 19.98), controlPoint2: NSPoint(x: 27.82, y: 20))
mainPath.curve(to: NSPoint(x: 25.77, y: 19.53), controlPoint1: NSPoint(x: 26.91, y: 20), controlPoint2: NSPoint(x: 26.29, y: 19.83))
mainPath.curve(to: NSPoint(x: 21.92, y: 24.83), controlPoint1: NSPoint(x: 25.15, y: 21.66), controlPoint2: NSPoint(x: 23.78, y: 23.5))
mainPath.line(to: NSPoint(x: 21.92, y: 24.83))
mainPath.line(to: NSPoint(x: 21.92, y: 24.83))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawRaindrops(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 7.5, y: 20))
mainPath.curve(to: NSPoint(x: 10.01, y: 24.5), controlPoint1: NSPoint(x: 7.5, y: 21.68), controlPoint2: NSPoint(x: 10.01, y: 24.5))
mainPath.curve(to: NSPoint(x: 12.5, y: 20), controlPoint1: NSPoint(x: 10.01, y: 24.5), controlPoint2: NSPoint(x: 12.5, y: 21.68))
mainPath.curve(to: NSPoint(x: 10.01, y: 17.5), controlPoint1: NSPoint(x: 12.5, y: 18.8), controlPoint2: NSPoint(x: 11.69, y: 17.5))
mainPath.curve(to: NSPoint(x: 7.5, y: 20), controlPoint1: NSPoint(x: 8.33, y: 17.5), controlPoint2: NSPoint(x: 7.5, y: 18.7))
mainPath.line(to: NSPoint(x: 7.5, y: 20))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.5, y: 16))
mainPath.curve(to: NSPoint(x: 20.01, y: 20.5), controlPoint1: NSPoint(x: 17.5, y: 17.68), controlPoint2: NSPoint(x: 20.01, y: 20.5))
mainPath.curve(to: NSPoint(x: 22.5, y: 16), controlPoint1: NSPoint(x: 20.01, y: 20.5), controlPoint2: NSPoint(x: 22.5, y: 17.68))
mainPath.curve(to: NSPoint(x: 20.01, y: 13.5), controlPoint1: NSPoint(x: 22.5, y: 14.8), controlPoint2: NSPoint(x: 21.69, y: 13.5))
mainPath.curve(to: NSPoint(x: 17.5, y: 16), controlPoint1: NSPoint(x: 18.33, y: 13.5), controlPoint2: NSPoint(x: 17.5, y: 14.7))
mainPath.line(to: NSPoint(x: 17.5, y: 16))
mainPath.close()
mainPath.move(to: NSPoint(x: 10.5, y: 8))
mainPath.curve(to: NSPoint(x: 13.01, y: 12.5), controlPoint1: NSPoint(x: 10.5, y: 9.68), controlPoint2: NSPoint(x: 13.01, y: 12.5))
mainPath.curve(to: NSPoint(x: 15.5, y: 8), controlPoint1: NSPoint(x: 13.01, y: 12.5), controlPoint2: NSPoint(x: 15.5, y: 9.68))
mainPath.curve(to: NSPoint(x: 13.01, y: 5.5), controlPoint1: NSPoint(x: 15.5, y: 6.8), controlPoint2: NSPoint(x: 14.69, y: 5.5))
mainPath.curve(to: NSPoint(x: 10.5, y: 8), controlPoint1: NSPoint(x: 11.33, y: 5.5), controlPoint2: NSPoint(x: 10.5, y: 6.7))
mainPath.line(to: NSPoint(x: 10.5, y: 8))
mainPath.close()
mainPath.move(to: NSPoint(x: 18.5, y: 16))
mainPath.curve(to: NSPoint(x: 20.01, y: 18.9), controlPoint1: NSPoint(x: 18.5, y: 17), controlPoint2: NSPoint(x: 20.01, y: 18.9))
mainPath.curve(to: NSPoint(x: 21.5, y: 16), controlPoint1: NSPoint(x: 20.01, y: 18.9), controlPoint2: NSPoint(x: 21.5, y: 17))
mainPath.curve(to: NSPoint(x: 20.01, y: 14.5), controlPoint1: NSPoint(x: 21.5, y: 14.8), controlPoint2: NSPoint(x: 20.69, y: 14.5))
mainPath.curve(to: NSPoint(x: 18.5, y: 16), controlPoint1: NSPoint(x: 19.33, y: 14.5), controlPoint2: NSPoint(x: 18.5, y: 14.8))
mainPath.line(to: NSPoint(x: 18.5, y: 16))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.5, y: 20))
mainPath.curve(to: NSPoint(x: 10.01, y: 22.9), controlPoint1: NSPoint(x: 8.5, y: 21), controlPoint2: NSPoint(x: 10.01, y: 22.9))
mainPath.curve(to: NSPoint(x: 11.5, y: 20), controlPoint1: NSPoint(x: 10.01, y: 22.9), controlPoint2: NSPoint(x: 11.5, y: 21))
mainPath.curve(to: NSPoint(x: 10.01, y: 18.5), controlPoint1: NSPoint(x: 11.5, y: 18.8), controlPoint2: NSPoint(x: 10.69, y: 18.5))
mainPath.curve(to: NSPoint(x: 8.5, y: 20), controlPoint1: NSPoint(x: 9.33, y: 18.5), controlPoint2: NSPoint(x: 8.5, y: 18.8))
mainPath.line(to: NSPoint(x: 8.5, y: 20))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.5, y: 8))
mainPath.curve(to: NSPoint(x: 13.01, y: 10.9), controlPoint1: NSPoint(x: 11.5, y: 9), controlPoint2: NSPoint(x: 13.01, y: 10.9))
mainPath.curve(to: NSPoint(x: 14.5, y: 8), controlPoint1: NSPoint(x: 13.01, y: 10.9), controlPoint2: NSPoint(x: 14.5, y: 9))
mainPath.curve(to: NSPoint(x: 13.01, y: 6.5), controlPoint1: NSPoint(x: 14.5, y: 6.8), controlPoint2: NSPoint(x: 13.69, y: 6.5))
mainPath.curve(to: NSPoint(x: 11.5, y: 8), controlPoint1: NSPoint(x: 12.33, y: 6.5), controlPoint2: NSPoint(x: 11.5, y: 6.8))
mainPath.line(to: NSPoint(x: 11.5, y: 8))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawRaindrop(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 11, y: 12.79))
mainPath.curve(to: NSPoint(x: 15, y: 21), controlPoint1: NSPoint(x: 11, y: 15.32), controlPoint2: NSPoint(x: 15, y: 21))
mainPath.curve(to: NSPoint(x: 19, y: 12.79), controlPoint1: NSPoint(x: 15, y: 21), controlPoint2: NSPoint(x: 19, y: 15.32))
mainPath.curve(to: NSPoint(x: 15, y: 9), controlPoint1: NSPoint(x: 19, y: 10.7), controlPoint2: NSPoint(x: 17.21, y: 9))
mainPath.curve(to: NSPoint(x: 11, y: 12.79), controlPoint1: NSPoint(x: 12.79, y: 9), controlPoint2: NSPoint(x: 11, y: 10.7))
mainPath.line(to: NSPoint(x: 11, y: 12.79))
mainPath.close()
mainPath.move(to: NSPoint(x: 12, y: 12.79))
mainPath.curve(to: NSPoint(x: 15, y: 19.2), controlPoint1: NSPoint(x: 12, y: 14.5), controlPoint2: NSPoint(x: 15, y: 19.2))
mainPath.curve(to: NSPoint(x: 18, y: 12.79), controlPoint1: NSPoint(x: 15, y: 19.2), controlPoint2: NSPoint(x: 18, y: 14.5))
mainPath.curve(to: NSPoint(x: 15, y: 10), controlPoint1: NSPoint(x: 18, y: 11), controlPoint2: NSPoint(x: 16.21, y: 10))
mainPath.curve(to: NSPoint(x: 12, y: 12.79), controlPoint1: NSPoint(x: 13.79, y: 10), controlPoint2: NSPoint(x: 12, y: 11))
mainPath.line(to: NSPoint(x: 12, y: 12.79))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawSunglasses(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 17.01, y: 18.03))
mainPath.curve(to: NSPoint(x: 17.12, y: 17.03), controlPoint1: NSPoint(x: 16.98, y: 17.7), controlPoint2: NSPoint(x: 17.04, y: 17.35))
mainPath.line(to: NSPoint(x: 17.12, y: 17.03))
mainPath.line(to: NSPoint(x: 27.96, y: 17.03))
mainPath.curve(to: NSPoint(x: 27.99, y: 18.03), controlPoint1: NSPoint(x: 27.99, y: 17.32), controlPoint2: NSPoint(x: 28.02, y: 17.68))
mainPath.line(to: NSPoint(x: 17.01, y: 18.03))
mainPath.line(to: NSPoint(x: 17.01, y: 18.03))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.61, y: 19.03))
mainPath.curve(to: NSPoint(x: 18.03, y: 19.23), controlPoint1: NSPoint(x: 17.73, y: 19.11), controlPoint2: NSPoint(x: 17.87, y: 19.18))
mainPath.curve(to: NSPoint(x: 22.67, y: 20.02), controlPoint1: NSPoint(x: 19.82, y: 19.83), controlPoint2: NSPoint(x: 21.66, y: 20))
mainPath.curve(to: NSPoint(x: 27.31, y: 19.48), controlPoint1: NSPoint(x: 23.67, y: 20.05), controlPoint2: NSPoint(x: 26.53, y: 20.04))
mainPath.curve(to: NSPoint(x: 27.71, y: 19.03), controlPoint1: NSPoint(x: 27.48, y: 19.36), controlPoint2: NSPoint(x: 27.61, y: 19.2))
mainPath.line(to: NSPoint(x: 17.61, y: 19.03))
mainPath.line(to: NSPoint(x: 17.61, y: 19.03))
mainPath.close()
mainPath.move(to: NSPoint(x: 12.49, y: 16.03))
mainPath.curve(to: NSPoint(x: 12, y: 15.03), controlPoint1: NSPoint(x: 12.39, y: 15.75), controlPoint2: NSPoint(x: 12.21, y: 15.39))
mainPath.line(to: NSPoint(x: 12, y: 15.03))
mainPath.line(to: NSPoint(x: 2.47, y: 15.03))
mainPath.curve(to: NSPoint(x: 2.2, y: 16.03), controlPoint1: NSPoint(x: 2.36, y: 15.33), controlPoint2: NSPoint(x: 2.26, y: 15.69))
mainPath.line(to: NSPoint(x: 12.49, y: 16.03))
mainPath.line(to: NSPoint(x: 12.49, y: 16.03))
mainPath.line(to: NSPoint(x: 12.49, y: 16.03))
mainPath.close()
mainPath.move(to: NSPoint(x: 12.84, y: 17.03))
mainPath.curve(to: NSPoint(x: 12.95, y: 18.03), controlPoint1: NSPoint(x: 12.93, y: 17.35), controlPoint2: NSPoint(x: 12.99, y: 17.7))
mainPath.line(to: NSPoint(x: 12.95, y: 18.03))
mainPath.line(to: NSPoint(x: 2.02, y: 18.03))
mainPath.curve(to: NSPoint(x: 2.04, y: 17.03), controlPoint1: NSPoint(x: 1.99, y: 17.68), controlPoint2: NSPoint(x: 2.01, y: 17.32))
mainPath.line(to: NSPoint(x: 12.84, y: 17.03))
mainPath.line(to: NSPoint(x: 12.84, y: 17.03))
mainPath.line(to: NSPoint(x: 12.84, y: 17.03))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.19, y: 14.03))
mainPath.curve(to: NSPoint(x: 11.04, y: 13.91), controlPoint1: NSPoint(x: 11.14, y: 13.99), controlPoint2: NSPoint(x: 11.09, y: 13.95))
mainPath.curve(to: NSPoint(x: 7.11, y: 13.08), controlPoint1: NSPoint(x: 10.38, y: 13.45), controlPoint2: NSPoint(x: 8.93, y: 13.08))
mainPath.curve(to: NSPoint(x: 4.34, y: 13.32), controlPoint1: NSPoint(x: 6.05, y: 13.08), controlPoint2: NSPoint(x: 5.19, y: 13.13))
mainPath.curve(to: NSPoint(x: 3, y: 14.03), controlPoint1: NSPoint(x: 3.74, y: 13.45), controlPoint2: NSPoint(x: 3.35, y: 13.58))
mainPath.line(to: NSPoint(x: 11.19, y: 14.03))
mainPath.line(to: NSPoint(x: 11.19, y: 14.03))
mainPath.line(to: NSPoint(x: 11.19, y: 14.03))
mainPath.close()
mainPath.move(to: NSPoint(x: 12.3, y: 19.03))
mainPath.curve(to: NSPoint(x: 11.94, y: 19.2), controlPoint1: NSPoint(x: 12.2, y: 19.1), controlPoint2: NSPoint(x: 12.08, y: 19.15))
mainPath.curve(to: NSPoint(x: 7.32, y: 19.98), controlPoint1: NSPoint(x: 10.16, y: 19.79), controlPoint2: NSPoint(x: 8.32, y: 19.95))
mainPath.curve(to: NSPoint(x: 2.7, y: 19.44), controlPoint1: NSPoint(x: 6.32, y: 20.01), controlPoint2: NSPoint(x: 3.47, y: 19.99))
mainPath.curve(to: NSPoint(x: 2.32, y: 19.03), controlPoint1: NSPoint(x: 2.54, y: 19.33), controlPoint2: NSPoint(x: 2.42, y: 19.19))
mainPath.line(to: NSPoint(x: 12.3, y: 19.03))
mainPath.line(to: NSPoint(x: 12.3, y: 19.03))
mainPath.line(to: NSPoint(x: 12.3, y: 19.03))
mainPath.close()
mainPath.move(to: NSPoint(x: 27.55, y: 15.03))
mainPath.curve(to: NSPoint(x: 27.81, y: 16.03), controlPoint1: NSPoint(x: 27.65, y: 15.33), controlPoint2: NSPoint(x: 27.74, y: 15.69))
mainPath.line(to: NSPoint(x: 27.81, y: 16.03))
mainPath.line(to: NSPoint(x: 17.47, y: 16.03))
mainPath.curve(to: NSPoint(x: 17.96, y: 15.03), controlPoint1: NSPoint(x: 17.57, y: 15.75), controlPoint2: NSPoint(x: 17.74, y: 15.39))
mainPath.line(to: NSPoint(x: 27.55, y: 15.03))
mainPath.line(to: NSPoint(x: 27.55, y: 15.03))
mainPath.line(to: NSPoint(x: 27.55, y: 15.03))
mainPath.close()
mainPath.move(to: NSPoint(x: 27.03, y: 14.03))
mainPath.curve(to: NSPoint(x: 25.65, y: 13.28), controlPoint1: NSPoint(x: 26.67, y: 13.55), controlPoint2: NSPoint(x: 26.28, y: 13.42))
mainPath.curve(to: NSPoint(x: 22.88, y: 13.03), controlPoint1: NSPoint(x: 24.81, y: 13.08), controlPoint2: NSPoint(x: 23.94, y: 13.03))
mainPath.curve(to: NSPoint(x: 18.93, y: 13.88), controlPoint1: NSPoint(x: 21.05, y: 13.03), controlPoint2: NSPoint(x: 19.6, y: 13.41))
mainPath.curve(to: NSPoint(x: 18.74, y: 14.03), controlPoint1: NSPoint(x: 18.87, y: 13.92), controlPoint2: NSPoint(x: 18.81, y: 13.98))
mainPath.line(to: NSPoint(x: 27.03, y: 14.03))
mainPath.line(to: NSPoint(x: 27.03, y: 14.03))
mainPath.line(to: NSPoint(x: 27.03, y: 14.03))
mainPath.close()
mainPath.move(to: NSPoint(x: 14.06, y: 20.02))
mainPath.curve(to: NSPoint(x: 0.37, y: 20.64), controlPoint1: NSPoint(x: 9.69, y: 21.23), controlPoint2: NSPoint(x: 3.53, y: 21.17))
mainPath.curve(to: NSPoint(x: 0.26, y: 18.75), controlPoint1: NSPoint(x: -0.02, y: 20.57), controlPoint2: NSPoint(x: -0.08, y: 18.82))
mainPath.curve(to: NSPoint(x: 1.16, y: 17.87), controlPoint1: NSPoint(x: 0.89, y: 18.5), controlPoint2: NSPoint(x: 1.16, y: 17.87))
mainPath.curve(to: NSPoint(x: 1.89, y: 15.03), controlPoint1: NSPoint(x: 1.16, y: 17.87), controlPoint2: NSPoint(x: 1.34, y: 17.31))
mainPath.curve(to: NSPoint(x: 3.72, y: 12.47), controlPoint1: NSPoint(x: 2.43, y: 12.75), controlPoint2: NSPoint(x: 3.72, y: 12.47))
mainPath.curve(to: NSPoint(x: 7.14, y: 12.08), controlPoint1: NSPoint(x: 3.72, y: 12.47), controlPoint2: NSPoint(x: 5.31, y: 12.08))
mainPath.curve(to: NSPoint(x: 11.23, y: 12.75), controlPoint1: NSPoint(x: 8.96, y: 12.08), controlPoint2: NSPoint(x: 10.06, y: 12.17))
mainPath.curve(to: NSPoint(x: 12.91, y: 14.97), controlPoint1: NSPoint(x: 12.4, y: 13.34), controlPoint2: NSPoint(x: 12.91, y: 14.97))
mainPath.curve(to: NSPoint(x: 13.9, y: 17.7), controlPoint1: NSPoint(x: 12.91, y: 14.97), controlPoint2: NSPoint(x: 13.5, y: 16.37))
mainPath.curve(to: NSPoint(x: 16.1, y: 17.7), controlPoint1: NSPoint(x: 14.03, y: 18.11), controlPoint2: NSPoint(x: 15.97, y: 18.11))
mainPath.curve(to: NSPoint(x: 17.09, y: 14.97), controlPoint1: NSPoint(x: 16.5, y: 16.37), controlPoint2: NSPoint(x: 17.09, y: 14.97))
mainPath.curve(to: NSPoint(x: 18.77, y: 12.75), controlPoint1: NSPoint(x: 17.09, y: 14.97), controlPoint2: NSPoint(x: 17.6, y: 13.34))
mainPath.curve(to: NSPoint(x: 22.86, y: 12.08), controlPoint1: NSPoint(x: 19.94, y: 12.17), controlPoint2: NSPoint(x: 21.04, y: 12.08))
mainPath.curve(to: NSPoint(x: 26.28, y: 12.47), controlPoint1: NSPoint(x: 24.69, y: 12.08), controlPoint2: NSPoint(x: 26.28, y: 12.47))
mainPath.curve(to: NSPoint(x: 28.11, y: 15.03), controlPoint1: NSPoint(x: 26.28, y: 12.47), controlPoint2: NSPoint(x: 27.57, y: 12.75))
mainPath.curve(to: NSPoint(x: 28.84, y: 17.87), controlPoint1: NSPoint(x: 28.66, y: 17.31), controlPoint2: NSPoint(x: 28.84, y: 17.87))
mainPath.curve(to: NSPoint(x: 29.74, y: 18.75), controlPoint1: NSPoint(x: 28.84, y: 17.87), controlPoint2: NSPoint(x: 29.11, y: 18.5))
mainPath.curve(to: NSPoint(x: 29.63, y: 20.64), controlPoint1: NSPoint(x: 30.08, y: 18.82), controlPoint2: NSPoint(x: 30.02, y: 20.57))
mainPath.curve(to: NSPoint(x: 15.94, y: 20.02), controlPoint1: NSPoint(x: 26.47, y: 21.17), controlPoint2: NSPoint(x: 20.31, y: 21.23))
mainPath.curve(to: NSPoint(x: 14.06, y: 20.02), controlPoint1: NSPoint(x: 15.64, y: 19.96), controlPoint2: NSPoint(x: 14.36, y: 19.96))
mainPath.line(to: NSPoint(x: 14.06, y: 20.02))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawStars(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 12.76, y: 15.36))
mainPath.line(to: NSPoint(x: 15, y: 16))
mainPath.line(to: NSPoint(x: 12.76, y: 16.64))
mainPath.line(to: NSPoint(x: 12.76, y: 16.64))
mainPath.line(to: NSPoint(x: 11.5, y: 20))
mainPath.line(to: NSPoint(x: 10.24, y: 16.64))
mainPath.line(to: NSPoint(x: 8, y: 16))
mainPath.line(to: NSPoint(x: 10.24, y: 15.36))
mainPath.line(to: NSPoint(x: 11.5, y: 12))
mainPath.line(to: NSPoint(x: 12.76, y: 15.36))
mainPath.line(to: NSPoint(x: 12.76, y: 15.36))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.71, y: 21.76))
mainPath.line(to: NSPoint(x: 21.5, y: 25))
mainPath.line(to: NSPoint(x: 20.29, y: 21.76))
mainPath.line(to: NSPoint(x: 18, y: 21))
mainPath.line(to: NSPoint(x: 20.29, y: 20.24))
mainPath.line(to: NSPoint(x: 21.5, y: 17))
mainPath.line(to: NSPoint(x: 22.71, y: 20.24))
mainPath.line(to: NSPoint(x: 25, y: 21))
mainPath.line(to: NSPoint(x: 22.71, y: 21.76))
mainPath.line(to: NSPoint(x: 22.71, y: 21.76))
mainPath.line(to: NSPoint(x: 22.71, y: 21.76))
mainPath.close()
mainPath.move(to: NSPoint(x: 20.71, y: 9.76))
mainPath.line(to: NSPoint(x: 19.5, y: 13))
mainPath.line(to: NSPoint(x: 18.29, y: 9.76))
mainPath.line(to: NSPoint(x: 16, y: 9))
mainPath.line(to: NSPoint(x: 18.29, y: 8.24))
mainPath.line(to: NSPoint(x: 19.5, y: 5))
mainPath.line(to: NSPoint(x: 20.71, y: 8.24))
mainPath.line(to: NSPoint(x: 23, y: 9))
mainPath.line(to: NSPoint(x: 20.71, y: 9.76))
mainPath.line(to: NSPoint(x: 20.71, y: 9.76))
mainPath.line(to: NSPoint(x: 20.71, y: 9.76))
mainPath.close()
mainPath.move(to: NSPoint(x: 13.46, y: 17.51))
mainPath.line(to: NSPoint(x: 11.5, y: 23))
mainPath.line(to: NSPoint(x: 9.54, y: 17.51))
mainPath.line(to: NSPoint(x: 5, y: 16))
mainPath.line(to: NSPoint(x: 9.54, y: 14.49))
mainPath.line(to: NSPoint(x: 11.5, y: 9))
mainPath.line(to: NSPoint(x: 13.46, y: 14.49))
mainPath.line(to: NSPoint(x: 18, y: 16))
mainPath.line(to: NSPoint(x: 13.46, y: 17.51))
mainPath.line(to: NSPoint(x: 13.46, y: 17.51))
mainPath.line(to: NSPoint(x: 13.46, y: 17.51))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawClouds2(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 25.16, y: 12.14))
mainPath.line(to: NSPoint(x: 26.12, y: 12.14))
mainPath.curve(to: NSPoint(x: 30, y: 15.95), controlPoint1: NSPoint(x: 28.26, y: 12.14), controlPoint2: NSPoint(x: 30, y: 13.85))
mainPath.curve(to: NSPoint(x: 26.98, y: 19.68), controlPoint1: NSPoint(x: 30, y: 17.77), controlPoint2: NSPoint(x: 28.71, y: 19.29))
mainPath.curve(to: NSPoint(x: 27.1, y: 20.73), controlPoint1: NSPoint(x: 27.06, y: 20.02), controlPoint2: NSPoint(x: 27.1, y: 20.37))
mainPath.curve(to: NSPoint(x: 22.26, y: 25.5), controlPoint1: NSPoint(x: 27.1, y: 23.36), controlPoint2: NSPoint(x: 24.93, y: 25.5))
mainPath.curve(to: NSPoint(x: 18.04, y: 23.07), controlPoint1: NSPoint(x: 20.45, y: 25.5), controlPoint2: NSPoint(x: 18.87, y: 24.52))
mainPath.curve(to: NSPoint(x: 15.97, y: 23.59), controlPoint1: NSPoint(x: 17.43, y: 23.4), controlPoint2: NSPoint(x: 16.72, y: 23.59))
mainPath.curve(to: NSPoint(x: 11.76, y: 20.41), controlPoint1: NSPoint(x: 13.95, y: 23.59), controlPoint2: NSPoint(x: 12.26, y: 22.24))
mainPath.curve(to: NSPoint(x: 9.68, y: 20.73), controlPoint1: NSPoint(x: 11.1, y: 20.61), controlPoint2: NSPoint(x: 10.4, y: 20.73))
mainPath.curve(to: NSPoint(x: 2.9, y: 14.05), controlPoint1: NSPoint(x: 5.94, y: 20.73), controlPoint2: NSPoint(x: 2.9, y: 17.74))
mainPath.curve(to: NSPoint(x: 2.91, y: 13.65), controlPoint1: NSPoint(x: 2.9, y: 13.91), controlPoint2: NSPoint(x: 2.91, y: 13.78))
mainPath.curve(to: NSPoint(x: 0, y: 9.27), controlPoint1: NSPoint(x: 1.2, y: 12.92), controlPoint2: NSPoint(x: 0, y: 11.23))
mainPath.curve(to: NSPoint(x: 4.84, y: 4.5), controlPoint1: NSPoint(x: 0, y: 6.64), controlPoint2: NSPoint(x: 2.16, y: 4.5))
mainPath.line(to: NSPoint(x: 21.29, y: 4.5))
mainPath.curve(to: NSPoint(x: 26.13, y: 9.27), controlPoint1: NSPoint(x: 23.96, y: 4.5), controlPoint2: NSPoint(x: 26.13, y: 6.64))
mainPath.curve(to: NSPoint(x: 25.16, y: 12.14), controlPoint1: NSPoint(x: 26.13, y: 10.35), controlPoint2: NSPoint(x: 25.77, y: 11.34))
mainPath.line(to: NSPoint(x: 25.16, y: 12.14))
mainPath.line(to: NSPoint(x: 25.16, y: 12.14))
mainPath.close()
mainPath.move(to: NSPoint(x: 24.2, y: 13.09))
mainPath.line(to: NSPoint(x: 26.13, y: 13.09))
mainPath.curve(to: NSPoint(x: 29.03, y: 15.95), controlPoint1: NSPoint(x: 27.73, y: 13.09), controlPoint2: NSPoint(x: 29.03, y: 14.37))
mainPath.curve(to: NSPoint(x: 26.13, y: 18.82), controlPoint1: NSPoint(x: 29.03, y: 17.53), controlPoint2: NSPoint(x: 27.73, y: 18.82))
mainPath.line(to: NSPoint(x: 25.61, y: 18.82))
mainPath.curve(to: NSPoint(x: 26.13, y: 20.73), controlPoint1: NSPoint(x: 25.94, y: 19.38), controlPoint2: NSPoint(x: 26.13, y: 20.03))
mainPath.curve(to: NSPoint(x: 22.26, y: 24.55), controlPoint1: NSPoint(x: 26.13, y: 22.84), controlPoint2: NSPoint(x: 24.4, y: 24.55))
mainPath.curve(to: NSPoint(x: 18.48, y: 21.54), controlPoint1: NSPoint(x: 20.4, y: 24.55), controlPoint2: NSPoint(x: 18.85, y: 23.26))
mainPath.curve(to: NSPoint(x: 15.97, y: 22.64), controlPoint1: NSPoint(x: 17.86, y: 22.21), controlPoint2: NSPoint(x: 16.96, y: 22.64))
mainPath.curve(to: NSPoint(x: 12.67, y: 20.04), controlPoint1: NSPoint(x: 14.36, y: 22.64), controlPoint2: NSPoint(x: 13.01, y: 21.53))
mainPath.curve(to: NSPoint(x: 15.11, y: 18.04), controlPoint1: NSPoint(x: 13.63, y: 19.57), controlPoint2: NSPoint(x: 14.47, y: 18.88))
mainPath.curve(to: NSPoint(x: 17.9, y: 18.82), controlPoint1: NSPoint(x: 15.92, y: 18.53), controlPoint2: NSPoint(x: 16.88, y: 18.82))
mainPath.curve(to: NSPoint(x: 23.23, y: 13.65), controlPoint1: NSPoint(x: 20.82, y: 18.82), controlPoint2: NSPoint(x: 23.18, y: 16.51))
mainPath.curve(to: NSPoint(x: 24.2, y: 13.09), controlPoint1: NSPoint(x: 23.57, y: 13.5), controlPoint2: NSPoint(x: 23.9, y: 13.31))
mainPath.line(to: NSPoint(x: 24.2, y: 13.09))
mainPath.line(to: NSPoint(x: 24.2, y: 13.09))
mainPath.close()
mainPath.move(to: NSPoint(x: 0.97, y: 9.27))
mainPath.curve(to: NSPoint(x: 4.84, y: 5.45), controlPoint1: NSPoint(x: 0.97, y: 7.16), controlPoint2: NSPoint(x: 2.71, y: 5.45))
mainPath.line(to: NSPoint(x: 21.29, y: 5.45))
mainPath.curve(to: NSPoint(x: 25.16, y: 9.27), controlPoint1: NSPoint(x: 23.43, y: 5.45), controlPoint2: NSPoint(x: 25.16, y: 7.17))
mainPath.curve(to: NSPoint(x: 22.22, y: 12.98), controlPoint1: NSPoint(x: 25.16, y: 11.06), controlPoint2: NSPoint(x: 23.9, y: 12.57))
mainPath.curve(to: NSPoint(x: 22.26, y: 13.57), controlPoint1: NSPoint(x: 22.24, y: 13.17), controlPoint2: NSPoint(x: 22.26, y: 13.37))
mainPath.curve(to: NSPoint(x: 17.9, y: 17.86), controlPoint1: NSPoint(x: 22.26, y: 15.94), controlPoint2: NSPoint(x: 20.31, y: 17.86))
mainPath.curve(to: NSPoint(x: 14.86, y: 16.64), controlPoint1: NSPoint(x: 16.72, y: 17.86), controlPoint2: NSPoint(x: 15.64, y: 17.4))
mainPath.curve(to: NSPoint(x: 9.68, y: 19.77), controlPoint1: NSPoint(x: 13.9, y: 18.5), controlPoint2: NSPoint(x: 11.94, y: 19.77))
mainPath.curve(to: NSPoint(x: 3.87, y: 14.05), controlPoint1: NSPoint(x: 6.47, y: 19.77), controlPoint2: NSPoint(x: 3.87, y: 17.21))
mainPath.curve(to: NSPoint(x: 3.97, y: 12.99), controlPoint1: NSPoint(x: 3.87, y: 13.69), controlPoint2: NSPoint(x: 3.9, y: 13.33))
mainPath.curve(to: NSPoint(x: 0.97, y: 9.27), controlPoint1: NSPoint(x: 2.25, y: 12.6), controlPoint2: NSPoint(x: 0.97, y: 11.08))
mainPath.line(to: NSPoint(x: 0.97, y: 9.27))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoonrise(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 18.07, y: 11.82))
mainPath.curve(to: NSPoint(x: 19.84, y: 14.67), controlPoint1: NSPoint(x: 18.92, y: 12.55), controlPoint2: NSPoint(x: 19.55, y: 13.54))
mainPath.curve(to: NSPoint(x: 19.99, y: 15.76), controlPoint1: NSPoint(x: 19.92, y: 15.02), controlPoint2: NSPoint(x: 19.98, y: 15.39))
mainPath.curve(to: NSPoint(x: 18.5, y: 15.51), controlPoint1: NSPoint(x: 19.53, y: 15.59), controlPoint2: NSPoint(x: 19.02, y: 15.51))
mainPath.curve(to: NSPoint(x: 14, y: 20.01), controlPoint1: NSPoint(x: 16.01, y: 15.51), controlPoint2: NSPoint(x: 14, y: 17.52))
mainPath.curve(to: NSPoint(x: 14.25, y: 21.5), controlPoint1: NSPoint(x: 14, y: 20.53), controlPoint2: NSPoint(x: 14.09, y: 21.03))
mainPath.curve(to: NSPoint(x: 13.16, y: 21.34), controlPoint1: NSPoint(x: 13.88, y: 21.48), controlPoint2: NSPoint(x: 13.51, y: 21.43))
mainPath.curve(to: NSPoint(x: 9, y: 16.01), controlPoint1: NSPoint(x: 10.77, y: 20.74), controlPoint2: NSPoint(x: 9, y: 18.58))
mainPath.curve(to: NSPoint(x: 11.47, y: 11.41), controlPoint1: NSPoint(x: 9, y: 14.09), controlPoint2: NSPoint(x: 9.98, y: 12.4))
mainPath.line(to: NSPoint(x: 12.26, y: 12.1))
mainPath.curve(to: NSPoint(x: 10, y: 16.01), controlPoint1: NSPoint(x: 10.91, y: 12.88), controlPoint2: NSPoint(x: 10, y: 14.34))
mainPath.curve(to: NSPoint(x: 13.01, y: 20.25), controlPoint1: NSPoint(x: 10, y: 17.97), controlPoint2: NSPoint(x: 11.25, y: 19.64))
mainPath.curve(to: NSPoint(x: 13, y: 20.01), controlPoint1: NSPoint(x: 13, y: 20.17), controlPoint2: NSPoint(x: 13, y: 20.09))
mainPath.curve(to: NSPoint(x: 18.5, y: 14.51), controlPoint1: NSPoint(x: 13, y: 16.97), controlPoint2: NSPoint(x: 15.46, y: 14.51))
mainPath.curve(to: NSPoint(x: 18.75, y: 14.51), controlPoint1: NSPoint(x: 18.58, y: 14.51), controlPoint2: NSPoint(x: 18.66, y: 14.51))
mainPath.curve(to: NSPoint(x: 17.3, y: 12.48), controlPoint1: NSPoint(x: 18.46, y: 13.71), controlPoint2: NSPoint(x: 17.96, y: 13.01))
mainPath.line(to: NSPoint(x: 18.07, y: 11.82))
mainPath.line(to: NSPoint(x: 18.07, y: 11.82))
mainPath.line(to: NSPoint(x: 18.07, y: 11.82))
mainPath.close()
mainPath.move(to: NSPoint(x: 6.01, y: 9.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 9), controlPoint1: NSPoint(x: 5.73, y: 9.5), controlPoint2: NSPoint(x: 5.5, y: 9.27))
mainPath.curve(to: NSPoint(x: 6.01, y: 8.5), controlPoint1: NSPoint(x: 5.5, y: 8.72), controlPoint2: NSPoint(x: 5.73, y: 8.5))
mainPath.line(to: NSPoint(x: 12.08, y: 8.5))
mainPath.line(to: NSPoint(x: 13.25, y: 9.5))
mainPath.line(to: NSPoint(x: 15, y: 11))
mainPath.line(to: NSPoint(x: 16.75, y: 9.5))
mainPath.line(to: NSPoint(x: 17.92, y: 8.5))
mainPath.line(to: NSPoint(x: 23.99, y: 8.5))
mainPath.curve(to: NSPoint(x: 24.5, y: 9), controlPoint1: NSPoint(x: 24.27, y: 8.5), controlPoint2: NSPoint(x: 24.5, y: 8.73))
mainPath.curve(to: NSPoint(x: 23.99, y: 9.5), controlPoint1: NSPoint(x: 24.5, y: 9.28), controlPoint2: NSPoint(x: 24.27, y: 9.5))
mainPath.line(to: NSPoint(x: 18.5, y: 9.5))
mainPath.line(to: NSPoint(x: 15, y: 12.5))
mainPath.line(to: NSPoint(x: 11.5, y: 9.5))
mainPath.line(to: NSPoint(x: 6.01, y: 9.5))
mainPath.line(to: NSPoint(x: 6.01, y: 9.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoonset(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 19.84, y: 16.67))
mainPath.curve(to: NSPoint(x: 14.5, y: 12.51), controlPoint1: NSPoint(x: 19.24, y: 14.28), controlPoint2: NSPoint(x: 17.08, y: 12.51))
mainPath.curve(to: NSPoint(x: 9, y: 18.01), controlPoint1: NSPoint(x: 11.46, y: 12.51), controlPoint2: NSPoint(x: 9, y: 14.97))
mainPath.curve(to: NSPoint(x: 13.16, y: 23.34), controlPoint1: NSPoint(x: 9, y: 20.58), controlPoint2: NSPoint(x: 10.77, y: 22.74))
mainPath.curve(to: NSPoint(x: 14.25, y: 23.5), controlPoint1: NSPoint(x: 13.51, y: 23.43), controlPoint2: NSPoint(x: 13.88, y: 23.48))
mainPath.curve(to: NSPoint(x: 14, y: 22.01), controlPoint1: NSPoint(x: 14.09, y: 23.03), controlPoint2: NSPoint(x: 14, y: 22.53))
mainPath.curve(to: NSPoint(x: 18.5, y: 17.51), controlPoint1: NSPoint(x: 14, y: 19.52), controlPoint2: NSPoint(x: 16.01, y: 17.51))
mainPath.curve(to: NSPoint(x: 19.99, y: 17.76), controlPoint1: NSPoint(x: 19.02, y: 17.51), controlPoint2: NSPoint(x: 19.53, y: 17.59))
mainPath.curve(to: NSPoint(x: 19.84, y: 16.67), controlPoint1: NSPoint(x: 19.98, y: 17.39), controlPoint2: NSPoint(x: 19.92, y: 17.02))
mainPath.line(to: NSPoint(x: 19.84, y: 16.67))
mainPath.close()
mainPath.move(to: NSPoint(x: 10, y: 18.01))
mainPath.curve(to: NSPoint(x: 13.01, y: 22.25), controlPoint1: NSPoint(x: 10, y: 19.97), controlPoint2: NSPoint(x: 11.25, y: 21.64))
mainPath.curve(to: NSPoint(x: 13, y: 22.01), controlPoint1: NSPoint(x: 13, y: 22.17), controlPoint2: NSPoint(x: 13, y: 22.09))
mainPath.curve(to: NSPoint(x: 18.5, y: 16.51), controlPoint1: NSPoint(x: 13, y: 18.97), controlPoint2: NSPoint(x: 15.46, y: 16.51))
mainPath.curve(to: NSPoint(x: 18.75, y: 16.51), controlPoint1: NSPoint(x: 18.58, y: 16.51), controlPoint2: NSPoint(x: 18.66, y: 16.51))
mainPath.curve(to: NSPoint(x: 14.5, y: 13.51), controlPoint1: NSPoint(x: 18.13, y: 14.76), controlPoint2: NSPoint(x: 16.46, y: 13.51))
mainPath.curve(to: NSPoint(x: 10, y: 18.01), controlPoint1: NSPoint(x: 12.01, y: 13.51), controlPoint2: NSPoint(x: 10, y: 15.52))
mainPath.line(to: NSPoint(x: 10, y: 18.01))
mainPath.close()
mainPath.move(to: NSPoint(x: 6.01, y: 9.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 10), controlPoint1: NSPoint(x: 5.73, y: 9.5), controlPoint2: NSPoint(x: 5.5, y: 9.73))
mainPath.curve(to: NSPoint(x: 6.01, y: 10.5), controlPoint1: NSPoint(x: 5.5, y: 10.28), controlPoint2: NSPoint(x: 5.73, y: 10.5))
mainPath.line(to: NSPoint(x: 12.08, y: 10.5))
mainPath.line(to: NSPoint(x: 13.25, y: 9.5))
mainPath.line(to: NSPoint(x: 15, y: 8))
mainPath.line(to: NSPoint(x: 16.75, y: 9.5))
mainPath.line(to: NSPoint(x: 17.92, y: 10.5))
mainPath.line(to: NSPoint(x: 23.99, y: 10.5))
mainPath.curve(to: NSPoint(x: 24.5, y: 10), controlPoint1: NSPoint(x: 24.27, y: 10.5), controlPoint2: NSPoint(x: 24.5, y: 10.27))
mainPath.curve(to: NSPoint(x: 23.99, y: 9.5), controlPoint1: NSPoint(x: 24.5, y: 9.72), controlPoint2: NSPoint(x: 24.27, y: 9.5))
mainPath.line(to: NSPoint(x: 18.5, y: 9.5))
mainPath.line(to: NSPoint(x: 15, y: 6.5))
mainPath.line(to: NSPoint(x: 11.5, y: 9.5))
mainPath.line(to: NSPoint(x: 6.01, y: 9.5))
mainPath.line(to: NSPoint(x: 6.01, y: 9.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawWind(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 28.5, y: 17.5))
mainPath.curve(to: NSPoint(x: 24.5, y: 21.5), controlPoint1: NSPoint(x: 28.5, y: 19.71), controlPoint2: NSPoint(x: 26.7, y: 21.5))
mainPath.curve(to: NSPoint(x: 20.5, y: 17.5), controlPoint1: NSPoint(x: 22.29, y: 21.5), controlPoint2: NSPoint(x: 20.5, y: 19.71))
mainPath.line(to: NSPoint(x: 21.5, y: 17.5))
mainPath.curve(to: NSPoint(x: 24.5, y: 20.5), controlPoint1: NSPoint(x: 21.5, y: 19.16), controlPoint2: NSPoint(x: 22.85, y: 20.5))
mainPath.curve(to: NSPoint(x: 27.5, y: 17.5), controlPoint1: NSPoint(x: 26.16, y: 20.5), controlPoint2: NSPoint(x: 27.5, y: 19.15))
mainPath.curve(to: NSPoint(x: 24.49, y: 14.5), controlPoint1: NSPoint(x: 27.5, y: 15.84), controlPoint2: NSPoint(x: 26.16, y: 14.5))
mainPath.line(to: NSPoint(x: 1.5, y: 14.5))
mainPath.line(to: NSPoint(x: 1.5, y: 13.5))
mainPath.line(to: NSPoint(x: 24.5, y: 13.5))
mainPath.curve(to: NSPoint(x: 28.5, y: 17.5), controlPoint1: NSPoint(x: 26.71, y: 13.5), controlPoint2: NSPoint(x: 28.5, y: 15.3))
mainPath.line(to: NSPoint(x: 28.5, y: 17.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 19.5, y: 18.5))
mainPath.curve(to: NSPoint(x: 16.5, y: 21.5), controlPoint1: NSPoint(x: 19.5, y: 20.16), controlPoint2: NSPoint(x: 18.15, y: 21.5))
mainPath.curve(to: NSPoint(x: 13.5, y: 18.51), controlPoint1: NSPoint(x: 14.84, y: 21.5), controlPoint2: NSPoint(x: 13.5, y: 20.16))
mainPath.line(to: NSPoint(x: 13.5, y: 18.5))
mainPath.line(to: NSPoint(x: 14.5, y: 18.5))
mainPath.curve(to: NSPoint(x: 16.5, y: 20.5), controlPoint1: NSPoint(x: 14.5, y: 19.6), controlPoint2: NSPoint(x: 15.39, y: 20.5))
mainPath.curve(to: NSPoint(x: 18.5, y: 18.5), controlPoint1: NSPoint(x: 17.6, y: 20.5), controlPoint2: NSPoint(x: 18.5, y: 19.61))
mainPath.curve(to: NSPoint(x: 16.49, y: 16.5), controlPoint1: NSPoint(x: 18.5, y: 17.4), controlPoint2: NSPoint(x: 17.6, y: 16.5))
mainPath.line(to: NSPoint(x: 4.5, y: 16.5))
mainPath.line(to: NSPoint(x: 4.5, y: 15.5))
mainPath.line(to: NSPoint(x: 16.5, y: 15.5))
mainPath.curve(to: NSPoint(x: 19.5, y: 18.5), controlPoint1: NSPoint(x: 18.16, y: 15.5), controlPoint2: NSPoint(x: 19.5, y: 16.85))
mainPath.line(to: NSPoint(x: 19.5, y: 18.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 23.5, y: 10.5))
mainPath.curve(to: NSPoint(x: 21.5, y: 8.5), controlPoint1: NSPoint(x: 23.5, y: 9.4), controlPoint2: NSPoint(x: 22.61, y: 8.5))
mainPath.line(to: NSPoint(x: 21.5, y: 8.5))
mainPath.curve(to: NSPoint(x: 19.5, y: 10.49), controlPoint1: NSPoint(x: 20.4, y: 8.5), controlPoint2: NSPoint(x: 19.5, y: 9.39))
mainPath.line(to: NSPoint(x: 19.5, y: 10.5))
mainPath.line(to: NSPoint(x: 20.5, y: 10.5))
mainPath.curve(to: NSPoint(x: 21.5, y: 9.5), controlPoint1: NSPoint(x: 20.5, y: 9.95), controlPoint2: NSPoint(x: 20.94, y: 9.5))
mainPath.line(to: NSPoint(x: 21.5, y: 9.5))
mainPath.curve(to: NSPoint(x: 22.5, y: 10.5), controlPoint1: NSPoint(x: 22.05, y: 9.5), controlPoint2: NSPoint(x: 22.5, y: 9.94))
mainPath.line(to: NSPoint(x: 22.5, y: 10.5))
mainPath.curve(to: NSPoint(x: 21.49, y: 11.5), controlPoint1: NSPoint(x: 22.5, y: 11.05), controlPoint2: NSPoint(x: 22.05, y: 11.5))
mainPath.line(to: NSPoint(x: 7.5, y: 11.5))
mainPath.line(to: NSPoint(x: 7.5, y: 12.5))
mainPath.line(to: NSPoint(x: 21.51, y: 12.5))
mainPath.curve(to: NSPoint(x: 23.5, y: 10.5), controlPoint1: NSPoint(x: 22.61, y: 12.5), controlPoint2: NSPoint(x: 23.5, y: 11.61))
mainPath.line(to: NSPoint(x: 23.5, y: 10.5))
mainPath.line(to: NSPoint(x: 23.5, y: 10.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawFullMoon(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath(ovalIn: NSRect(x: 8, y: 10, width: 12, height: 12))
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoonCrescent(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 16, y: 23))
mainPath.curve(to: NSPoint(x: 11, y: 18), controlPoint1: NSPoint(x: 13.24, y: 23), controlPoint2: NSPoint(x: 11, y: 20.76))
mainPath.curve(to: NSPoint(x: 16, y: 13), controlPoint1: NSPoint(x: 11, y: 15.24), controlPoint2: NSPoint(x: 13.24, y: 13))
mainPath.curve(to: NSPoint(x: 13, y: 18), controlPoint1: NSPoint(x: 14.34, y: 13), controlPoint2: NSPoint(x: 13, y: 15.24))
mainPath.curve(to: NSPoint(x: 16, y: 23), controlPoint1: NSPoint(x: 13, y: 20.76), controlPoint2: NSPoint(x: 14.34, y: 23))
mainPath.line(to: NSPoint(x: 16, y: 23))
mainPath.line(to: NSPoint(x: 16, y: 23))
mainPath.close()
mainPath.move(to: NSPoint(x: 16, y: 12))
mainPath.curve(to: NSPoint(x: 22, y: 18), controlPoint1: NSPoint(x: 19.31, y: 12), controlPoint2: NSPoint(x: 22, y: 14.69))
mainPath.curve(to: NSPoint(x: 16, y: 24), controlPoint1: NSPoint(x: 22, y: 21.31), controlPoint2: NSPoint(x: 19.31, y: 24))
mainPath.curve(to: NSPoint(x: 10, y: 18), controlPoint1: NSPoint(x: 12.69, y: 24), controlPoint2: NSPoint(x: 10, y: 21.31))
mainPath.curve(to: NSPoint(x: 16, y: 12), controlPoint1: NSPoint(x: 10, y: 14.69), controlPoint2: NSPoint(x: 12.69, y: 12))
mainPath.line(to: NSPoint(x: 16, y: 12))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoonHalf(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// half-moon Drawing
let halfmoonPath = NSBezierPath()
halfmoonPath.move(to: NSPoint(x: 14, y: 9))
halfmoonPath.curve(to: NSPoint(x: 20, y: 15), controlPoint1: NSPoint(x: 17.31, y: 9), controlPoint2: NSPoint(x: 20, y: 11.69))
halfmoonPath.curve(to: NSPoint(x: 14, y: 21), controlPoint1: NSPoint(x: 20, y: 18.31), controlPoint2: NSPoint(x: 17.31, y: 21))
halfmoonPath.curve(to: NSPoint(x: 8, y: 15), controlPoint1: NSPoint(x: 10.69, y: 21), controlPoint2: NSPoint(x: 8, y: 18.31))
halfmoonPath.curve(to: NSPoint(x: 14, y: 9), controlPoint1: NSPoint(x: 8, y: 11.69), controlPoint2: NSPoint(x: 10.69, y: 9))
halfmoonPath.line(to: NSPoint(x: 14, y: 9))
halfmoonPath.close()
halfmoonPath.move(to: NSPoint(x: 14, y: 10))
halfmoonPath.line(to: NSPoint(x: 14, y: 15))
halfmoonPath.line(to: NSPoint(x: 14, y: 20))
halfmoonPath.curve(to: NSPoint(x: 9, y: 15), controlPoint1: NSPoint(x: 11.24, y: 20), controlPoint2: NSPoint(x: 9, y: 17.76))
halfmoonPath.curve(to: NSPoint(x: 14, y: 10), controlPoint1: NSPoint(x: 9, y: 12.24), controlPoint2: NSPoint(x: 11.24, y: 10))
halfmoonPath.line(to: NSPoint(x: 14, y: 10))
halfmoonPath.close()
halfmoonPath.windingRule = .evenOddWindingRule
fillColor.setFill()
halfmoonPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoonGibbous(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15, y: 20))
mainPath.curve(to: NSPoint(x: 10, y: 15), controlPoint1: NSPoint(x: 12.24, y: 20), controlPoint2: NSPoint(x: 10, y: 17.76))
mainPath.curve(to: NSPoint(x: 15, y: 10), controlPoint1: NSPoint(x: 10, y: 12.24), controlPoint2: NSPoint(x: 12.24, y: 10))
mainPath.curve(to: NSPoint(x: 18, y: 15), controlPoint1: NSPoint(x: 16.66, y: 10), controlPoint2: NSPoint(x: 18, y: 12.24))
mainPath.curve(to: NSPoint(x: 15, y: 20), controlPoint1: NSPoint(x: 18, y: 17.76), controlPoint2: NSPoint(x: 16.66, y: 20))
mainPath.line(to: NSPoint(x: 15, y: 20))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 9))
mainPath.curve(to: NSPoint(x: 21, y: 15), controlPoint1: NSPoint(x: 18.31, y: 9), controlPoint2: NSPoint(x: 21, y: 11.69))
mainPath.curve(to: NSPoint(x: 15, y: 21), controlPoint1: NSPoint(x: 21, y: 18.31), controlPoint2: NSPoint(x: 18.31, y: 21))
mainPath.curve(to: NSPoint(x: 9, y: 15), controlPoint1: NSPoint(x: 11.69, y: 21), controlPoint2: NSPoint(x: 9, y: 18.31))
mainPath.curve(to: NSPoint(x: 15, y: 9), controlPoint1: NSPoint(x: 9, y: 11.69), controlPoint2: NSPoint(x: 11.69, y: 9))
mainPath.line(to: NSPoint(x: 15, y: 9))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoon2(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15, y: 9))
mainPath.curve(to: NSPoint(x: 21, y: 15), controlPoint1: NSPoint(x: 18.31, y: 9), controlPoint2: NSPoint(x: 21, y: 11.69))
mainPath.curve(to: NSPoint(x: 15, y: 21), controlPoint1: NSPoint(x: 21, y: 18.31), controlPoint2: NSPoint(x: 18.31, y: 21))
mainPath.curve(to: NSPoint(x: 9, y: 15), controlPoint1: NSPoint(x: 11.69, y: 21), controlPoint2: NSPoint(x: 9, y: 18.31))
mainPath.curve(to: NSPoint(x: 15, y: 9), controlPoint1: NSPoint(x: 9, y: 11.69), controlPoint2: NSPoint(x: 11.69, y: 9))
mainPath.line(to: NSPoint(x: 15, y: 9))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 10))
mainPath.curve(to: NSPoint(x: 20, y: 15), controlPoint1: NSPoint(x: 17.76, y: 10), controlPoint2: NSPoint(x: 20, y: 12.24))
mainPath.curve(to: NSPoint(x: 15, y: 20), controlPoint1: NSPoint(x: 20, y: 17.76), controlPoint2: NSPoint(x: 17.76, y: 20))
mainPath.curve(to: NSPoint(x: 10, y: 15), controlPoint1: NSPoint(x: 12.24, y: 20), controlPoint2: NSPoint(x: 10, y: 17.76))
mainPath.curve(to: NSPoint(x: 15, y: 10), controlPoint1: NSPoint(x: 10, y: 12.24), controlPoint2: NSPoint(x: 12.24, y: 10))
mainPath.line(to: NSPoint(x: 15, y: 10))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoonGibbous2(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15, y: 20))
mainPath.curve(to: NSPoint(x: 20, y: 15), controlPoint1: NSPoint(x: 17.76, y: 20), controlPoint2: NSPoint(x: 20, y: 17.76))
mainPath.curve(to: NSPoint(x: 15, y: 10), controlPoint1: NSPoint(x: 20, y: 12.24), controlPoint2: NSPoint(x: 17.76, y: 10))
mainPath.curve(to: NSPoint(x: 12, y: 15), controlPoint1: NSPoint(x: 13.34, y: 10), controlPoint2: NSPoint(x: 12, y: 12.24))
mainPath.curve(to: NSPoint(x: 15, y: 20), controlPoint1: NSPoint(x: 12, y: 17.76), controlPoint2: NSPoint(x: 13.34, y: 20))
mainPath.line(to: NSPoint(x: 15, y: 20))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 9))
mainPath.curve(to: NSPoint(x: 9, y: 15), controlPoint1: NSPoint(x: 11.69, y: 9), controlPoint2: NSPoint(x: 9, y: 11.69))
mainPath.curve(to: NSPoint(x: 15, y: 21), controlPoint1: NSPoint(x: 9, y: 18.31), controlPoint2: NSPoint(x: 11.69, y: 21))
mainPath.curve(to: NSPoint(x: 21, y: 15), controlPoint1: NSPoint(x: 18.31, y: 21), controlPoint2: NSPoint(x: 21, y: 18.31))
mainPath.curve(to: NSPoint(x: 15, y: 9), controlPoint1: NSPoint(x: 21, y: 11.69), controlPoint2: NSPoint(x: 18.31, y: 9))
mainPath.line(to: NSPoint(x: 15, y: 9))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoonHalf2(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// half-moon Drawing
let halfmoonPath = NSBezierPath()
halfmoonPath.move(to: NSPoint(x: 18, y: 9))
halfmoonPath.curve(to: NSPoint(x: 12, y: 15), controlPoint1: NSPoint(x: 14.69, y: 9), controlPoint2: NSPoint(x: 12, y: 11.69))
halfmoonPath.curve(to: NSPoint(x: 18, y: 21), controlPoint1: NSPoint(x: 12, y: 18.31), controlPoint2: NSPoint(x: 14.69, y: 21))
halfmoonPath.curve(to: NSPoint(x: 24, y: 15), controlPoint1: NSPoint(x: 21.31, y: 21), controlPoint2: NSPoint(x: 24, y: 18.31))
halfmoonPath.curve(to: NSPoint(x: 18, y: 9), controlPoint1: NSPoint(x: 24, y: 11.69), controlPoint2: NSPoint(x: 21.31, y: 9))
halfmoonPath.line(to: NSPoint(x: 18, y: 9))
halfmoonPath.close()
halfmoonPath.move(to: NSPoint(x: 18, y: 10))
halfmoonPath.line(to: NSPoint(x: 18, y: 15))
halfmoonPath.line(to: NSPoint(x: 18, y: 20))
halfmoonPath.curve(to: NSPoint(x: 23, y: 15), controlPoint1: NSPoint(x: 20.76, y: 20), controlPoint2: NSPoint(x: 23, y: 17.76))
halfmoonPath.curve(to: NSPoint(x: 18, y: 10), controlPoint1: NSPoint(x: 23, y: 12.24), controlPoint2: NSPoint(x: 20.76, y: 10))
halfmoonPath.line(to: NSPoint(x: 18, y: 10))
halfmoonPath.close()
halfmoonPath.windingRule = .evenOddWindingRule
fillColor.setFill()
halfmoonPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawMoonCrescent2(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-51-crescent
//// crescent Drawing
let crescentPath = NSBezierPath()
crescentPath.move(to: NSPoint(x: 14, y: 20))
crescentPath.curve(to: NSPoint(x: 19, y: 15), controlPoint1: NSPoint(x: 16.76, y: 20), controlPoint2: NSPoint(x: 19, y: 17.76))
crescentPath.curve(to: NSPoint(x: 14, y: 10), controlPoint1: NSPoint(x: 19, y: 12.24), controlPoint2: NSPoint(x: 16.76, y: 10))
crescentPath.curve(to: NSPoint(x: 17, y: 15), controlPoint1: NSPoint(x: 15.66, y: 10), controlPoint2: NSPoint(x: 17, y: 12.24))
crescentPath.curve(to: NSPoint(x: 14, y: 20), controlPoint1: NSPoint(x: 17, y: 17.76), controlPoint2: NSPoint(x: 15.66, y: 20))
crescentPath.line(to: NSPoint(x: 14, y: 20))
crescentPath.line(to: NSPoint(x: 14, y: 20))
crescentPath.close()
crescentPath.move(to: NSPoint(x: 14, y: 9))
crescentPath.curve(to: NSPoint(x: 8, y: 15), controlPoint1: NSPoint(x: 10.69, y: 9), controlPoint2: NSPoint(x: 8, y: 11.69))
crescentPath.curve(to: NSPoint(x: 14, y: 21), controlPoint1: NSPoint(x: 8, y: 18.31), controlPoint2: NSPoint(x: 10.69, y: 21))
crescentPath.curve(to: NSPoint(x: 20, y: 15), controlPoint1: NSPoint(x: 17.31, y: 21), controlPoint2: NSPoint(x: 20, y: 18.31))
crescentPath.curve(to: NSPoint(x: 14, y: 9), controlPoint1: NSPoint(x: 20, y: 11.69), controlPoint2: NSPoint(x: 17.31, y: 9))
crescentPath.line(to: NSPoint(x: 14, y: 9))
crescentPath.close()
crescentPath.windingRule = .evenOddWindingRule
fillColor.setFill()
crescentPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawBarometer(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 16.39, y: 9.58))
mainPath.curve(to: NSPoint(x: 17.5, y: 7.5), controlPoint1: NSPoint(x: 17.06, y: 9.13), controlPoint2: NSPoint(x: 17.5, y: 8.37))
mainPath.curve(to: NSPoint(x: 15, y: 5), controlPoint1: NSPoint(x: 17.5, y: 6.12), controlPoint2: NSPoint(x: 16.38, y: 5))
mainPath.curve(to: NSPoint(x: 12.5, y: 7.5), controlPoint1: NSPoint(x: 13.62, y: 5), controlPoint2: NSPoint(x: 12.5, y: 6.12))
mainPath.curve(to: NSPoint(x: 13.61, y: 9.58), controlPoint1: NSPoint(x: 12.5, y: 8.37), controlPoint2: NSPoint(x: 12.94, y: 9.13))
mainPath.line(to: NSPoint(x: 15, y: 17))
mainPath.line(to: NSPoint(x: 16.39, y: 9.58))
mainPath.line(to: NSPoint(x: 16.39, y: 9.58))
mainPath.line(to: NSPoint(x: 16.39, y: 9.58))
mainPath.close()
mainPath.move(to: NSPoint(x: 27.78, y: 7.13))
mainPath.curve(to: NSPoint(x: 28.5, y: 11.5), controlPoint1: NSPoint(x: 28.25, y: 8.5), controlPoint2: NSPoint(x: 28.5, y: 9.97))
mainPath.curve(to: NSPoint(x: 15, y: 25), controlPoint1: NSPoint(x: 28.5, y: 18.96), controlPoint2: NSPoint(x: 22.46, y: 25))
mainPath.curve(to: NSPoint(x: 1.5, y: 11.5), controlPoint1: NSPoint(x: 7.54, y: 25), controlPoint2: NSPoint(x: 1.5, y: 18.96))
mainPath.curve(to: NSPoint(x: 2.22, y: 7.13), controlPoint1: NSPoint(x: 1.5, y: 9.97), controlPoint2: NSPoint(x: 1.75, y: 8.5))
mainPath.line(to: NSPoint(x: 3.18, y: 7.42))
mainPath.curve(to: NSPoint(x: 2.5, y: 11.5), controlPoint1: NSPoint(x: 2.74, y: 8.7), controlPoint2: NSPoint(x: 2.5, y: 10.07))
mainPath.curve(to: NSPoint(x: 15, y: 24), controlPoint1: NSPoint(x: 2.5, y: 18.4), controlPoint2: NSPoint(x: 8.1, y: 24))
mainPath.curve(to: NSPoint(x: 27.5, y: 11.5), controlPoint1: NSPoint(x: 21.9, y: 24), controlPoint2: NSPoint(x: 27.5, y: 18.4))
mainPath.curve(to: NSPoint(x: 26.82, y: 7.42), controlPoint1: NSPoint(x: 27.5, y: 10.07), controlPoint2: NSPoint(x: 27.26, y: 8.7))
mainPath.line(to: NSPoint(x: 27.78, y: 7.13))
mainPath.line(to: NSPoint(x: 27.78, y: 7.13))
mainPath.line(to: NSPoint(x: 27.78, y: 7.13))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 6))
mainPath.curve(to: NSPoint(x: 16.5, y: 7.5), controlPoint1: NSPoint(x: 15.83, y: 6), controlPoint2: NSPoint(x: 16.5, y: 6.67))
mainPath.curve(to: NSPoint(x: 15, y: 9), controlPoint1: NSPoint(x: 16.5, y: 8.33), controlPoint2: NSPoint(x: 15.83, y: 9))
mainPath.curve(to: NSPoint(x: 13.5, y: 7.5), controlPoint1: NSPoint(x: 14.17, y: 9), controlPoint2: NSPoint(x: 13.5, y: 8.33))
mainPath.curve(to: NSPoint(x: 15, y: 6), controlPoint1: NSPoint(x: 13.5, y: 6.67), controlPoint2: NSPoint(x: 14.17, y: 6))
mainPath.line(to: NSPoint(x: 15, y: 6))
mainPath.line(to: NSPoint(x: 15, y: 6))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 23))
mainPath.curve(to: NSPoint(x: 14.5, y: 22.51), controlPoint1: NSPoint(x: 14.72, y: 23), controlPoint2: NSPoint(x: 14.5, y: 22.78))
mainPath.line(to: NSPoint(x: 14.5, y: 19.49))
mainPath.curve(to: NSPoint(x: 15, y: 19), controlPoint1: NSPoint(x: 14.5, y: 19.22), controlPoint2: NSPoint(x: 14.73, y: 19))
mainPath.curve(to: NSPoint(x: 15.5, y: 19.49), controlPoint1: NSPoint(x: 15.28, y: 19), controlPoint2: NSPoint(x: 15.5, y: 19.22))
mainPath.line(to: NSPoint(x: 15.5, y: 22.51))
mainPath.curve(to: NSPoint(x: 15, y: 23), controlPoint1: NSPoint(x: 15.5, y: 22.78), controlPoint2: NSPoint(x: 15.27, y: 23))
mainPath.line(to: NSPoint(x: 15, y: 23))
mainPath.line(to: NSPoint(x: 15, y: 23))
mainPath.close()
mainPath.move(to: NSPoint(x: 21.76, y: 20.8))
mainPath.curve(to: NSPoint(x: 21.07, y: 20.7), controlPoint1: NSPoint(x: 21.54, y: 20.97), controlPoint2: NSPoint(x: 21.23, y: 20.92))
mainPath.line(to: NSPoint(x: 19.29, y: 18.26))
mainPath.curve(to: NSPoint(x: 19.41, y: 17.57), controlPoint1: NSPoint(x: 19.13, y: 18.04), controlPoint2: NSPoint(x: 19.19, y: 17.72))
mainPath.curve(to: NSPoint(x: 20.1, y: 17.67), controlPoint1: NSPoint(x: 19.63, y: 17.4), controlPoint2: NSPoint(x: 19.94, y: 17.45))
mainPath.line(to: NSPoint(x: 21.88, y: 20.11))
mainPath.curve(to: NSPoint(x: 21.76, y: 20.8), controlPoint1: NSPoint(x: 22.04, y: 20.33), controlPoint2: NSPoint(x: 21.98, y: 20.65))
mainPath.line(to: NSPoint(x: 21.76, y: 20.8))
mainPath.line(to: NSPoint(x: 21.76, y: 20.8))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.94, y: 15.05))
mainPath.curve(to: NSPoint(x: 25.32, y: 15.38), controlPoint1: NSPoint(x: 25.85, y: 15.31), controlPoint2: NSPoint(x: 25.58, y: 15.46))
mainPath.line(to: NSPoint(x: 22.45, y: 14.44))
mainPath.curve(to: NSPoint(x: 22.14, y: 13.82), controlPoint1: NSPoint(x: 22.19, y: 14.36), controlPoint2: NSPoint(x: 22.05, y: 14.07))
mainPath.curve(to: NSPoint(x: 22.76, y: 13.49), controlPoint1: NSPoint(x: 22.22, y: 13.55), controlPoint2: NSPoint(x: 22.49, y: 13.41))
mainPath.line(to: NSPoint(x: 25.63, y: 14.42))
mainPath.curve(to: NSPoint(x: 25.94, y: 15.05), controlPoint1: NSPoint(x: 25.89, y: 14.51), controlPoint2: NSPoint(x: 26.02, y: 14.8))
mainPath.line(to: NSPoint(x: 25.94, y: 15.05))
mainPath.line(to: NSPoint(x: 25.94, y: 15.05))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.94, y: 7.94))
mainPath.curve(to: NSPoint(x: 25.63, y: 8.57), controlPoint1: NSPoint(x: 26.03, y: 8.2), controlPoint2: NSPoint(x: 25.89, y: 8.48))
mainPath.line(to: NSPoint(x: 22.76, y: 9.5))
mainPath.curve(to: NSPoint(x: 22.14, y: 9.18), controlPoint1: NSPoint(x: 22.5, y: 9.59), controlPoint2: NSPoint(x: 22.22, y: 9.43))
mainPath.curve(to: NSPoint(x: 22.45, y: 8.55), controlPoint1: NSPoint(x: 22.05, y: 8.92), controlPoint2: NSPoint(x: 22.19, y: 8.64))
mainPath.line(to: NSPoint(x: 25.32, y: 7.62))
mainPath.curve(to: NSPoint(x: 25.94, y: 7.94), controlPoint1: NSPoint(x: 25.58, y: 7.53), controlPoint2: NSPoint(x: 25.86, y: 7.69))
mainPath.line(to: NSPoint(x: 25.94, y: 7.94))
mainPath.line(to: NSPoint(x: 25.94, y: 7.94))
mainPath.close()
mainPath.move(to: NSPoint(x: 4.06, y: 7.94))
mainPath.curve(to: NSPoint(x: 4.68, y: 7.62), controlPoint1: NSPoint(x: 4.15, y: 7.68), controlPoint2: NSPoint(x: 4.42, y: 7.53))
mainPath.line(to: NSPoint(x: 7.55, y: 8.55))
mainPath.curve(to: NSPoint(x: 7.86, y: 9.18), controlPoint1: NSPoint(x: 7.81, y: 8.63), controlPoint2: NSPoint(x: 7.95, y: 8.92))
mainPath.curve(to: NSPoint(x: 7.24, y: 9.5), controlPoint1: NSPoint(x: 7.78, y: 9.44), controlPoint2: NSPoint(x: 7.51, y: 9.59))
mainPath.line(to: NSPoint(x: 4.37, y: 8.57))
mainPath.curve(to: NSPoint(x: 4.06, y: 7.94), controlPoint1: NSPoint(x: 4.11, y: 8.49), controlPoint2: NSPoint(x: 3.98, y: 8.2))
mainPath.line(to: NSPoint(x: 4.06, y: 7.94))
mainPath.line(to: NSPoint(x: 4.06, y: 7.94))
mainPath.close()
mainPath.move(to: NSPoint(x: 4.06, y: 15.05))
mainPath.curve(to: NSPoint(x: 4.37, y: 14.42), controlPoint1: NSPoint(x: 3.97, y: 14.79), controlPoint2: NSPoint(x: 4.11, y: 14.51))
mainPath.line(to: NSPoint(x: 7.24, y: 13.49))
mainPath.curve(to: NSPoint(x: 7.86, y: 13.82), controlPoint1: NSPoint(x: 7.5, y: 13.41), controlPoint2: NSPoint(x: 7.78, y: 13.56))
mainPath.curve(to: NSPoint(x: 7.55, y: 14.44), controlPoint1: NSPoint(x: 7.95, y: 14.08), controlPoint2: NSPoint(x: 7.81, y: 14.36))
mainPath.line(to: NSPoint(x: 4.68, y: 15.38))
mainPath.curve(to: NSPoint(x: 4.06, y: 15.05), controlPoint1: NSPoint(x: 4.42, y: 15.46), controlPoint2: NSPoint(x: 4.14, y: 15.31))
mainPath.line(to: NSPoint(x: 4.06, y: 15.05))
mainPath.line(to: NSPoint(x: 4.06, y: 15.05))
mainPath.close()
mainPath.move(to: NSPoint(x: 8.24, y: 20.8))
mainPath.curve(to: NSPoint(x: 8.12, y: 20.11), controlPoint1: NSPoint(x: 8.02, y: 20.64), controlPoint2: NSPoint(x: 7.96, y: 20.34))
mainPath.line(to: NSPoint(x: 9.9, y: 17.67))
mainPath.curve(to: NSPoint(x: 10.59, y: 17.57), controlPoint1: NSPoint(x: 10.06, y: 17.45), controlPoint2: NSPoint(x: 10.37, y: 17.41))
mainPath.curve(to: NSPoint(x: 10.71, y: 18.26), controlPoint1: NSPoint(x: 10.81, y: 17.73), controlPoint2: NSPoint(x: 10.87, y: 18.03))
mainPath.line(to: NSPoint(x: 8.93, y: 20.7))
mainPath.curve(to: NSPoint(x: 8.24, y: 20.8), controlPoint1: NSPoint(x: 8.77, y: 20.92), controlPoint2: NSPoint(x: 8.46, y: 20.96))
mainPath.line(to: NSPoint(x: 8.24, y: 20.8))
mainPath.line(to: NSPoint(x: 8.24, y: 20.8))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCompassNorth(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15, y: 2))
mainPath.curve(to: NSPoint(x: 28, y: 15), controlPoint1: NSPoint(x: 22.18, y: 2), controlPoint2: NSPoint(x: 28, y: 7.82))
mainPath.curve(to: NSPoint(x: 15, y: 28), controlPoint1: NSPoint(x: 28, y: 22.18), controlPoint2: NSPoint(x: 22.18, y: 28))
mainPath.curve(to: NSPoint(x: 2, y: 15), controlPoint1: NSPoint(x: 7.82, y: 28), controlPoint2: NSPoint(x: 2, y: 22.18))
mainPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 2, y: 7.82), controlPoint2: NSPoint(x: 7.82, y: 2))
mainPath.line(to: NSPoint(x: 15, y: 2))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 3))
mainPath.curve(to: NSPoint(x: 27, y: 15), controlPoint1: NSPoint(x: 21.63, y: 3), controlPoint2: NSPoint(x: 27, y: 8.37))
mainPath.curve(to: NSPoint(x: 15, y: 27), controlPoint1: NSPoint(x: 27, y: 21.63), controlPoint2: NSPoint(x: 21.63, y: 27))
mainPath.curve(to: NSPoint(x: 3, y: 15), controlPoint1: NSPoint(x: 8.37, y: 27), controlPoint2: NSPoint(x: 3, y: 21.63))
mainPath.curve(to: NSPoint(x: 15, y: 3), controlPoint1: NSPoint(x: 3, y: 8.37), controlPoint2: NSPoint(x: 8.37, y: 3))
mainPath.line(to: NSPoint(x: 15, y: 3))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 24))
mainPath.curve(to: NSPoint(x: 18, y: 15), controlPoint1: NSPoint(x: 15, y: 24), controlPoint2: NSPoint(x: 18, y: 17))
mainPath.curve(to: NSPoint(x: 18, y: 15), controlPoint1: NSPoint(x: 18, y: 14.33), controlPoint2: NSPoint(x: 18, y: 15))
mainPath.curve(to: NSPoint(x: 15, y: 12), controlPoint1: NSPoint(x: 18, y: 13.34), controlPoint2: NSPoint(x: 16.65, y: 12))
mainPath.curve(to: NSPoint(x: 12, y: 15), controlPoint1: NSPoint(x: 13.34, y: 12), controlPoint2: NSPoint(x: 12, y: 13.34))
mainPath.curve(to: NSPoint(x: 12, y: 15), controlPoint1: NSPoint(x: 12, y: 15), controlPoint2: NSPoint(x: 12, y: 13.79))
mainPath.curve(to: NSPoint(x: 15, y: 24), controlPoint1: NSPoint(x: 12, y: 17), controlPoint2: NSPoint(x: 15, y: 24))
mainPath.line(to: NSPoint(x: 15, y: 24))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 13))
mainPath.curve(to: NSPoint(x: 17, y: 15), controlPoint1: NSPoint(x: 16.1, y: 13), controlPoint2: NSPoint(x: 17, y: 13.9))
mainPath.curve(to: NSPoint(x: 15, y: 17), controlPoint1: NSPoint(x: 17, y: 16.1), controlPoint2: NSPoint(x: 16.1, y: 17))
mainPath.curve(to: NSPoint(x: 13, y: 15), controlPoint1: NSPoint(x: 13.9, y: 17), controlPoint2: NSPoint(x: 13, y: 16.1))
mainPath.curve(to: NSPoint(x: 15, y: 13), controlPoint1: NSPoint(x: 13, y: 13.9), controlPoint2: NSPoint(x: 13.9, y: 13))
mainPath.line(to: NSPoint(x: 15, y: 13))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCompassWest(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 2, y: 16))
mainPath.curve(to: NSPoint(x: 15, y: 29), controlPoint1: NSPoint(x: 2, y: 23.18), controlPoint2: NSPoint(x: 7.82, y: 29))
mainPath.curve(to: NSPoint(x: 28, y: 16), controlPoint1: NSPoint(x: 22.18, y: 29), controlPoint2: NSPoint(x: 28, y: 23.18))
mainPath.curve(to: NSPoint(x: 15, y: 3), controlPoint1: NSPoint(x: 28, y: 8.82), controlPoint2: NSPoint(x: 22.18, y: 3))
mainPath.curve(to: NSPoint(x: 2, y: 16), controlPoint1: NSPoint(x: 7.82, y: 3), controlPoint2: NSPoint(x: 2, y: 8.82))
mainPath.line(to: NSPoint(x: 2, y: 16))
mainPath.close()
mainPath.move(to: NSPoint(x: 3, y: 16))
mainPath.curve(to: NSPoint(x: 15, y: 28), controlPoint1: NSPoint(x: 3, y: 22.63), controlPoint2: NSPoint(x: 8.37, y: 28))
mainPath.curve(to: NSPoint(x: 27, y: 16), controlPoint1: NSPoint(x: 21.63, y: 28), controlPoint2: NSPoint(x: 27, y: 22.63))
mainPath.curve(to: NSPoint(x: 15, y: 4), controlPoint1: NSPoint(x: 27, y: 9.37), controlPoint2: NSPoint(x: 21.63, y: 4))
mainPath.curve(to: NSPoint(x: 3, y: 16), controlPoint1: NSPoint(x: 8.37, y: 4), controlPoint2: NSPoint(x: 3, y: 9.37))
mainPath.line(to: NSPoint(x: 3, y: 16))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 16))
mainPath.curve(to: NSPoint(x: 15, y: 19), controlPoint1: NSPoint(x: 18, y: 17.66), controlPoint2: NSPoint(x: 16.66, y: 19))
mainPath.curve(to: NSPoint(x: 6, y: 16), controlPoint1: NSPoint(x: 13, y: 19), controlPoint2: NSPoint(x: 6, y: 16))
mainPath.curve(to: NSPoint(x: 15, y: 13), controlPoint1: NSPoint(x: 6, y: 16), controlPoint2: NSPoint(x: 13, y: 13))
mainPath.curve(to: NSPoint(x: 18, y: 16), controlPoint1: NSPoint(x: 16.66, y: 13), controlPoint2: NSPoint(x: 18, y: 14.35))
mainPath.line(to: NSPoint(x: 18, y: 16))
mainPath.close()
mainPath.move(to: NSPoint(x: 13, y: 16))
mainPath.curve(to: NSPoint(x: 15, y: 18), controlPoint1: NSPoint(x: 13, y: 17.1), controlPoint2: NSPoint(x: 13.9, y: 18))
mainPath.curve(to: NSPoint(x: 17, y: 16), controlPoint1: NSPoint(x: 16.1, y: 18), controlPoint2: NSPoint(x: 17, y: 17.1))
mainPath.curve(to: NSPoint(x: 15, y: 14), controlPoint1: NSPoint(x: 17, y: 14.9), controlPoint2: NSPoint(x: 16.1, y: 14))
mainPath.curve(to: NSPoint(x: 13, y: 16), controlPoint1: NSPoint(x: 13.9, y: 14), controlPoint2: NSPoint(x: 13, y: 14.9))
mainPath.line(to: NSPoint(x: 13, y: 16))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCompassEast(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-55-compass-east
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 28, y: 15))
mainPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 28, y: 7.82), controlPoint2: NSPoint(x: 22.18, y: 2))
mainPath.curve(to: NSPoint(x: 2, y: 15), controlPoint1: NSPoint(x: 7.82, y: 2), controlPoint2: NSPoint(x: 2, y: 7.82))
mainPath.curve(to: NSPoint(x: 15, y: 28), controlPoint1: NSPoint(x: 2, y: 22.18), controlPoint2: NSPoint(x: 7.82, y: 28))
mainPath.curve(to: NSPoint(x: 28, y: 15), controlPoint1: NSPoint(x: 22.18, y: 28), controlPoint2: NSPoint(x: 28, y: 22.18))
mainPath.line(to: NSPoint(x: 28, y: 15))
mainPath.close()
mainPath.move(to: NSPoint(x: 27, y: 15))
mainPath.curve(to: NSPoint(x: 15, y: 3), controlPoint1: NSPoint(x: 27, y: 8.37), controlPoint2: NSPoint(x: 21.63, y: 3))
mainPath.curve(to: NSPoint(x: 3, y: 15), controlPoint1: NSPoint(x: 8.37, y: 3), controlPoint2: NSPoint(x: 3, y: 8.37))
mainPath.curve(to: NSPoint(x: 15, y: 27), controlPoint1: NSPoint(x: 3, y: 21.63), controlPoint2: NSPoint(x: 8.37, y: 27))
mainPath.curve(to: NSPoint(x: 27, y: 15), controlPoint1: NSPoint(x: 21.63, y: 27), controlPoint2: NSPoint(x: 27, y: 21.63))
mainPath.line(to: NSPoint(x: 27, y: 15))
mainPath.close()
mainPath.move(to: NSPoint(x: 12, y: 15))
mainPath.curve(to: NSPoint(x: 15, y: 12), controlPoint1: NSPoint(x: 12, y: 13.34), controlPoint2: NSPoint(x: 13.34, y: 12))
mainPath.curve(to: NSPoint(x: 24, y: 15), controlPoint1: NSPoint(x: 17, y: 12), controlPoint2: NSPoint(x: 24, y: 15))
mainPath.curve(to: NSPoint(x: 15, y: 18), controlPoint1: NSPoint(x: 24, y: 15), controlPoint2: NSPoint(x: 17, y: 18))
mainPath.curve(to: NSPoint(x: 12, y: 15), controlPoint1: NSPoint(x: 13.34, y: 18), controlPoint2: NSPoint(x: 12, y: 16.65))
mainPath.line(to: NSPoint(x: 12, y: 15))
mainPath.close()
mainPath.move(to: NSPoint(x: 17, y: 15))
mainPath.curve(to: NSPoint(x: 15, y: 13), controlPoint1: NSPoint(x: 17, y: 13.9), controlPoint2: NSPoint(x: 16.1, y: 13))
mainPath.curve(to: NSPoint(x: 13, y: 15), controlPoint1: NSPoint(x: 13.9, y: 13), controlPoint2: NSPoint(x: 13, y: 13.9))
mainPath.curve(to: NSPoint(x: 15, y: 17), controlPoint1: NSPoint(x: 13, y: 16.1), controlPoint2: NSPoint(x: 13.9, y: 17))
mainPath.curve(to: NSPoint(x: 17, y: 15), controlPoint1: NSPoint(x: 16.1, y: 17), controlPoint2: NSPoint(x: 17, y: 16.1))
mainPath.line(to: NSPoint(x: 17, y: 15))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCompassSouth(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-56-compass-south
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 28, y: 15))
mainPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 28, y: 7.82), controlPoint2: NSPoint(x: 22.18, y: 2))
mainPath.curve(to: NSPoint(x: 2, y: 15), controlPoint1: NSPoint(x: 7.82, y: 2), controlPoint2: NSPoint(x: 2, y: 7.82))
mainPath.curve(to: NSPoint(x: 15, y: 28), controlPoint1: NSPoint(x: 2, y: 22.18), controlPoint2: NSPoint(x: 7.82, y: 28))
mainPath.curve(to: NSPoint(x: 28, y: 15), controlPoint1: NSPoint(x: 22.18, y: 28), controlPoint2: NSPoint(x: 28, y: 22.18))
mainPath.line(to: NSPoint(x: 28, y: 15))
mainPath.close()
mainPath.move(to: NSPoint(x: 27, y: 15))
mainPath.curve(to: NSPoint(x: 15, y: 3), controlPoint1: NSPoint(x: 27, y: 8.37), controlPoint2: NSPoint(x: 21.63, y: 3))
mainPath.curve(to: NSPoint(x: 3, y: 15), controlPoint1: NSPoint(x: 8.37, y: 3), controlPoint2: NSPoint(x: 3, y: 8.37))
mainPath.curve(to: NSPoint(x: 15, y: 27), controlPoint1: NSPoint(x: 3, y: 21.63), controlPoint2: NSPoint(x: 8.37, y: 27))
mainPath.curve(to: NSPoint(x: 27, y: 15), controlPoint1: NSPoint(x: 21.63, y: 27), controlPoint2: NSPoint(x: 27, y: 21.63))
mainPath.line(to: NSPoint(x: 27, y: 15))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 15))
mainPath.curve(to: NSPoint(x: 15, y: 18), controlPoint1: NSPoint(x: 18, y: 16.66), controlPoint2: NSPoint(x: 16.65, y: 18))
mainPath.curve(to: NSPoint(x: 12, y: 15), controlPoint1: NSPoint(x: 13.34, y: 18), controlPoint2: NSPoint(x: 12, y: 16.66))
mainPath.curve(to: NSPoint(x: 15, y: 6), controlPoint1: NSPoint(x: 12, y: 13), controlPoint2: NSPoint(x: 15, y: 6))
mainPath.curve(to: NSPoint(x: 18, y: 15), controlPoint1: NSPoint(x: 15, y: 6), controlPoint2: NSPoint(x: 18, y: 13))
mainPath.line(to: NSPoint(x: 18, y: 15))
mainPath.close()
mainPath.move(to: NSPoint(x: 17, y: 15))
mainPath.curve(to: NSPoint(x: 15, y: 13), controlPoint1: NSPoint(x: 17, y: 13.9), controlPoint2: NSPoint(x: 16.1, y: 13))
mainPath.curve(to: NSPoint(x: 13, y: 15), controlPoint1: NSPoint(x: 13.9, y: 13), controlPoint2: NSPoint(x: 13, y: 13.9))
mainPath.curve(to: NSPoint(x: 15, y: 17), controlPoint1: NSPoint(x: 13, y: 16.1), controlPoint2: NSPoint(x: 13.9, y: 17))
mainPath.curve(to: NSPoint(x: 17, y: 15), controlPoint1: NSPoint(x: 16.1, y: 17), controlPoint2: NSPoint(x: 17, y: 16.1))
mainPath.line(to: NSPoint(x: 17, y: 15))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawAirSock(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-57-air-sock
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 21.5, y: 20.1))
mainPath.line(to: NSPoint(x: 19.5, y: 19.89))
mainPath.line(to: NSPoint(x: 19.5, y: 19.89))
mainPath.line(to: NSPoint(x: 19.5, y: 25.12))
mainPath.line(to: NSPoint(x: 21.5, y: 24.91))
mainPath.line(to: NSPoint(x: 21.5, y: 20.1))
mainPath.line(to: NSPoint(x: 21.5, y: 20.1))
mainPath.close()
mainPath.move(to: NSPoint(x: 22.5, y: 20.21))
mainPath.line(to: NSPoint(x: 24.5, y: 20.42))
mainPath.line(to: NSPoint(x: 24.5, y: 24.59))
mainPath.line(to: NSPoint(x: 22.5, y: 24.8))
mainPath.line(to: NSPoint(x: 22.5, y: 20.21))
mainPath.line(to: NSPoint(x: 22.5, y: 20.21))
mainPath.close()
mainPath.move(to: NSPoint(x: 18.5, y: 19.78))
mainPath.line(to: NSPoint(x: 15.5, y: 19.46))
mainPath.line(to: NSPoint(x: 15.5, y: 19.46))
mainPath.line(to: NSPoint(x: 15.5, y: 25.55))
mainPath.line(to: NSPoint(x: 18.5, y: 25.23))
mainPath.line(to: NSPoint(x: 18.5, y: 19.78))
mainPath.line(to: NSPoint(x: 18.5, y: 19.78))
mainPath.line(to: NSPoint(x: 18.5, y: 19.78))
mainPath.close()
mainPath.move(to: NSPoint(x: 14.5, y: 19.35))
mainPath.line(to: NSPoint(x: 11.5, y: 19.03))
mainPath.line(to: NSPoint(x: 11.5, y: 25.98))
mainPath.line(to: NSPoint(x: 14.5, y: 25.66))
mainPath.line(to: NSPoint(x: 14.5, y: 19.35))
mainPath.line(to: NSPoint(x: 14.5, y: 19.35))
mainPath.line(to: NSPoint(x: 14.5, y: 19.35))
mainPath.close()
mainPath.move(to: NSPoint(x: 10.5, y: 18.92))
mainPath.line(to: NSPoint(x: 7.5, y: 18.6))
mainPath.line(to: NSPoint(x: 7.5, y: 26.4))
mainPath.line(to: NSPoint(x: 10.5, y: 26.08))
mainPath.line(to: NSPoint(x: 10.5, y: 18.92))
mainPath.line(to: NSPoint(x: 10.5, y: 18.92))
mainPath.close()
mainPath.move(to: NSPoint(x: 5, y: 27.5))
mainPath.curve(to: NSPoint(x: 4.5, y: 27), controlPoint1: NSPoint(x: 4.72, y: 27.5), controlPoint2: NSPoint(x: 4.5, y: 27.28))
mainPath.line(to: NSPoint(x: 4.5, y: 3))
mainPath.curve(to: NSPoint(x: 5, y: 2.5), controlPoint1: NSPoint(x: 4.5, y: 2.72), controlPoint2: NSPoint(x: 4.73, y: 2.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 3), controlPoint1: NSPoint(x: 5.28, y: 2.5), controlPoint2: NSPoint(x: 5.5, y: 2.72))
mainPath.line(to: NSPoint(x: 5.5, y: 27))
mainPath.curve(to: NSPoint(x: 5, y: 27.5), controlPoint1: NSPoint(x: 5.5, y: 27.28), controlPoint2: NSPoint(x: 5.27, y: 27.5))
mainPath.line(to: NSPoint(x: 5, y: 27.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 6.5, y: 27.5))
mainPath.line(to: NSPoint(x: 6.5, y: 17.5))
mainPath.line(to: NSPoint(x: 25.5, y: 19.5))
mainPath.line(to: NSPoint(x: 25.5, y: 25.5))
mainPath.line(to: NSPoint(x: 6.5, y: 27.5))
mainPath.line(to: NSPoint(x: 6.5, y: 27.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawTornado(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-58-tornado
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 26.5, y: 25.92))
mainPath.curve(to: NSPoint(x: 17.74, y: 16.78), controlPoint1: NSPoint(x: 26.83, y: 23.96), controlPoint2: NSPoint(x: 23.53, y: 20.19))
mainPath.curve(to: NSPoint(x: 11.73, y: 6.85), controlPoint1: NSPoint(x: 10.9, y: 12.75), controlPoint2: NSPoint(x: 7.26, y: 8.77))
mainPath.curve(to: NSPoint(x: 16.23, y: 2.48), controlPoint1: NSPoint(x: 17.28, y: 4.48), controlPoint2: NSPoint(x: 16.23, y: 2.48))
mainPath.curve(to: NSPoint(x: 13.44, y: 4.71), controlPoint1: NSPoint(x: 16.23, y: 2.48), controlPoint2: NSPoint(x: 15.74, y: 3.81))
mainPath.curve(to: NSPoint(x: 5.2, y: 8.9), controlPoint1: NSPoint(x: 11.16, y: 5.61), controlPoint2: NSPoint(x: 8.71, y: 5.89))
mainPath.curve(to: NSPoint(x: 6.98, y: 19), controlPoint1: NSPoint(x: 3.56, y: 10.31), controlPoint2: NSPoint(x: 1.55, y: 14.26))
mainPath.curve(to: NSPoint(x: 4.26, y: 24.86), controlPoint1: NSPoint(x: 8.65, y: 21.25), controlPoint2: NSPoint(x: 5.62, y: 23.23))
mainPath.curve(to: NSPoint(x: 15, y: 22.47), controlPoint1: NSPoint(x: 5.95, y: 23.46), controlPoint2: NSPoint(x: 10.12, y: 22.47))
mainPath.curve(to: NSPoint(x: 26.5, y: 25.92), controlPoint1: NSPoint(x: 21.05, y: 22.47), controlPoint2: NSPoint(x: 26.01, y: 23.99))
mainPath.line(to: NSPoint(x: 26.5, y: 25.92))
mainPath.line(to: NSPoint(x: 26.5, y: 25.92))
mainPath.close()
mainPath.move(to: NSPoint(x: 3, y: 27.1))
mainPath.curve(to: NSPoint(x: 15.02, y: 30), controlPoint1: NSPoint(x: 4, y: 28.7), controlPoint2: NSPoint(x: 8.38, y: 30))
mainPath.curve(to: NSPoint(x: 27.03, y: 27.1), controlPoint1: NSPoint(x: 21.65, y: 30), controlPoint2: NSPoint(x: 25.95, y: 28.46))
mainPath.curve(to: NSPoint(x: 19.02, y: 16.45), controlPoint1: NSPoint(x: 28.54, y: 25.22), controlPoint2: NSPoint(x: 26.19, y: 20.78))
mainPath.curve(to: NSPoint(x: 12.01, y: 7.74), controlPoint1: NSPoint(x: 12.91, y: 12.76), controlPoint2: NSPoint(x: 8.41, y: 9.17))
mainPath.curve(to: NSPoint(x: 16.02, y: 0), controlPoint1: NSPoint(x: 20.59, y: 4.35), controlPoint2: NSPoint(x: 16.02, y: 0))
mainPath.curve(to: NSPoint(x: 13.01, y: 3.87), controlPoint1: NSPoint(x: 16.02, y: 0), controlPoint2: NSPoint(x: 16.02, y: 2.9))
mainPath.curve(to: NSPoint(x: 4, y: 8.71), controlPoint1: NSPoint(x: 7.93, y: 5.51), controlPoint2: NSPoint(x: 6, y: 6.77))
mainPath.curve(to: NSPoint(x: 6, y: 19.35), controlPoint1: NSPoint(x: 2.48, y: 10.17), controlPoint2: NSPoint(x: 0.85, y: 14.8))
mainPath.curve(to: NSPoint(x: 3, y: 27.1), controlPoint1: NSPoint(x: 8.56, y: 21.62), controlPoint2: NSPoint(x: 1.08, y: 24.02))
mainPath.line(to: NSPoint(x: 3, y: 27.1))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.58, y: 26.22))
mainPath.curve(to: NSPoint(x: 15, y: 29.03), controlPoint1: NSPoint(x: 25.58, y: 27.77), controlPoint2: NSPoint(x: 20.84, y: 29.03))
mainPath.curve(to: NSPoint(x: 4.42, y: 26.22), controlPoint1: NSPoint(x: 9.16, y: 29.03), controlPoint2: NSPoint(x: 4.42, y: 27.77))
mainPath.curve(to: NSPoint(x: 15, y: 23.41), controlPoint1: NSPoint(x: 4.42, y: 24.67), controlPoint2: NSPoint(x: 9.16, y: 23.41))
mainPath.curve(to: NSPoint(x: 25.58, y: 26.22), controlPoint1: NSPoint(x: 20.84, y: 23.41), controlPoint2: NSPoint(x: 25.58, y: 24.67))
mainPath.line(to: NSPoint(x: 25.58, y: 26.22))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawDegreeFahrenheit(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-59-degree-fahrenheit
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 8, y: 17))
mainPath.curve(to: NSPoint(x: 12, y: 21), controlPoint1: NSPoint(x: 10.21, y: 17), controlPoint2: NSPoint(x: 12, y: 18.79))
mainPath.curve(to: NSPoint(x: 8, y: 25), controlPoint1: NSPoint(x: 12, y: 23.21), controlPoint2: NSPoint(x: 10.21, y: 25))
mainPath.curve(to: NSPoint(x: 4, y: 21), controlPoint1: NSPoint(x: 5.79, y: 25), controlPoint2: NSPoint(x: 4, y: 23.21))
mainPath.curve(to: NSPoint(x: 8, y: 17), controlPoint1: NSPoint(x: 4, y: 18.79), controlPoint2: NSPoint(x: 5.79, y: 17))
mainPath.line(to: NSPoint(x: 8, y: 17))
mainPath.close()
mainPath.move(to: NSPoint(x: 8, y: 18))
mainPath.curve(to: NSPoint(x: 11, y: 21), controlPoint1: NSPoint(x: 9.66, y: 18), controlPoint2: NSPoint(x: 11, y: 19.34))
mainPath.curve(to: NSPoint(x: 8, y: 24), controlPoint1: NSPoint(x: 11, y: 22.66), controlPoint2: NSPoint(x: 9.66, y: 24))
mainPath.curve(to: NSPoint(x: 5, y: 21), controlPoint1: NSPoint(x: 6.34, y: 24), controlPoint2: NSPoint(x: 5, y: 22.66))
mainPath.curve(to: NSPoint(x: 8, y: 18), controlPoint1: NSPoint(x: 5, y: 19.34), controlPoint2: NSPoint(x: 6.34, y: 18))
mainPath.line(to: NSPoint(x: 8, y: 18))
mainPath.close()
mainPath.move(to: NSPoint(x: 19, y: 25))
mainPath.curve(to: NSPoint(x: 14, y: 20), controlPoint1: NSPoint(x: 16.24, y: 25), controlPoint2: NSPoint(x: 14, y: 22.76))
mainPath.line(to: NSPoint(x: 14, y: 5.49))
mainPath.curve(to: NSPoint(x: 14.5, y: 5), controlPoint1: NSPoint(x: 14, y: 5.22), controlPoint2: NSPoint(x: 14.23, y: 5))
mainPath.line(to: NSPoint(x: 14.5, y: 5))
mainPath.curve(to: NSPoint(x: 15, y: 5.51), controlPoint1: NSPoint(x: 14.78, y: 5), controlPoint2: NSPoint(x: 15, y: 5.23))
mainPath.line(to: NSPoint(x: 15, y: 15))
mainPath.line(to: NSPoint(x: 21.5, y: 15))
mainPath.curve(to: NSPoint(x: 22, y: 15.5), controlPoint1: NSPoint(x: 21.77, y: 15), controlPoint2: NSPoint(x: 22, y: 15.23))
mainPath.line(to: NSPoint(x: 22, y: 15.5))
mainPath.curve(to: NSPoint(x: 21.5, y: 16), controlPoint1: NSPoint(x: 22, y: 15.78), controlPoint2: NSPoint(x: 21.77, y: 16))
mainPath.line(to: NSPoint(x: 15, y: 16))
mainPath.line(to: NSPoint(x: 15, y: 20))
mainPath.curve(to: NSPoint(x: 19, y: 24), controlPoint1: NSPoint(x: 15, y: 22.21), controlPoint2: NSPoint(x: 16.79, y: 24))
mainPath.line(to: NSPoint(x: 25.5, y: 24))
mainPath.curve(to: NSPoint(x: 26, y: 24.5), controlPoint1: NSPoint(x: 25.78, y: 24), controlPoint2: NSPoint(x: 26, y: 24.23))
mainPath.line(to: NSPoint(x: 26, y: 24.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 25), controlPoint1: NSPoint(x: 26, y: 24.78), controlPoint2: NSPoint(x: 25.77, y: 25))
mainPath.line(to: NSPoint(x: 19, y: 25))
mainPath.line(to: NSPoint(x: 19, y: 25))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawDegreeCelsius(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-60-degree-celsius
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 25, y: 19.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 19), controlPoint1: NSPoint(x: 25, y: 19.22), controlPoint2: NSPoint(x: 25.23, y: 19))
mainPath.curve(to: NSPoint(x: 26, y: 19.5), controlPoint1: NSPoint(x: 25.78, y: 19), controlPoint2: NSPoint(x: 26, y: 19.23))
mainPath.line(to: NSPoint(x: 26, y: 20))
mainPath.curve(to: NSPoint(x: 21, y: 25), controlPoint1: NSPoint(x: 26, y: 22.76), controlPoint2: NSPoint(x: 23.77, y: 25))
mainPath.line(to: NSPoint(x: 19, y: 25))
mainPath.curve(to: NSPoint(x: 14, y: 20), controlPoint1: NSPoint(x: 16.24, y: 25), controlPoint2: NSPoint(x: 14, y: 22.76))
mainPath.line(to: NSPoint(x: 14, y: 10))
mainPath.curve(to: NSPoint(x: 19, y: 5), controlPoint1: NSPoint(x: 14, y: 7.24), controlPoint2: NSPoint(x: 16.23, y: 5))
mainPath.line(to: NSPoint(x: 21, y: 5))
mainPath.curve(to: NSPoint(x: 26, y: 10), controlPoint1: NSPoint(x: 23.76, y: 5), controlPoint2: NSPoint(x: 26, y: 7.24))
mainPath.line(to: NSPoint(x: 26, y: 10.5))
mainPath.line(to: NSPoint(x: 26, y: 10.5))
mainPath.curve(to: NSPoint(x: 25.5, y: 11), controlPoint1: NSPoint(x: 26, y: 10.78), controlPoint2: NSPoint(x: 25.77, y: 11))
mainPath.curve(to: NSPoint(x: 25, y: 10.5), controlPoint1: NSPoint(x: 25.22, y: 11), controlPoint2: NSPoint(x: 25, y: 10.77))
mainPath.line(to: NSPoint(x: 25, y: 9.99))
mainPath.curve(to: NSPoint(x: 20.99, y: 6), controlPoint1: NSPoint(x: 25, y: 7.79), controlPoint2: NSPoint(x: 23.2, y: 6))
mainPath.line(to: NSPoint(x: 19.01, y: 6))
mainPath.curve(to: NSPoint(x: 15, y: 9.99), controlPoint1: NSPoint(x: 16.79, y: 6), controlPoint2: NSPoint(x: 15, y: 7.79))
mainPath.line(to: NSPoint(x: 15, y: 20.01))
mainPath.curve(to: NSPoint(x: 19.01, y: 24), controlPoint1: NSPoint(x: 15, y: 22.21), controlPoint2: NSPoint(x: 16.8, y: 24))
mainPath.line(to: NSPoint(x: 20.99, y: 24))
mainPath.curve(to: NSPoint(x: 25, y: 20.01), controlPoint1: NSPoint(x: 23.21, y: 24), controlPoint2: NSPoint(x: 25, y: 22.21))
mainPath.line(to: NSPoint(x: 25, y: 19.5))
mainPath.line(to: NSPoint(x: 25, y: 19.5))
mainPath.line(to: NSPoint(x: 25, y: 19.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 8, y: 17))
mainPath.curve(to: NSPoint(x: 12, y: 21), controlPoint1: NSPoint(x: 10.21, y: 17), controlPoint2: NSPoint(x: 12, y: 18.79))
mainPath.curve(to: NSPoint(x: 8, y: 25), controlPoint1: NSPoint(x: 12, y: 23.21), controlPoint2: NSPoint(x: 10.21, y: 25))
mainPath.curve(to: NSPoint(x: 4, y: 21), controlPoint1: NSPoint(x: 5.79, y: 25), controlPoint2: NSPoint(x: 4, y: 23.21))
mainPath.curve(to: NSPoint(x: 8, y: 17), controlPoint1: NSPoint(x: 4, y: 18.79), controlPoint2: NSPoint(x: 5.79, y: 17))
mainPath.line(to: NSPoint(x: 8, y: 17))
mainPath.close()
mainPath.move(to: NSPoint(x: 8, y: 18))
mainPath.curve(to: NSPoint(x: 11, y: 21), controlPoint1: NSPoint(x: 9.66, y: 18), controlPoint2: NSPoint(x: 11, y: 19.34))
mainPath.curve(to: NSPoint(x: 8, y: 24), controlPoint1: NSPoint(x: 11, y: 22.66), controlPoint2: NSPoint(x: 9.66, y: 24))
mainPath.curve(to: NSPoint(x: 5, y: 21), controlPoint1: NSPoint(x: 6.34, y: 24), controlPoint2: NSPoint(x: 5, y: 22.66))
mainPath.curve(to: NSPoint(x: 8, y: 18), controlPoint1: NSPoint(x: 5, y: 19.34), controlPoint2: NSPoint(x: 6.34, y: 18))
mainPath.line(to: NSPoint(x: 8, y: 18))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawWarning(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-61-warning
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 14.42, y: 23.85))
mainPath.curve(to: NSPoint(x: 17.58, y: 23.85), controlPoint1: NSPoint(x: 15.29, y: 25.26), controlPoint2: NSPoint(x: 16.71, y: 25.26))
mainPath.line(to: NSPoint(x: 28.36, y: 6.4))
mainPath.curve(to: NSPoint(x: 26.47, y: 3), controlPoint1: NSPoint(x: 29.52, y: 4.52), controlPoint2: NSPoint(x: 28.68, y: 3))
mainPath.line(to: NSPoint(x: 5.53, y: 3))
mainPath.curve(to: NSPoint(x: 3.64, y: 6.4), controlPoint1: NSPoint(x: 3.32, y: 3), controlPoint2: NSPoint(x: 2.47, y: 4.52))
mainPath.line(to: NSPoint(x: 14.42, y: 23.85))
mainPath.line(to: NSPoint(x: 14.42, y: 23.85))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.35, y: 23.48))
mainPath.curve(to: NSPoint(x: 16.61, y: 23.48), controlPoint1: NSPoint(x: 15.7, y: 24.04), controlPoint2: NSPoint(x: 16.26, y: 24.04))
mainPath.line(to: NSPoint(x: 27.62, y: 5.69))
mainPath.curve(to: NSPoint(x: 26.67, y: 4), controlPoint1: NSPoint(x: 28.2, y: 4.76), controlPoint2: NSPoint(x: 27.76, y: 4))
mainPath.line(to: NSPoint(x: 5.29, y: 4))
mainPath.curve(to: NSPoint(x: 4.35, y: 5.69), controlPoint1: NSPoint(x: 4.19, y: 4), controlPoint2: NSPoint(x: 3.77, y: 4.75))
mainPath.line(to: NSPoint(x: 15.35, y: 23.48))
mainPath.line(to: NSPoint(x: 15.35, y: 23.48))
mainPath.close()
mainPath.move(to: NSPoint(x: 16, y: 18))
mainPath.curve(to: NSPoint(x: 15, y: 17), controlPoint1: NSPoint(x: 15.45, y: 18), controlPoint2: NSPoint(x: 15, y: 17.55))
mainPath.line(to: NSPoint(x: 15, y: 11))
mainPath.curve(to: NSPoint(x: 16, y: 10), controlPoint1: NSPoint(x: 15, y: 10.45), controlPoint2: NSPoint(x: 15.44, y: 10))
mainPath.curve(to: NSPoint(x: 17, y: 11), controlPoint1: NSPoint(x: 16.55, y: 10), controlPoint2: NSPoint(x: 17, y: 10.45))
mainPath.line(to: NSPoint(x: 17, y: 17))
mainPath.curve(to: NSPoint(x: 16, y: 18), controlPoint1: NSPoint(x: 17, y: 17.55), controlPoint2: NSPoint(x: 16.56, y: 18))
mainPath.line(to: NSPoint(x: 16, y: 18))
mainPath.close()
mainPath.move(to: NSPoint(x: 16, y: 6))
mainPath.curve(to: NSPoint(x: 17, y: 7), controlPoint1: NSPoint(x: 16.55, y: 6), controlPoint2: NSPoint(x: 17, y: 6.45))
mainPath.curve(to: NSPoint(x: 16, y: 8), controlPoint1: NSPoint(x: 17, y: 7.55), controlPoint2: NSPoint(x: 16.55, y: 8))
mainPath.curve(to: NSPoint(x: 15, y: 7), controlPoint1: NSPoint(x: 15.45, y: 8), controlPoint2: NSPoint(x: 15, y: 7.55))
mainPath.curve(to: NSPoint(x: 16, y: 6), controlPoint1: NSPoint(x: 15, y: 6.45), controlPoint2: NSPoint(x: 15.45, y: 6))
mainPath.line(to: NSPoint(x: 16, y: 6))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCompass(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-62-compass
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15, y: 2))
mainPath.curve(to: NSPoint(x: 28, y: 15), controlPoint1: NSPoint(x: 22.18, y: 2), controlPoint2: NSPoint(x: 28, y: 7.82))
mainPath.curve(to: NSPoint(x: 15, y: 28), controlPoint1: NSPoint(x: 28, y: 22.18), controlPoint2: NSPoint(x: 22.18, y: 28))
mainPath.curve(to: NSPoint(x: 2, y: 15), controlPoint1: NSPoint(x: 7.82, y: 28), controlPoint2: NSPoint(x: 2, y: 22.18))
mainPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 2, y: 7.82), controlPoint2: NSPoint(x: 7.82, y: 2))
mainPath.line(to: NSPoint(x: 15, y: 2))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 3))
mainPath.curve(to: NSPoint(x: 27, y: 15), controlPoint1: NSPoint(x: 21.63, y: 3), controlPoint2: NSPoint(x: 27, y: 8.37))
mainPath.curve(to: NSPoint(x: 15, y: 27), controlPoint1: NSPoint(x: 27, y: 21.63), controlPoint2: NSPoint(x: 21.63, y: 27))
mainPath.curve(to: NSPoint(x: 3, y: 15), controlPoint1: NSPoint(x: 8.37, y: 27), controlPoint2: NSPoint(x: 3, y: 21.63))
mainPath.curve(to: NSPoint(x: 15, y: 3), controlPoint1: NSPoint(x: 3, y: 8.37), controlPoint2: NSPoint(x: 8.37, y: 3))
mainPath.line(to: NSPoint(x: 15, y: 3))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.12, y: 12.88))
mainPath.curve(to: NSPoint(x: 7.93, y: 7.93), controlPoint1: NSPoint(x: 15.35, y: 11.11), controlPoint2: NSPoint(x: 7.93, y: 7.93))
mainPath.curve(to: NSPoint(x: 12.88, y: 17.12), controlPoint1: NSPoint(x: 7.93, y: 7.93), controlPoint2: NSPoint(x: 11.11, y: 15.35))
mainPath.curve(to: NSPoint(x: 22.07, y: 22.07), controlPoint1: NSPoint(x: 14.65, y: 18.89), controlPoint2: NSPoint(x: 22.07, y: 22.07))
mainPath.curve(to: NSPoint(x: 17.12, y: 12.88), controlPoint1: NSPoint(x: 22.07, y: 22.07), controlPoint2: NSPoint(x: 18.89, y: 14.65))
mainPath.line(to: NSPoint(x: 17.12, y: 12.88))
mainPath.close()
mainPath.move(to: NSPoint(x: 13.59, y: 13.59))
mainPath.curve(to: NSPoint(x: 16.41, y: 13.59), controlPoint1: NSPoint(x: 14.37, y: 12.8), controlPoint2: NSPoint(x: 15.63, y: 12.8))
mainPath.curve(to: NSPoint(x: 16.41, y: 16.41), controlPoint1: NSPoint(x: 17.2, y: 14.37), controlPoint2: NSPoint(x: 17.2, y: 15.63))
mainPath.curve(to: NSPoint(x: 13.59, y: 16.41), controlPoint1: NSPoint(x: 15.63, y: 17.2), controlPoint2: NSPoint(x: 14.37, y: 17.2))
mainPath.curve(to: NSPoint(x: 13.59, y: 13.59), controlPoint1: NSPoint(x: 12.8, y: 15.63), controlPoint2: NSPoint(x: 12.8, y: 14.37))
mainPath.line(to: NSPoint(x: 13.59, y: 13.59))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCompass2(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-63-compass
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15.5, y: 3))
mainPath.curve(to: NSPoint(x: 28, y: 15.5), controlPoint1: NSPoint(x: 22.4, y: 3), controlPoint2: NSPoint(x: 28, y: 8.6))
mainPath.curve(to: NSPoint(x: 15.5, y: 28), controlPoint1: NSPoint(x: 28, y: 22.4), controlPoint2: NSPoint(x: 22.4, y: 28))
mainPath.curve(to: NSPoint(x: 3, y: 15.5), controlPoint1: NSPoint(x: 8.6, y: 28), controlPoint2: NSPoint(x: 3, y: 22.4))
mainPath.curve(to: NSPoint(x: 15.5, y: 3), controlPoint1: NSPoint(x: 3, y: 8.6), controlPoint2: NSPoint(x: 8.6, y: 3))
mainPath.line(to: NSPoint(x: 15.5, y: 3))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.5, y: 4))
mainPath.curve(to: NSPoint(x: 27, y: 15.5), controlPoint1: NSPoint(x: 21.85, y: 4), controlPoint2: NSPoint(x: 27, y: 9.15))
mainPath.curve(to: NSPoint(x: 15.5, y: 27), controlPoint1: NSPoint(x: 27, y: 21.85), controlPoint2: NSPoint(x: 21.85, y: 27))
mainPath.curve(to: NSPoint(x: 4, y: 15.5), controlPoint1: NSPoint(x: 9.15, y: 27), controlPoint2: NSPoint(x: 4, y: 21.85))
mainPath.curve(to: NSPoint(x: 15.5, y: 4), controlPoint1: NSPoint(x: 4, y: 9.15), controlPoint2: NSPoint(x: 9.15, y: 4))
mainPath.line(to: NSPoint(x: 15.5, y: 4))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.27, y: 13.73))
mainPath.curve(to: NSPoint(x: 8.78, y: 8.78), controlPoint1: NSPoint(x: 15.5, y: 11.96), controlPoint2: NSPoint(x: 8.78, y: 8.78))
mainPath.curve(to: NSPoint(x: 13.73, y: 17.27), controlPoint1: NSPoint(x: 8.78, y: 8.78), controlPoint2: NSPoint(x: 11.96, y: 15.5))
mainPath.curve(to: NSPoint(x: 22.22, y: 22.22), controlPoint1: NSPoint(x: 15.5, y: 19.04), controlPoint2: NSPoint(x: 22.22, y: 22.22))
mainPath.curve(to: NSPoint(x: 17.27, y: 13.73), controlPoint1: NSPoint(x: 22.22, y: 22.22), controlPoint2: NSPoint(x: 19.04, y: 15.5))
mainPath.line(to: NSPoint(x: 17.27, y: 13.73))
mainPath.close()
mainPath.move(to: NSPoint(x: 14.44, y: 14.44))
mainPath.curve(to: NSPoint(x: 16.56, y: 14.44), controlPoint1: NSPoint(x: 15.03, y: 13.85), controlPoint2: NSPoint(x: 15.97, y: 13.85))
mainPath.curve(to: NSPoint(x: 16.56, y: 16.56), controlPoint1: NSPoint(x: 17.15, y: 15.03), controlPoint2: NSPoint(x: 17.15, y: 15.97))
mainPath.curve(to: NSPoint(x: 14.44, y: 16.56), controlPoint1: NSPoint(x: 15.97, y: 17.15), controlPoint2: NSPoint(x: 15.03, y: 17.15))
mainPath.curve(to: NSPoint(x: 14.44, y: 14.44), controlPoint1: NSPoint(x: 13.85, y: 15.97), controlPoint2: NSPoint(x: 13.85, y: 15.03))
mainPath.line(to: NSPoint(x: 14.44, y: 14.44))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.5, y: 26))
mainPath.curve(to: NSPoint(x: 15, y: 25.51), controlPoint1: NSPoint(x: 15.22, y: 26), controlPoint2: NSPoint(x: 15, y: 25.78))
mainPath.line(to: NSPoint(x: 15, y: 22.49))
mainPath.curve(to: NSPoint(x: 15.5, y: 22), controlPoint1: NSPoint(x: 15, y: 22.22), controlPoint2: NSPoint(x: 15.23, y: 22))
mainPath.curve(to: NSPoint(x: 16, y: 22.49), controlPoint1: NSPoint(x: 15.78, y: 22), controlPoint2: NSPoint(x: 16, y: 22.22))
mainPath.line(to: NSPoint(x: 16, y: 25.51))
mainPath.curve(to: NSPoint(x: 15.5, y: 26), controlPoint1: NSPoint(x: 16, y: 25.78), controlPoint2: NSPoint(x: 15.77, y: 26))
mainPath.line(to: NSPoint(x: 15.5, y: 26))
mainPath.close()
mainPath.move(to: NSPoint(x: 26.04, y: 15.46))
mainPath.curve(to: NSPoint(x: 25.55, y: 15.96), controlPoint1: NSPoint(x: 26.04, y: 15.73), controlPoint2: NSPoint(x: 25.83, y: 15.96))
mainPath.line(to: NSPoint(x: 22.53, y: 15.96))
mainPath.curve(to: NSPoint(x: 22.04, y: 15.46), controlPoint1: NSPoint(x: 22.26, y: 15.96), controlPoint2: NSPoint(x: 22.04, y: 15.72))
mainPath.curve(to: NSPoint(x: 22.53, y: 14.96), controlPoint1: NSPoint(x: 22.04, y: 15.18), controlPoint2: NSPoint(x: 22.26, y: 14.96))
mainPath.line(to: NSPoint(x: 25.55, y: 14.96))
mainPath.curve(to: NSPoint(x: 26.04, y: 15.46), controlPoint1: NSPoint(x: 25.82, y: 14.96), controlPoint2: NSPoint(x: 26.04, y: 15.19))
mainPath.line(to: NSPoint(x: 26.04, y: 15.46))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.5, y: 4.91))
mainPath.curve(to: NSPoint(x: 16, y: 5.4), controlPoint1: NSPoint(x: 15.78, y: 4.91), controlPoint2: NSPoint(x: 16, y: 5.13))
mainPath.line(to: NSPoint(x: 16, y: 8.42))
mainPath.curve(to: NSPoint(x: 15.5, y: 8.91), controlPoint1: NSPoint(x: 16, y: 8.69), controlPoint2: NSPoint(x: 15.77, y: 8.91))
mainPath.curve(to: NSPoint(x: 15, y: 8.42), controlPoint1: NSPoint(x: 15.22, y: 8.91), controlPoint2: NSPoint(x: 15, y: 8.7))
mainPath.line(to: NSPoint(x: 15, y: 5.4))
mainPath.curve(to: NSPoint(x: 15.5, y: 4.91), controlPoint1: NSPoint(x: 15, y: 5.13), controlPoint2: NSPoint(x: 15.23, y: 4.91))
mainPath.line(to: NSPoint(x: 15.5, y: 4.91))
mainPath.close()
mainPath.move(to: NSPoint(x: 4.96, y: 15.46))
mainPath.curve(to: NSPoint(x: 5.45, y: 14.96), controlPoint1: NSPoint(x: 4.96, y: 15.18), controlPoint2: NSPoint(x: 5.17, y: 14.96))
mainPath.line(to: NSPoint(x: 8.47, y: 14.96))
mainPath.curve(to: NSPoint(x: 8.96, y: 15.46), controlPoint1: NSPoint(x: 8.74, y: 14.96), controlPoint2: NSPoint(x: 8.96, y: 15.19))
mainPath.curve(to: NSPoint(x: 8.47, y: 15.96), controlPoint1: NSPoint(x: 8.96, y: 15.73), controlPoint2: NSPoint(x: 8.74, y: 15.96))
mainPath.line(to: NSPoint(x: 5.45, y: 15.96))
mainPath.curve(to: NSPoint(x: 4.96, y: 15.46), controlPoint1: NSPoint(x: 5.18, y: 15.96), controlPoint2: NSPoint(x: 4.96, y: 15.72))
mainPath.line(to: NSPoint(x: 4.96, y: 15.46))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCompass3(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15, y: 2.5))
mainPath.curve(to: NSPoint(x: 27.5, y: 15), controlPoint1: NSPoint(x: 21.9, y: 2.5), controlPoint2: NSPoint(x: 27.5, y: 8.1))
mainPath.curve(to: NSPoint(x: 15, y: 27.5), controlPoint1: NSPoint(x: 27.5, y: 21.9), controlPoint2: NSPoint(x: 21.9, y: 27.5))
mainPath.curve(to: NSPoint(x: 2.5, y: 15), controlPoint1: NSPoint(x: 8.1, y: 27.5), controlPoint2: NSPoint(x: 2.5, y: 21.9))
mainPath.curve(to: NSPoint(x: 15, y: 2.5), controlPoint1: NSPoint(x: 2.5, y: 8.1), controlPoint2: NSPoint(x: 8.1, y: 2.5))
mainPath.line(to: NSPoint(x: 15, y: 2.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 3.5))
mainPath.curve(to: NSPoint(x: 26.5, y: 15), controlPoint1: NSPoint(x: 21.35, y: 3.5), controlPoint2: NSPoint(x: 26.5, y: 8.65))
mainPath.curve(to: NSPoint(x: 15, y: 26.5), controlPoint1: NSPoint(x: 26.5, y: 21.35), controlPoint2: NSPoint(x: 21.35, y: 26.5))
mainPath.curve(to: NSPoint(x: 3.5, y: 15), controlPoint1: NSPoint(x: 8.65, y: 26.5), controlPoint2: NSPoint(x: 3.5, y: 21.35))
mainPath.curve(to: NSPoint(x: 15, y: 3.5), controlPoint1: NSPoint(x: 3.5, y: 8.65), controlPoint2: NSPoint(x: 8.65, y: 3.5))
mainPath.line(to: NSPoint(x: 15, y: 3.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 16.77, y: 13.23))
mainPath.curve(to: NSPoint(x: 8.28, y: 8.28), controlPoint1: NSPoint(x: 15, y: 11.46), controlPoint2: NSPoint(x: 8.28, y: 8.28))
mainPath.curve(to: NSPoint(x: 13.23, y: 16.77), controlPoint1: NSPoint(x: 8.28, y: 8.28), controlPoint2: NSPoint(x: 11.46, y: 15))
mainPath.curve(to: NSPoint(x: 21.72, y: 21.72), controlPoint1: NSPoint(x: 15, y: 18.54), controlPoint2: NSPoint(x: 21.72, y: 21.72))
mainPath.curve(to: NSPoint(x: 16.77, y: 13.23), controlPoint1: NSPoint(x: 21.72, y: 21.72), controlPoint2: NSPoint(x: 18.54, y: 15))
mainPath.line(to: NSPoint(x: 16.77, y: 13.23))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 25.5))
mainPath.curve(to: NSPoint(x: 14.5, y: 25.01), controlPoint1: NSPoint(x: 14.72, y: 25.5), controlPoint2: NSPoint(x: 14.5, y: 25.28))
mainPath.line(to: NSPoint(x: 14.5, y: 21.99))
mainPath.curve(to: NSPoint(x: 15, y: 21.5), controlPoint1: NSPoint(x: 14.5, y: 21.72), controlPoint2: NSPoint(x: 14.73, y: 21.5))
mainPath.curve(to: NSPoint(x: 15.5, y: 21.99), controlPoint1: NSPoint(x: 15.28, y: 21.5), controlPoint2: NSPoint(x: 15.5, y: 21.72))
mainPath.line(to: NSPoint(x: 15.5, y: 25.01))
mainPath.curve(to: NSPoint(x: 15, y: 25.5), controlPoint1: NSPoint(x: 15.5, y: 25.28), controlPoint2: NSPoint(x: 15.27, y: 25.5))
mainPath.line(to: NSPoint(x: 15, y: 25.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 25.54, y: 14.96))
mainPath.curve(to: NSPoint(x: 25.05, y: 15.46), controlPoint1: NSPoint(x: 25.54, y: 15.23), controlPoint2: NSPoint(x: 25.33, y: 15.46))
mainPath.line(to: NSPoint(x: 22.03, y: 15.46))
mainPath.curve(to: NSPoint(x: 21.54, y: 14.96), controlPoint1: NSPoint(x: 21.76, y: 15.46), controlPoint2: NSPoint(x: 21.54, y: 15.22))
mainPath.curve(to: NSPoint(x: 22.03, y: 14.46), controlPoint1: NSPoint(x: 21.54, y: 14.68), controlPoint2: NSPoint(x: 21.76, y: 14.46))
mainPath.line(to: NSPoint(x: 25.05, y: 14.46))
mainPath.curve(to: NSPoint(x: 25.54, y: 14.96), controlPoint1: NSPoint(x: 25.32, y: 14.46), controlPoint2: NSPoint(x: 25.54, y: 14.69))
mainPath.line(to: NSPoint(x: 25.54, y: 14.96))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 4.41))
mainPath.curve(to: NSPoint(x: 15.5, y: 4.9), controlPoint1: NSPoint(x: 15.28, y: 4.41), controlPoint2: NSPoint(x: 15.5, y: 4.63))
mainPath.line(to: NSPoint(x: 15.5, y: 7.92))
mainPath.curve(to: NSPoint(x: 15, y: 8.41), controlPoint1: NSPoint(x: 15.5, y: 8.19), controlPoint2: NSPoint(x: 15.27, y: 8.41))
mainPath.curve(to: NSPoint(x: 14.5, y: 7.92), controlPoint1: NSPoint(x: 14.72, y: 8.41), controlPoint2: NSPoint(x: 14.5, y: 8.2))
mainPath.line(to: NSPoint(x: 14.5, y: 4.9))
mainPath.curve(to: NSPoint(x: 15, y: 4.41), controlPoint1: NSPoint(x: 14.5, y: 4.63), controlPoint2: NSPoint(x: 14.73, y: 4.41))
mainPath.line(to: NSPoint(x: 15, y: 4.41))
mainPath.close()
mainPath.move(to: NSPoint(x: 4.46, y: 14.96))
mainPath.curve(to: NSPoint(x: 4.95, y: 14.46), controlPoint1: NSPoint(x: 4.46, y: 14.68), controlPoint2: NSPoint(x: 4.67, y: 14.46))
mainPath.line(to: NSPoint(x: 7.97, y: 14.46))
mainPath.curve(to: NSPoint(x: 8.46, y: 14.96), controlPoint1: NSPoint(x: 8.24, y: 14.46), controlPoint2: NSPoint(x: 8.46, y: 14.69))
mainPath.curve(to: NSPoint(x: 7.97, y: 15.46), controlPoint1: NSPoint(x: 8.46, y: 15.23), controlPoint2: NSPoint(x: 8.24, y: 15.46))
mainPath.line(to: NSPoint(x: 4.95, y: 15.46))
mainPath.curve(to: NSPoint(x: 4.46, y: 14.96), controlPoint1: NSPoint(x: 4.68, y: 15.46), controlPoint2: NSPoint(x: 4.46, y: 15.22))
mainPath.line(to: NSPoint(x: 4.46, y: 14.96))
mainPath.close()
mainPath.move(to: NSPoint(x: 13.93, y: 16))
mainPath.curve(to: NSPoint(x: 10.46, y: 10.41), controlPoint1: NSPoint(x: 12.86, y: 14.94), controlPoint2: NSPoint(x: 10.46, y: 10.41))
mainPath.curve(to: NSPoint(x: 16.05, y: 13.88), controlPoint1: NSPoint(x: 10.46, y: 10.41), controlPoint2: NSPoint(x: 14.99, y: 12.82))
mainPath.line(to: NSPoint(x: 13.93, y: 16))
mainPath.line(to: NSPoint(x: 13.93, y: 16))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawCompass4(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-65-compass
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15, y: 2))
mainPath.curve(to: NSPoint(x: 28, y: 15), controlPoint1: NSPoint(x: 22.18, y: 2), controlPoint2: NSPoint(x: 28, y: 7.82))
mainPath.curve(to: NSPoint(x: 15, y: 28), controlPoint1: NSPoint(x: 28, y: 22.18), controlPoint2: NSPoint(x: 22.18, y: 28))
mainPath.curve(to: NSPoint(x: 2, y: 15), controlPoint1: NSPoint(x: 7.82, y: 28), controlPoint2: NSPoint(x: 2, y: 22.18))
mainPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 2, y: 7.82), controlPoint2: NSPoint(x: 7.82, y: 2))
mainPath.line(to: NSPoint(x: 15, y: 2))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 3))
mainPath.curve(to: NSPoint(x: 27, y: 15), controlPoint1: NSPoint(x: 21.63, y: 3), controlPoint2: NSPoint(x: 27, y: 8.37))
mainPath.curve(to: NSPoint(x: 15, y: 27), controlPoint1: NSPoint(x: 27, y: 21.63), controlPoint2: NSPoint(x: 21.63, y: 27))
mainPath.curve(to: NSPoint(x: 3, y: 15), controlPoint1: NSPoint(x: 8.37, y: 27), controlPoint2: NSPoint(x: 3, y: 21.63))
mainPath.curve(to: NSPoint(x: 15, y: 3), controlPoint1: NSPoint(x: 3, y: 8.37), controlPoint2: NSPoint(x: 8.37, y: 3))
mainPath.line(to: NSPoint(x: 15, y: 3))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.12, y: 12.88))
mainPath.curve(to: NSPoint(x: 7.93, y: 7.93), controlPoint1: NSPoint(x: 15.35, y: 11.11), controlPoint2: NSPoint(x: 7.93, y: 7.93))
mainPath.curve(to: NSPoint(x: 12.88, y: 17.12), controlPoint1: NSPoint(x: 7.93, y: 7.93), controlPoint2: NSPoint(x: 11.11, y: 15.35))
mainPath.curve(to: NSPoint(x: 22.07, y: 22.07), controlPoint1: NSPoint(x: 14.65, y: 18.89), controlPoint2: NSPoint(x: 22.07, y: 22.07))
mainPath.curve(to: NSPoint(x: 17.12, y: 12.88), controlPoint1: NSPoint(x: 22.07, y: 22.07), controlPoint2: NSPoint(x: 18.89, y: 14.65))
mainPath.line(to: NSPoint(x: 17.12, y: 12.88))
mainPath.close()
mainPath.move(to: NSPoint(x: 13.62, y: 16.4))
mainPath.curve(to: NSPoint(x: 10.01, y: 9.97), controlPoint1: NSPoint(x: 12.21, y: 14.99), controlPoint2: NSPoint(x: 10.01, y: 9.97))
mainPath.curve(to: NSPoint(x: 16.45, y: 13.57), controlPoint1: NSPoint(x: 10.01, y: 9.97), controlPoint2: NSPoint(x: 15.03, y: 12.16))
mainPath.line(to: NSPoint(x: 13.62, y: 16.4))
mainPath.line(to: NSPoint(x: 13.62, y: 16.4))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawThermometer(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-66-thermometer
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 17, y: 8.46))
mainPath.curve(to: NSPoint(x: 19, y: 5), controlPoint1: NSPoint(x: 18.2, y: 7.77), controlPoint2: NSPoint(x: 19, y: 6.48))
mainPath.curve(to: NSPoint(x: 15, y: 1), controlPoint1: NSPoint(x: 19, y: 2.79), controlPoint2: NSPoint(x: 17.21, y: 1))
mainPath.curve(to: NSPoint(x: 11, y: 5), controlPoint1: NSPoint(x: 12.79, y: 1), controlPoint2: NSPoint(x: 11, y: 2.79))
mainPath.curve(to: NSPoint(x: 13, y: 8.46), controlPoint1: NSPoint(x: 11, y: 6.48), controlPoint2: NSPoint(x: 11.8, y: 7.77))
mainPath.line(to: NSPoint(x: 13, y: 27))
mainPath.curve(to: NSPoint(x: 15, y: 29), controlPoint1: NSPoint(x: 13, y: 28.11), controlPoint2: NSPoint(x: 13.9, y: 29))
mainPath.curve(to: NSPoint(x: 17, y: 27), controlPoint1: NSPoint(x: 16.11, y: 29), controlPoint2: NSPoint(x: 17, y: 28.1))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 9))
mainPath.curve(to: NSPoint(x: 20, y: 5), controlPoint1: NSPoint(x: 19.21, y: 8.09), controlPoint2: NSPoint(x: 20, y: 6.64))
mainPath.curve(to: NSPoint(x: 15, y: 0), controlPoint1: NSPoint(x: 20, y: 2.24), controlPoint2: NSPoint(x: 17.76, y: 0))
mainPath.curve(to: NSPoint(x: 10, y: 5), controlPoint1: NSPoint(x: 12.24, y: 0), controlPoint2: NSPoint(x: 10, y: 2.24))
mainPath.curve(to: NSPoint(x: 12, y: 9), controlPoint1: NSPoint(x: 10, y: 6.64), controlPoint2: NSPoint(x: 10.79, y: 8.09))
mainPath.line(to: NSPoint(x: 12, y: 27.01))
mainPath.curve(to: NSPoint(x: 15, y: 30), controlPoint1: NSPoint(x: 12, y: 28.66), controlPoint2: NSPoint(x: 13.34, y: 30))
mainPath.curve(to: NSPoint(x: 18, y: 27.01), controlPoint1: NSPoint(x: 16.65, y: 30), controlPoint2: NSPoint(x: 18, y: 28.66))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawThermometerLow(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-67-thermometer-low
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 17, y: 8.46))
mainPath.curve(to: NSPoint(x: 19, y: 5), controlPoint1: NSPoint(x: 18.2, y: 7.77), controlPoint2: NSPoint(x: 19, y: 6.48))
mainPath.curve(to: NSPoint(x: 15, y: 1), controlPoint1: NSPoint(x: 19, y: 2.79), controlPoint2: NSPoint(x: 17.21, y: 1))
mainPath.curve(to: NSPoint(x: 11, y: 5), controlPoint1: NSPoint(x: 12.79, y: 1), controlPoint2: NSPoint(x: 11, y: 2.79))
mainPath.curve(to: NSPoint(x: 13, y: 8.46), controlPoint1: NSPoint(x: 11, y: 6.48), controlPoint2: NSPoint(x: 11.8, y: 7.77))
mainPath.line(to: NSPoint(x: 13, y: 27))
mainPath.curve(to: NSPoint(x: 15, y: 29), controlPoint1: NSPoint(x: 13, y: 28.11), controlPoint2: NSPoint(x: 13.9, y: 29))
mainPath.curve(to: NSPoint(x: 17, y: 27), controlPoint1: NSPoint(x: 16.11, y: 29), controlPoint2: NSPoint(x: 17, y: 28.1))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 9))
mainPath.curve(to: NSPoint(x: 20, y: 5), controlPoint1: NSPoint(x: 19.21, y: 8.09), controlPoint2: NSPoint(x: 20, y: 6.64))
mainPath.curve(to: NSPoint(x: 15, y: 0), controlPoint1: NSPoint(x: 20, y: 2.24), controlPoint2: NSPoint(x: 17.76, y: 0))
mainPath.curve(to: NSPoint(x: 10, y: 5), controlPoint1: NSPoint(x: 12.24, y: 0), controlPoint2: NSPoint(x: 10, y: 2.24))
mainPath.curve(to: NSPoint(x: 12, y: 9), controlPoint1: NSPoint(x: 10, y: 6.64), controlPoint2: NSPoint(x: 10.79, y: 8.09))
mainPath.line(to: NSPoint(x: 12, y: 27.01))
mainPath.curve(to: NSPoint(x: 15, y: 30), controlPoint1: NSPoint(x: 12, y: 28.66), controlPoint2: NSPoint(x: 13.34, y: 30))
mainPath.curve(to: NSPoint(x: 18, y: 27.01), controlPoint1: NSPoint(x: 16.65, y: 30), controlPoint2: NSPoint(x: 18, y: 28.66))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.close()
mainPath.move(to: NSPoint(x: 15, y: 2))
mainPath.curve(to: NSPoint(x: 18, y: 5), controlPoint1: NSPoint(x: 16.66, y: 2), controlPoint2: NSPoint(x: 18, y: 3.34))
mainPath.curve(to: NSPoint(x: 15, y: 8), controlPoint1: NSPoint(x: 18, y: 6.66), controlPoint2: NSPoint(x: 16.66, y: 8))
mainPath.curve(to: NSPoint(x: 12, y: 5), controlPoint1: NSPoint(x: 13.34, y: 8), controlPoint2: NSPoint(x: 12, y: 6.66))
mainPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 12, y: 3.34), controlPoint2: NSPoint(x: 13.34, y: 2))
mainPath.line(to: NSPoint(x: 15, y: 2))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawThermometerQuarter(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-68-thermometer-quarter
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15.99, y: 7.83))
mainPath.curve(to: NSPoint(x: 18, y: 5), controlPoint1: NSPoint(x: 17.16, y: 7.43), controlPoint2: NSPoint(x: 18, y: 6.31))
mainPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 18, y: 3.34), controlPoint2: NSPoint(x: 16.66, y: 2))
mainPath.curve(to: NSPoint(x: 12, y: 5), controlPoint1: NSPoint(x: 13.34, y: 2), controlPoint2: NSPoint(x: 12, y: 3.34))
mainPath.curve(to: NSPoint(x: 14.01, y: 7.83), controlPoint1: NSPoint(x: 12, y: 6.31), controlPoint2: NSPoint(x: 12.84, y: 7.43))
mainPath.curve(to: NSPoint(x: 14, y: 8), controlPoint1: NSPoint(x: 14, y: 7.89), controlPoint2: NSPoint(x: 14, y: 7.95))
mainPath.line(to: NSPoint(x: 14, y: 13))
mainPath.curve(to: NSPoint(x: 15, y: 14), controlPoint1: NSPoint(x: 14, y: 13.56), controlPoint2: NSPoint(x: 14.45, y: 14))
mainPath.curve(to: NSPoint(x: 16, y: 13), controlPoint1: NSPoint(x: 15.56, y: 14), controlPoint2: NSPoint(x: 16, y: 13.55))
mainPath.line(to: NSPoint(x: 16, y: 8))
mainPath.curve(to: NSPoint(x: 15.99, y: 7.83), controlPoint1: NSPoint(x: 16, y: 7.95), controlPoint2: NSPoint(x: 16, y: 7.89))
mainPath.line(to: NSPoint(x: 15.99, y: 7.83))
mainPath.close()
mainPath.move(to: NSPoint(x: 17, y: 8.46))
mainPath.curve(to: NSPoint(x: 19, y: 5), controlPoint1: NSPoint(x: 18.2, y: 7.77), controlPoint2: NSPoint(x: 19, y: 6.48))
mainPath.curve(to: NSPoint(x: 15, y: 1), controlPoint1: NSPoint(x: 19, y: 2.79), controlPoint2: NSPoint(x: 17.21, y: 1))
mainPath.curve(to: NSPoint(x: 11, y: 5), controlPoint1: NSPoint(x: 12.79, y: 1), controlPoint2: NSPoint(x: 11, y: 2.79))
mainPath.curve(to: NSPoint(x: 13, y: 8.46), controlPoint1: NSPoint(x: 11, y: 6.48), controlPoint2: NSPoint(x: 11.8, y: 7.77))
mainPath.line(to: NSPoint(x: 13, y: 27))
mainPath.curve(to: NSPoint(x: 15, y: 29), controlPoint1: NSPoint(x: 13, y: 28.11), controlPoint2: NSPoint(x: 13.9, y: 29))
mainPath.curve(to: NSPoint(x: 17, y: 27), controlPoint1: NSPoint(x: 16.11, y: 29), controlPoint2: NSPoint(x: 17, y: 28.1))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 9))
mainPath.curve(to: NSPoint(x: 20, y: 5), controlPoint1: NSPoint(x: 19.21, y: 8.09), controlPoint2: NSPoint(x: 20, y: 6.64))
mainPath.curve(to: NSPoint(x: 15, y: 0), controlPoint1: NSPoint(x: 20, y: 2.24), controlPoint2: NSPoint(x: 17.76, y: 0))
mainPath.curve(to: NSPoint(x: 10, y: 5), controlPoint1: NSPoint(x: 12.24, y: 0), controlPoint2: NSPoint(x: 10, y: 2.24))
mainPath.curve(to: NSPoint(x: 12, y: 9), controlPoint1: NSPoint(x: 10, y: 6.64), controlPoint2: NSPoint(x: 10.79, y: 8.09))
mainPath.line(to: NSPoint(x: 12, y: 27.01))
mainPath.curve(to: NSPoint(x: 15, y: 30), controlPoint1: NSPoint(x: 12, y: 28.66), controlPoint2: NSPoint(x: 13.34, y: 30))
mainPath.curve(to: NSPoint(x: 18, y: 27.01), controlPoint1: NSPoint(x: 16.65, y: 30), controlPoint2: NSPoint(x: 18, y: 28.66))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawThermometerHalf(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-69-thermometer-half
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15.99, y: 7.83))
mainPath.curve(to: NSPoint(x: 18, y: 5), controlPoint1: NSPoint(x: 17.16, y: 7.43), controlPoint2: NSPoint(x: 18, y: 6.31))
mainPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 18, y: 3.34), controlPoint2: NSPoint(x: 16.66, y: 2))
mainPath.curve(to: NSPoint(x: 12, y: 5), controlPoint1: NSPoint(x: 13.34, y: 2), controlPoint2: NSPoint(x: 12, y: 3.34))
mainPath.curve(to: NSPoint(x: 14.01, y: 7.83), controlPoint1: NSPoint(x: 12, y: 6.31), controlPoint2: NSPoint(x: 12.84, y: 7.43))
mainPath.curve(to: NSPoint(x: 14, y: 8), controlPoint1: NSPoint(x: 14, y: 7.89), controlPoint2: NSPoint(x: 14, y: 7.95))
mainPath.line(to: NSPoint(x: 14, y: 18))
mainPath.curve(to: NSPoint(x: 15, y: 19), controlPoint1: NSPoint(x: 14, y: 18.54), controlPoint2: NSPoint(x: 14.45, y: 19))
mainPath.curve(to: NSPoint(x: 16, y: 18), controlPoint1: NSPoint(x: 15.56, y: 19), controlPoint2: NSPoint(x: 16, y: 18.55))
mainPath.line(to: NSPoint(x: 16, y: 8))
mainPath.curve(to: NSPoint(x: 15.99, y: 7.83), controlPoint1: NSPoint(x: 16, y: 7.95), controlPoint2: NSPoint(x: 16, y: 7.89))
mainPath.line(to: NSPoint(x: 15.99, y: 7.83))
mainPath.close()
mainPath.move(to: NSPoint(x: 17, y: 8.46))
mainPath.curve(to: NSPoint(x: 19, y: 5), controlPoint1: NSPoint(x: 18.2, y: 7.77), controlPoint2: NSPoint(x: 19, y: 6.48))
mainPath.curve(to: NSPoint(x: 15, y: 1), controlPoint1: NSPoint(x: 19, y: 2.79), controlPoint2: NSPoint(x: 17.21, y: 1))
mainPath.curve(to: NSPoint(x: 11, y: 5), controlPoint1: NSPoint(x: 12.79, y: 1), controlPoint2: NSPoint(x: 11, y: 2.79))
mainPath.curve(to: NSPoint(x: 13, y: 8.46), controlPoint1: NSPoint(x: 11, y: 6.48), controlPoint2: NSPoint(x: 11.8, y: 7.77))
mainPath.line(to: NSPoint(x: 13, y: 27))
mainPath.curve(to: NSPoint(x: 15, y: 29), controlPoint1: NSPoint(x: 13, y: 28.11), controlPoint2: NSPoint(x: 13.9, y: 29))
mainPath.curve(to: NSPoint(x: 17, y: 27), controlPoint1: NSPoint(x: 16.11, y: 29), controlPoint2: NSPoint(x: 17, y: 28.1))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 9))
mainPath.curve(to: NSPoint(x: 20, y: 5), controlPoint1: NSPoint(x: 19.21, y: 8.09), controlPoint2: NSPoint(x: 20, y: 6.64))
mainPath.curve(to: NSPoint(x: 15, y: 0), controlPoint1: NSPoint(x: 20, y: 2.24), controlPoint2: NSPoint(x: 17.76, y: 0))
mainPath.curve(to: NSPoint(x: 10, y: 5), controlPoint1: NSPoint(x: 12.24, y: 0), controlPoint2: NSPoint(x: 10, y: 2.24))
mainPath.curve(to: NSPoint(x: 12, y: 9), controlPoint1: NSPoint(x: 10, y: 6.64), controlPoint2: NSPoint(x: 10.79, y: 8.09))
mainPath.line(to: NSPoint(x: 12, y: 27.01))
mainPath.curve(to: NSPoint(x: 15, y: 30), controlPoint1: NSPoint(x: 12, y: 28.66), controlPoint2: NSPoint(x: 13.34, y: 30))
mainPath.curve(to: NSPoint(x: 18, y: 27.01), controlPoint1: NSPoint(x: 16.65, y: 30), controlPoint2: NSPoint(x: 18, y: 28.66))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawThermometerThreeQuarters(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-70-thermometer-three-quarters
//// min Drawing
let minPath = NSBezierPath()
minPath.move(to: NSPoint(x: 15.99, y: 7.83))
minPath.curve(to: NSPoint(x: 18, y: 5), controlPoint1: NSPoint(x: 17.16, y: 7.43), controlPoint2: NSPoint(x: 18, y: 6.31))
minPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 18, y: 3.34), controlPoint2: NSPoint(x: 16.66, y: 2))
minPath.curve(to: NSPoint(x: 12, y: 5), controlPoint1: NSPoint(x: 13.34, y: 2), controlPoint2: NSPoint(x: 12, y: 3.34))
minPath.curve(to: NSPoint(x: 14.01, y: 7.83), controlPoint1: NSPoint(x: 12, y: 6.31), controlPoint2: NSPoint(x: 12.84, y: 7.43))
minPath.curve(to: NSPoint(x: 14, y: 8), controlPoint1: NSPoint(x: 14, y: 7.89), controlPoint2: NSPoint(x: 14, y: 7.94))
minPath.line(to: NSPoint(x: 14, y: 23))
minPath.curve(to: NSPoint(x: 15, y: 24), controlPoint1: NSPoint(x: 14, y: 23.55), controlPoint2: NSPoint(x: 14.45, y: 24))
minPath.curve(to: NSPoint(x: 16, y: 23), controlPoint1: NSPoint(x: 15.56, y: 24), controlPoint2: NSPoint(x: 16, y: 23.55))
minPath.line(to: NSPoint(x: 16, y: 8))
minPath.curve(to: NSPoint(x: 15.99, y: 7.83), controlPoint1: NSPoint(x: 16, y: 7.94), controlPoint2: NSPoint(x: 16, y: 7.89))
minPath.line(to: NSPoint(x: 15.99, y: 7.83))
minPath.close()
minPath.move(to: NSPoint(x: 17, y: 8.46))
minPath.curve(to: NSPoint(x: 19, y: 5), controlPoint1: NSPoint(x: 18.2, y: 7.77), controlPoint2: NSPoint(x: 19, y: 6.48))
minPath.curve(to: NSPoint(x: 15, y: 1), controlPoint1: NSPoint(x: 19, y: 2.79), controlPoint2: NSPoint(x: 17.21, y: 1))
minPath.curve(to: NSPoint(x: 11, y: 5), controlPoint1: NSPoint(x: 12.79, y: 1), controlPoint2: NSPoint(x: 11, y: 2.79))
minPath.curve(to: NSPoint(x: 13, y: 8.46), controlPoint1: NSPoint(x: 11, y: 6.48), controlPoint2: NSPoint(x: 11.8, y: 7.77))
minPath.line(to: NSPoint(x: 13, y: 27))
minPath.curve(to: NSPoint(x: 15, y: 29), controlPoint1: NSPoint(x: 13, y: 28.11), controlPoint2: NSPoint(x: 13.9, y: 29))
minPath.curve(to: NSPoint(x: 17, y: 27), controlPoint1: NSPoint(x: 16.11, y: 29), controlPoint2: NSPoint(x: 17, y: 28.1))
minPath.line(to: NSPoint(x: 17, y: 8.46))
minPath.line(to: NSPoint(x: 17, y: 8.46))
minPath.line(to: NSPoint(x: 17, y: 8.46))
minPath.close()
minPath.move(to: NSPoint(x: 18, y: 9))
minPath.curve(to: NSPoint(x: 20, y: 5), controlPoint1: NSPoint(x: 19.21, y: 8.09), controlPoint2: NSPoint(x: 20, y: 6.64))
minPath.curve(to: NSPoint(x: 15, y: 0), controlPoint1: NSPoint(x: 20, y: 2.24), controlPoint2: NSPoint(x: 17.76, y: 0))
minPath.curve(to: NSPoint(x: 10, y: 5), controlPoint1: NSPoint(x: 12.24, y: 0), controlPoint2: NSPoint(x: 10, y: 2.24))
minPath.curve(to: NSPoint(x: 12, y: 9), controlPoint1: NSPoint(x: 10, y: 6.64), controlPoint2: NSPoint(x: 10.79, y: 8.09))
minPath.line(to: NSPoint(x: 12, y: 27.01))
minPath.curve(to: NSPoint(x: 15, y: 30), controlPoint1: NSPoint(x: 12, y: 28.66), controlPoint2: NSPoint(x: 13.34, y: 30))
minPath.curve(to: NSPoint(x: 18, y: 27.01), controlPoint1: NSPoint(x: 16.65, y: 30), controlPoint2: NSPoint(x: 18, y: 28.66))
minPath.line(to: NSPoint(x: 18, y: 9))
minPath.line(to: NSPoint(x: 18, y: 9))
minPath.line(to: NSPoint(x: 18, y: 9))
minPath.close()
minPath.windingRule = .evenOddWindingRule
fillColor.setFill()
minPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawThermometerFull(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-71-thermometer-full
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15.99, y: 7.83))
mainPath.curve(to: NSPoint(x: 18, y: 5), controlPoint1: NSPoint(x: 17.16, y: 7.43), controlPoint2: NSPoint(x: 18, y: 6.31))
mainPath.curve(to: NSPoint(x: 15, y: 2), controlPoint1: NSPoint(x: 18, y: 3.34), controlPoint2: NSPoint(x: 16.66, y: 2))
mainPath.curve(to: NSPoint(x: 12, y: 5), controlPoint1: NSPoint(x: 13.34, y: 2), controlPoint2: NSPoint(x: 12, y: 3.34))
mainPath.curve(to: NSPoint(x: 14.01, y: 7.83), controlPoint1: NSPoint(x: 12, y: 6.31), controlPoint2: NSPoint(x: 12.84, y: 7.43))
mainPath.curve(to: NSPoint(x: 14, y: 8), controlPoint1: NSPoint(x: 14, y: 7.89), controlPoint2: NSPoint(x: 14, y: 7.94))
mainPath.line(to: NSPoint(x: 14, y: 27))
mainPath.curve(to: NSPoint(x: 15, y: 28), controlPoint1: NSPoint(x: 14, y: 27.56), controlPoint2: NSPoint(x: 14.45, y: 28))
mainPath.curve(to: NSPoint(x: 16, y: 27), controlPoint1: NSPoint(x: 15.56, y: 28), controlPoint2: NSPoint(x: 16, y: 27.55))
mainPath.line(to: NSPoint(x: 16, y: 8))
mainPath.curve(to: NSPoint(x: 15.99, y: 7.83), controlPoint1: NSPoint(x: 16, y: 7.94), controlPoint2: NSPoint(x: 16, y: 7.89))
mainPath.line(to: NSPoint(x: 15.99, y: 7.83))
mainPath.close()
mainPath.move(to: NSPoint(x: 17, y: 8.46))
mainPath.curve(to: NSPoint(x: 19, y: 5), controlPoint1: NSPoint(x: 18.2, y: 7.77), controlPoint2: NSPoint(x: 19, y: 6.48))
mainPath.curve(to: NSPoint(x: 15, y: 1), controlPoint1: NSPoint(x: 19, y: 2.79), controlPoint2: NSPoint(x: 17.21, y: 1))
mainPath.curve(to: NSPoint(x: 11, y: 5), controlPoint1: NSPoint(x: 12.79, y: 1), controlPoint2: NSPoint(x: 11, y: 2.79))
mainPath.curve(to: NSPoint(x: 13, y: 8.46), controlPoint1: NSPoint(x: 11, y: 6.48), controlPoint2: NSPoint(x: 11.8, y: 7.77))
mainPath.line(to: NSPoint(x: 13, y: 27))
mainPath.curve(to: NSPoint(x: 15, y: 29), controlPoint1: NSPoint(x: 13, y: 28.11), controlPoint2: NSPoint(x: 13.9, y: 29))
mainPath.curve(to: NSPoint(x: 17, y: 27), controlPoint1: NSPoint(x: 16.11, y: 29), controlPoint2: NSPoint(x: 17, y: 28.1))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.line(to: NSPoint(x: 17, y: 8.46))
mainPath.close()
mainPath.move(to: NSPoint(x: 18, y: 9))
mainPath.curve(to: NSPoint(x: 20, y: 5), controlPoint1: NSPoint(x: 19.21, y: 8.09), controlPoint2: NSPoint(x: 20, y: 6.64))
mainPath.curve(to: NSPoint(x: 15, y: 0), controlPoint1: NSPoint(x: 20, y: 2.24), controlPoint2: NSPoint(x: 17.76, y: 0))
mainPath.curve(to: NSPoint(x: 10, y: 5), controlPoint1: NSPoint(x: 12.24, y: 0), controlPoint2: NSPoint(x: 10, y: 2.24))
mainPath.curve(to: NSPoint(x: 12, y: 9), controlPoint1: NSPoint(x: 10, y: 6.64), controlPoint2: NSPoint(x: 10.79, y: 8.09))
mainPath.line(to: NSPoint(x: 12, y: 27.01))
mainPath.curve(to: NSPoint(x: 15, y: 30), controlPoint1: NSPoint(x: 12, y: 28.66), controlPoint2: NSPoint(x: 13.34, y: 30))
mainPath.curve(to: NSPoint(x: 18, y: 27.01), controlPoint1: NSPoint(x: 16.65, y: 30), controlPoint2: NSPoint(x: 18, y: 28.66))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.line(to: NSPoint(x: 18, y: 9))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawLightning(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-72-lightning
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 15.07, y: 17.5))
mainPath.line(to: NSPoint(x: 17.6, y: 17.5))
mainPath.line(to: NSPoint(x: 11.5, y: 11.4))
mainPath.line(to: NSPoint(x: 12.98, y: 15.5))
mainPath.line(to: NSPoint(x: 10.4, y: 15.5))
mainPath.line(to: NSPoint(x: 12.7, y: 21.5))
mainPath.line(to: NSPoint(x: 16.6, y: 21.5))
mainPath.line(to: NSPoint(x: 15.07, y: 17.5))
mainPath.line(to: NSPoint(x: 15.07, y: 17.5))
mainPath.close()
mainPath.move(to: NSPoint(x: 11.55, y: 14.5))
mainPath.line(to: NSPoint(x: 9, y: 14.5))
mainPath.line(to: NSPoint(x: 12, y: 22.5))
mainPath.line(to: NSPoint(x: 18, y: 22.5))
mainPath.line(to: NSPoint(x: 16.5, y: 18.5))
mainPath.line(to: NSPoint(x: 20, y: 18.5))
mainPath.line(to: NSPoint(x: 9, y: 7.5))
mainPath.line(to: NSPoint(x: 11.55, y: 14.5))
mainPath.line(to: NSPoint(x: 11.55, y: 14.5))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawWindTurbine(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-73-wind-turbine
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 16.99, y: 15.8))
mainPath.curve(to: NSPoint(x: 22.95, y: 13.31), controlPoint1: NSPoint(x: 20.86, y: 14.1), controlPoint2: NSPoint(x: 22.95, y: 13.31))
mainPath.curve(to: NSPoint(x: 17.77, y: 17.13), controlPoint1: NSPoint(x: 22.95, y: 13.31), controlPoint2: NSPoint(x: 20.59, y: 15.16))
mainPath.curve(to: NSPoint(x: 16.99, y: 15.8), controlPoint1: NSPoint(x: 17.64, y: 16.62), controlPoint2: NSPoint(x: 17.37, y: 16.16))
mainPath.line(to: NSPoint(x: 16.99, y: 15.8))
mainPath.line(to: NSPoint(x: 16.99, y: 15.8))
mainPath.close()
mainPath.move(to: NSPoint(x: 12.21, y: 17.14))
mainPath.curve(to: NSPoint(x: 6.97, y: 13.27), controlPoint1: NSPoint(x: 8.73, y: 14.67), controlPoint2: NSPoint(x: 6.97, y: 13.27))
mainPath.curve(to: NSPoint(x: 13, y: 15.79), controlPoint1: NSPoint(x: 6.97, y: 13.27), controlPoint2: NSPoint(x: 9.82, y: 14.37))
mainPath.curve(to: NSPoint(x: 12.21, y: 17.14), controlPoint1: NSPoint(x: 12.62, y: 16.15), controlPoint2: NSPoint(x: 12.34, y: 16.62))
mainPath.line(to: NSPoint(x: 12.21, y: 17.14))
mainPath.line(to: NSPoint(x: 12.21, y: 17.14))
mainPath.close()
mainPath.move(to: NSPoint(x: 17.83, y: 18.23))
mainPath.curve(to: NSPoint(x: 25.77, y: 11.69), controlPoint1: NSPoint(x: 20.27, y: 16.52), controlPoint2: NSPoint(x: 26.15, y: 12.34))
mainPath.curve(to: NSPoint(x: 16.05, y: 15.16), controlPoint1: NSPoint(x: 25.39, y: 11.05), controlPoint2: NSPoint(x: 18.79, y: 13.93))
mainPath.line(to: NSPoint(x: 16.05, y: 15.16))
mainPath.line(to: NSPoint(x: 16.9, y: 0.94))
mainPath.curve(to: NSPoint(x: 14.99, y: 0), controlPoint1: NSPoint(x: 16.9, y: 0.94), controlPoint2: NSPoint(x: 16.43, y: 0))
mainPath.curve(to: NSPoint(x: 13.08, y: 0.94), controlPoint1: NSPoint(x: 13.56, y: 0), controlPoint2: NSPoint(x: 13.08, y: 0.94))
mainPath.line(to: NSPoint(x: 13.93, y: 15.16))
mainPath.line(to: NSPoint(x: 13.93, y: 15.16))
mainPath.curve(to: NSPoint(x: 4.22, y: 11.69), controlPoint1: NSPoint(x: 11.2, y: 13.93), controlPoint2: NSPoint(x: 4.6, y: 11.05))
mainPath.curve(to: NSPoint(x: 12.16, y: 18.23), controlPoint1: NSPoint(x: 3.84, y: 12.34), controlPoint2: NSPoint(x: 9.71, y: 16.52))
mainPath.curve(to: NSPoint(x: 13.2, y: 20), controlPoint1: NSPoint(x: 12.26, y: 18.94), controlPoint2: NSPoint(x: 12.65, y: 19.57))
mainPath.curve(to: NSPoint(x: 14.99, y: 30), controlPoint1: NSPoint(x: 13.48, y: 22.94), controlPoint2: NSPoint(x: 14.23, y: 30))
mainPath.curve(to: NSPoint(x: 16.79, y: 20), controlPoint1: NSPoint(x: 15.75, y: 30), controlPoint2: NSPoint(x: 16.51, y: 22.94))
mainPath.curve(to: NSPoint(x: 17.83, y: 18.23), controlPoint1: NSPoint(x: 17.34, y: 19.57), controlPoint2: NSPoint(x: 17.72, y: 18.94))
mainPath.line(to: NSPoint(x: 17.83, y: 18.23))
mainPath.line(to: NSPoint(x: 17.83, y: 18.23))
mainPath.close()
mainPath.move(to: NSPoint(x: 14.88, y: 15))
mainPath.line(to: NSPoint(x: 14.05, y: 1.24))
mainPath.curve(to: NSPoint(x: 14.99, y: 0.94), controlPoint1: NSPoint(x: 14.05, y: 1.24), controlPoint2: NSPoint(x: 14.23, y: 0.94))
mainPath.curve(to: NSPoint(x: 15.95, y: 1.24), controlPoint1: NSPoint(x: 15.75, y: 0.94), controlPoint2: NSPoint(x: 15.95, y: 1.24))
mainPath.line(to: NSPoint(x: 15.11, y: 15))
mainPath.curve(to: NSPoint(x: 14.99, y: 15), controlPoint1: NSPoint(x: 15.07, y: 15), controlPoint2: NSPoint(x: 15.03, y: 15))
mainPath.curve(to: NSPoint(x: 14.88, y: 15), controlPoint1: NSPoint(x: 14.95, y: 15), controlPoint2: NSPoint(x: 14.92, y: 15))
mainPath.line(to: NSPoint(x: 14.88, y: 15))
mainPath.line(to: NSPoint(x: 14.88, y: 15))
mainPath.close()
mainPath.move(to: NSPoint(x: 15.78, y: 20.52))
mainPath.curve(to: NSPoint(x: 14.99, y: 26.89), controlPoint1: NSPoint(x: 15.34, y: 24.7), controlPoint2: NSPoint(x: 14.99, y: 26.89))
mainPath.curve(to: NSPoint(x: 14.2, y: 20.52), controlPoint1: NSPoint(x: 14.99, y: 26.89), controlPoint2: NSPoint(x: 14.54, y: 23.92))
mainPath.curve(to: NSPoint(x: 14.99, y: 20.62), controlPoint1: NSPoint(x: 14.45, y: 20.59), controlPoint2: NSPoint(x: 14.72, y: 20.62))
mainPath.curve(to: NSPoint(x: 15.78, y: 20.52), controlPoint1: NSPoint(x: 15.27, y: 20.62), controlPoint2: NSPoint(x: 15.53, y: 20.59))
mainPath.line(to: NSPoint(x: 15.78, y: 20.52))
mainPath.line(to: NSPoint(x: 15.78, y: 20.52))
mainPath.close()
mainPath.move(to: NSPoint(x: 14.99, y: 15.94))
mainPath.curve(to: NSPoint(x: 16.9, y: 17.81), controlPoint1: NSPoint(x: 16.05, y: 15.94), controlPoint2: NSPoint(x: 16.9, y: 16.78))
mainPath.curve(to: NSPoint(x: 14.99, y: 19.69), controlPoint1: NSPoint(x: 16.9, y: 18.85), controlPoint2: NSPoint(x: 16.05, y: 19.69))
mainPath.curve(to: NSPoint(x: 13.08, y: 17.81), controlPoint1: NSPoint(x: 13.94, y: 19.69), controlPoint2: NSPoint(x: 13.08, y: 18.85))
mainPath.curve(to: NSPoint(x: 14.99, y: 15.94), controlPoint1: NSPoint(x: 13.08, y: 16.78), controlPoint2: NSPoint(x: 13.94, y: 15.94))
mainPath.line(to: NSPoint(x: 14.99, y: 15.94))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
public dynamic class func drawSnowflake(frame targetFrame: NSRect = NSRect(x: 0, y: 0, width: 30, height: 30), resizing: ResizingBehavior = .aspectFit, fillColor: NSColor = NSColor(calibratedRed: 0.081, green: 0.394, blue: 0.979, alpha: 1)) {
//// General Declarations
let context = NSGraphicsContext.current()!.cgContext
//// Resize to Target Frame
NSGraphicsContext.saveGraphicsState()
let resizedFrame: NSRect = resizing.apply(rect: NSRect(x: 0, y: 0, width: 30, height: 30), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 30, y: resizedFrame.height / 30)
//// Page-1
//// icon-74-snowflake
//// main Drawing
let mainPath = NSBezierPath()
mainPath.move(to: NSPoint(x: 11.47, y: 12.18))
mainPath.line(to: NSPoint(x: 13.79, y: 14.5))
mainPath.line(to: NSPoint(x: 8.16, y: 14.5))
mainPath.curve(to: NSPoint(x: 8.05, y: 14.33), controlPoint1: NSPoint(x: 8.14, y: 14.44), controlPoint2: NSPoint(x: 8.1, y: 14.38))
mainPath.line(to: NSPoint(x: 6.63, y: 12.91))
mainPath.curve(to: NSPoint(x: 5.93, y: 12.92), controlPoint1: NSPoint(x: 6.44, y: 12.72), controlPoint2: NSPoint(x: 6.13, y: 12.72))
mainPath.curve(to: NSPoint(x: 5.93, y: 13.62), controlPoint1: NSPoint(x: 5.74, y: 13.11), controlPoint2: NSPoint(x: 5.73, y: 13.43))
mainPath.line(to: NSPoint(x: 6.81, y: 14.5))
mainPath.line(to: NSPoint(x: 6.01, y: 14.5))
mainPath.curve(to: NSPoint(x: 5.5, y: 15), controlPoint1: NSPoint(x: 5.73, y: 14.5), controlPoint2: NSPoint(x: 5.5, y: 14.72))
mainPath.curve(to: NSPoint(x: 6.01, y: 15.5), controlPoint1: NSPoint(x: 5.5, y: 15.27), controlPoint2: NSPoint(x: 5.73, y: 15.5))
mainPath.line(to: NSPoint(x: 6.76, y: 15.5))
mainPath.line(to: NSPoint(x: 5.93, y: 16.33))
mainPath.curve(to: NSPoint(x: 5.93, y: 17.04), controlPoint1: NSPoint(x: 5.73, y: 16.53), controlPoint2: NSPoint(x: 5.74, y: 16.85))
mainPath.curve(to: NSPoint(x: 6.63, y: 17.04), controlPoint1: NSPoint(x: 6.13, y: 17.23), controlPoint2: NSPoint(x: 6.44, y: 17.24))
mainPath.line(to: NSPoint(x: 8.05, y: 15.62))
mainPath.curve(to: NSPoint(x: 8.14, y: 15.5), controlPoint1: NSPoint(x: 8.09, y: 15.58), controlPoint2: NSPoint(x: 8.12, y: 15.54))
mainPath.line(to: NSPoint(x: 8.14, y: 15.5))
mainPath.line(to: NSPoint(x: 13.79, y: 15.5))
mainPath.line(to: NSPoint(x: 11.49, y: 17.81))
mainPath.line(to: NSPoint(x: 11.49, y: 17.81))
mainPath.curve(to: NSPoint(x: 11.31, y: 17.77), controlPoint1: NSPoint(x: 11.43, y: 17.79), controlPoint2: NSPoint(x: 11.37, y: 17.77))
mainPath.line(to: NSPoint(x: 9.3, y: 17.77))
mainPath.curve(to: NSPoint(x: 8.81, y: 18.27), controlPoint1: NSPoint(x: 9.02, y: 17.77), controlPoint2: NSPoint(x: 8.81, y: 18))
mainPath.curve(to: NSPoint(x: 9.3, y: 18.77), controlPoint1: NSPoint(x: 8.81, y: 18.54), controlPoint2: NSPoint(x: 9.03, y: 18.77))
mainPath.line(to: NSPoint(x: 10.52, y: 18.77))
mainPath.line(to: NSPoint(x: 9.7, y: 19.6))
mainPath.curve(to: NSPoint(x: 9.7, y: 20.3), controlPoint1: NSPoint(x: 9.5, y: 19.79), controlPoint2: NSPoint(x: 9.51, y: 20.11))
mainPath.curve(to: NSPoint(x: 10.4, y: 20.3), controlPoint1: NSPoint(x: 9.89, y: 20.5), controlPoint2: NSPoint(x: 10.21, y: 20.5))
mainPath.line(to: NSPoint(x: 11.22, y: 19.48))
mainPath.line(to: NSPoint(x: 11.22, y: 20.69))
mainPath.curve(to: NSPoint(x: 11.72, y: 21.19), controlPoint1: NSPoint(x: 11.22, y: 20.97), controlPoint2: NSPoint(x: 11.45, y: 21.19))
mainPath.curve(to: NSPoint(x: 12.22, y: 20.69), controlPoint1: NSPoint(x: 12, y: 21.19), controlPoint2: NSPoint(x: 12.22, y: 20.97))
mainPath.line(to: NSPoint(x: 12.22, y: 18.68))
mainPath.curve(to: NSPoint(x: 12.19, y: 18.52), controlPoint1: NSPoint(x: 12.22, y: 18.62), controlPoint2: NSPoint(x: 12.21, y: 18.57))
mainPath.line(to: NSPoint(x: 14.5, y: 16.21))
mainPath.line(to: NSPoint(x: 14.5, y: 21.84))
mainPath.line(to: NSPoint(x: 14.5, y: 21.84))
mainPath.curve(to: NSPoint(x: 14.37, y: 21.94), controlPoint1: NSPoint(x: 14.45, y: 21.87), controlPoint2: NSPoint(x: 14.41, y: 21.9))
mainPath.line(to: NSPoint(x: 12.95, y: 23.36))
mainPath.curve(to: NSPoint(x: 12.95, y: 24.06), controlPoint1: NSPoint(x: 12.75, y: 23.55), controlPoint2: NSPoint(x: 12.76, y: 23.87))
mainPath.curve(to: NSPoint(x: 13.66, y: 24.06), controlPoint1: NSPoint(x: 13.14, y: 24.25), controlPoint2: NSPoint(x: 13.46, y: 24.26))
mainPath.line(to: NSPoint(x: 14.5, y: 23.22))
mainPath.line(to: NSPoint(x: 14.5, y: 23.99))
mainPath.curve(to: NSPoint(x: 15, y: 24.5), controlPoint1: NSPoint(x: 14.5, y: 24.27), controlPoint2: NSPoint(x: 14.72, y: 24.5))
mainPath.curve(to: NSPoint(x: 15.5, y: 23.99), controlPoint1: NSPoint(x: 15.27, y: 24.5), controlPoint2: NSPoint(x: 15.5, y: 24.27))
mainPath.line(to: NSPoint(x: 15.5, y: 23.19))
mainPath.line(to: NSPoint(x: 16.37, y: 24.06))
mainPath.curve(to: NSPoint(x: 17.07, y: 24.06), controlPoint1: NSPoint(x: 16.56, y: 24.26), controlPoint2: NSPoint(x: 16.89, y: 24.25))
mainPath.curve(to: NSPoint(x: 17.08, y: 23.36), controlPoint1: NSPoint(x: 17.27, y: 23.87), controlPoint2: NSPoint(x: 17.28, y: 23.55))
mainPath.line(to: NSPoint(x: 15.66, y: 21.94))
mainPath.curve(to: NSPoint(x: 15.5, y: 21.83), controlPoint1: NSPoint(x: 15.61, y: 21.89), controlPoint2: NSPoint(x: 15.56, y: 21.85))
mainPath.line(to: NSPoint(x: 15.5, y: 16.21))
mainPath.line(to: NSPoint(x: 15.5, y: 16.21))
mainPath.line(to: NSPoint(x: 17.81, y: 18.52))
mainPath.curve(to: NSPoint(x: 17.78, y: 18.67), controlPoint1: NSPoint(x: 17.79, y: 18.56), controlPoint2: NSPoint(x: 17.78, y: 18.62))
mainPath.line(to: NSPoint(x: 17.78, y: 20.68))
mainPath.curve(to: NSPoint(x: 18.28, y: 21.17), controlPoint1: NSPoint(x: 17.78, y: 20.96), controlPoint2: NSPoint(x: 18.01, y: 21.17))
mainPath.curve(to: NSPoint(x: 18.78, y: 20.68), controlPoint1: NSPoint(x: 18.55, y: 21.17), controlPoint2: NSPoint(x: 18.78, y: 20.95))
mainPath.line(to: NSPoint(x: 18.78, y: 19.49))
mainPath.line(to: NSPoint(x: 19.6, y: 20.3))
mainPath.curve(to: NSPoint(x: 20.3, y: 20.3), controlPoint1: NSPoint(x: 19.79, y: 20.5), controlPoint2: NSPoint(x: 20.11, y: 20.5))
mainPath.curve(to: NSPoint(x: 20.3, y: 19.6), controlPoint1: NSPoint(x: 20.49, y: 20.11), controlPoint2: NSPoint(x: 20.5, y: 19.79))
mainPath.line(to: NSPoint(x: 19.47, y: 18.76))
mainPath.line(to: NSPoint(x: 20.7, y: 18.76))
mainPath.curve(to: NSPoint(x: 21.2, y: 18.26), controlPoint1: NSPoint(x: 20.98, y: 18.76), controlPoint2: NSPoint(x: 21.2, y: 18.53))
mainPath.curve(to: NSPoint(x: 20.7, y: 17.76), controlPoint1: NSPoint(x: 21.2, y: 17.98), controlPoint2: NSPoint(x: 20.98, y: 17.76))
mainPath.line(to: NSPoint(x: 18.69, y: 17.76))
mainPath.curve(to: NSPoint(x: 18.5, y: 17.8), controlPoint1: NSPoint(x: 18.63, y: 17.76), controlPoint2: NSPoint(x: 18.56, y: 17.77))
mainPath.line(to: NSPoint(x: 18.5, y: 17.8))
mainPath.line(to: NSPoint(x: 16.21, y: 15.5))
mainPath.line(to: NSPoint(x: 21.89, y: 15.5))
mainPath.curve(to: NSPoint(x: 21.97, y: 15.62), controlPoint1: NSPoint(x: 21.91, y: 15.54), controlPoint2: NSPoint(x: 21.94, y: 15.58))
mainPath.line(to: NSPoint(x: 23.39, y: 17.04))
mainPath.curve(to: NSPoint(x: 24.1, y: 17.04), controlPoint1: NSPoint(x: 23.59, y: 17.24), controlPoint2: NSPoint(x: 23.9, y: 17.23))
mainPath.curve(to: NSPoint(x: 24.1, y: 16.33), controlPoint1: NSPoint(x: 24.29, y: 16.85), controlPoint2: NSPoint(x: 24.29, y: 16.53))
mainPath.line(to: NSPoint(x: 23.27, y: 15.5))
mainPath.line(to: NSPoint(x: 23.99, y: 15.5))
mainPath.curve(to: NSPoint(x: 24.5, y: 15), controlPoint1: NSPoint(x: 24.27, y: 15.5), controlPoint2: NSPoint(x: 24.5, y: 15.28))
mainPath.curve(to: NSPoint(x: 23.99, y: 14.5), controlPoint1: NSPoint(x: 24.5, y: 14.73), controlPoint2: NSPoint(x: 24.27, y: 14.5))
mainPath.line(to: NSPoint(x: 23.22, y: 14.5))
mainPath.line(to: NSPoint(x: 24.1, y: 13.62))
mainPath.curve(to: NSPoint(x: 24.1, y: 12.92), controlPoint1: NSPoint(x: 24.29, y: 13.43), controlPoint2: NSPoint(x: 24.29, y: 13.11))
mainPath.curve(to: NSPoint(x: 23.39, y: 12.91), controlPoint1: NSPoint(x: 23.9, y: 12.72), controlPoint2: NSPoint(x: 23.59, y: 12.72))
mainPath.line(to: NSPoint(x: 21.97, y: 14.33))
mainPath.curve(to: NSPoint(x: 21.87, y: 14.5), controlPoint1: NSPoint(x: 21.92, y: 14.38), controlPoint2: NSPoint(x: 21.89, y: 14.44))
mainPath.line(to: NSPoint(x: 21.87, y: 14.5))
mainPath.line(to: NSPoint(x: 16.21, y: 14.5))
mainPath.line(to: NSPoint(x: 18.53, y: 12.18))
mainPath.line(to: NSPoint(x: 18.53, y: 12.18))
mainPath.curve(to: NSPoint(x: 18.68, y: 12.2), controlPoint1: NSPoint(x: 18.58, y: 12.19), controlPoint2: NSPoint(x: 18.63, y: 12.2))
mainPath.line(to: NSPoint(x: 20.69, y: 12.2))
mainPath.curve(to: NSPoint(x: 21.18, y: 11.7), controlPoint1: NSPoint(x: 20.97, y: 12.2), controlPoint2: NSPoint(x: 21.18, y: 11.97))
mainPath.curve(to: NSPoint(x: 20.69, y: 11.2), controlPoint1: NSPoint(x: 21.18, y: 11.43), controlPoint2: NSPoint(x: 20.96, y: 11.2))
mainPath.line(to: NSPoint(x: 19.51, y: 11.2))
mainPath.line(to: NSPoint(x: 20.3, y: 10.4))
mainPath.curve(to: NSPoint(x: 20.3, y: 9.7), controlPoint1: NSPoint(x: 20.5, y: 10.21), controlPoint2: NSPoint(x: 20.49, y: 9.89))
mainPath.curve(to: NSPoint(x: 19.6, y: 9.7), controlPoint1: NSPoint(x: 20.11, y: 9.5), controlPoint2: NSPoint(x: 19.79, y: 9.5))
mainPath.line(to: NSPoint(x: 18.77, y: 10.52))
mainPath.line(to: NSPoint(x: 18.77, y: 9.28))
mainPath.curve(to: NSPoint(x: 18.27, y: 8.78), controlPoint1: NSPoint(x: 18.77, y: 9.01), controlPoint2: NSPoint(x: 18.54, y: 8.78))
mainPath.curve(to: NSPoint(x: 17.77, y: 9.28), controlPoint1: NSPoint(x: 17.99, y: 8.78), controlPoint2: NSPoint(x: 17.77, y: 9))
mainPath.line(to: NSPoint(x: 17.77, y: 11.29))
mainPath.curve(to: NSPoint(x: 17.81, y: 11.48), controlPoint1: NSPoint(x: 17.77, y: 11.36), controlPoint2: NSPoint(x: 17.78, y: 11.42))
mainPath.line(to: NSPoint(x: 15.5, y: 13.79))
mainPath.line(to: NSPoint(x: 15.5, y: 8.12))
mainPath.line(to: NSPoint(x: 15.5, y: 8.12))
mainPath.curve(to: NSPoint(x: 15.66, y: 8.02), controlPoint1: NSPoint(x: 15.56, y: 8.1), controlPoint2: NSPoint(x: 15.61, y: 8.06))
mainPath.line(to: NSPoint(x: 17.08, y: 6.6))
mainPath.curve(to: NSPoint(x: 17.07, y: 5.89), controlPoint1: NSPoint(x: 17.28, y: 6.4), controlPoint2: NSPoint(x: 17.27, y: 6.09))
mainPath.curve(to: NSPoint(x: 16.37, y: 5.89), controlPoint1: NSPoint(x: 16.89, y: 5.7), controlPoint2: NSPoint(x: 16.56, y: 5.7))
mainPath.line(to: NSPoint(x: 15.5, y: 6.76))
mainPath.line(to: NSPoint(x: 15.5, y: 6.01))
mainPath.curve(to: NSPoint(x: 15, y: 5.5), controlPoint1: NSPoint(x: 15.5, y: 5.73), controlPoint2: NSPoint(x: 15.28, y: 5.5))
mainPath.curve(to: NSPoint(x: 14.5, y: 6.01), controlPoint1: NSPoint(x: 14.73, y: 5.5), controlPoint2: NSPoint(x: 14.5, y: 5.73))
mainPath.line(to: NSPoint(x: 14.5, y: 6.73))
mainPath.line(to: NSPoint(x: 13.66, y: 5.89))
mainPath.curve(to: NSPoint(x: 12.95, y: 5.89), controlPoint1: NSPoint(x: 13.46, y: 5.7), controlPoint2: NSPoint(x: 13.14, y: 5.7))
mainPath.curve(to: NSPoint(x: 12.95, y: 6.6), controlPoint1: NSPoint(x: 12.76, y: 6.09), controlPoint2: NSPoint(x: 12.75, y: 6.4))
mainPath.line(to: NSPoint(x: 14.37, y: 8.02))
mainPath.curve(to: NSPoint(x: 14.5, y: 8.11), controlPoint1: NSPoint(x: 14.41, y: 8.06), controlPoint2: NSPoint(x: 14.45, y: 8.09))
mainPath.line(to: NSPoint(x: 14.5, y: 13.79))
mainPath.line(to: NSPoint(x: 12.18, y: 11.47))
mainPath.curve(to: NSPoint(x: 12.21, y: 11.3), controlPoint1: NSPoint(x: 12.2, y: 11.42), controlPoint2: NSPoint(x: 12.21, y: 11.36))
mainPath.line(to: NSPoint(x: 12.21, y: 9.29))
mainPath.curve(to: NSPoint(x: 11.71, y: 8.8), controlPoint1: NSPoint(x: 12.21, y: 9.02), controlPoint2: NSPoint(x: 11.98, y: 8.8))
mainPath.curve(to: NSPoint(x: 11.21, y: 9.29), controlPoint1: NSPoint(x: 11.44, y: 8.8), controlPoint2: NSPoint(x: 11.21, y: 9.02))
mainPath.line(to: NSPoint(x: 11.21, y: 10.5))
mainPath.line(to: NSPoint(x: 10.4, y: 9.7))
mainPath.curve(to: NSPoint(x: 9.7, y: 9.7), controlPoint1: NSPoint(x: 10.21, y: 9.5), controlPoint2: NSPoint(x: 9.89, y: 9.5))
mainPath.curve(to: NSPoint(x: 9.7, y: 10.4), controlPoint1: NSPoint(x: 9.51, y: 9.89), controlPoint2: NSPoint(x: 9.5, y: 10.21))
mainPath.line(to: NSPoint(x: 10.51, y: 11.21))
mainPath.line(to: NSPoint(x: 9.29, y: 11.21))
mainPath.curve(to: NSPoint(x: 8.79, y: 11.71), controlPoint1: NSPoint(x: 9.01, y: 11.21), controlPoint2: NSPoint(x: 8.79, y: 11.45))
mainPath.curve(to: NSPoint(x: 9.29, y: 12.21), controlPoint1: NSPoint(x: 8.79, y: 11.99), controlPoint2: NSPoint(x: 9.01, y: 12.21))
mainPath.line(to: NSPoint(x: 11.3, y: 12.21))
mainPath.curve(to: NSPoint(x: 11.47, y: 12.18), controlPoint1: NSPoint(x: 11.36, y: 12.21), controlPoint2: NSPoint(x: 11.42, y: 12.2))
mainPath.line(to: NSPoint(x: 11.47, y: 12.18))
mainPath.close()
mainPath.windingRule = .evenOddWindingRule
fillColor.setFill()
mainPath.fill()
NSGraphicsContext.restoreGraphicsState()
}
@objc public enum ResizingBehavior: Int {
case aspectFit /// The content is proportionally resized to fit into the target rectangle.
case aspectFill /// The content is proportionally resized to completely fill the target rectangle.
case stretch /// The content is stretched to match the entire target rectangle.
case center /// The content is centered in the target rectangle, but it is NOT resized.
public func apply(rect: NSRect, target: NSRect) -> NSRect {
if rect == target || target == NSRect.zero {
return rect
}
var scales = NSSize.zero
scales.width = abs(target.width / rect.width)
scales.height = abs(target.height / rect.height)
switch self {
case .aspectFit:
scales.width = min(scales.width, scales.height)
scales.height = scales.width
case .aspectFill:
scales.width = max(scales.width, scales.height)
scales.height = scales.width
case .stretch:
break
case .center:
scales.width = 1
scales.height = 1
}
var result = rect.standardized
result.size.width *= scales.width
result.size.height *= scales.height
result.origin.x = target.minX + (target.width - result.width) / 2
result.origin.y = target.minY + (target.height - result.height) / 2
return result
}
}
}
|
mit
|
d9911a6b287f18a4b77f23eeccd95da9
| 77.995378 | 261 | 0.615153 | 2.815669 | false | false | false | false |
ahoppen/swift
|
test/Generics/associated_types.swift
|
40
|
3766
|
// RUN: %target-typecheck-verify-swift
// Deduction of associated types.
protocol Fooable {
associatedtype AssocType
func foo(_ x : AssocType)
}
struct X : Fooable {
func foo(_ x: Float) {}
}
struct Y<T> : Fooable {
func foo(_ x: T) {}
}
struct Z : Fooable {
func foo(_ x: Float) {}
func blah() {
var a : AssocType // expected-warning {{variable 'a' was never used; consider replacing with '_' or removing it}} {{9-10=_}}
}
func blarg() -> AssocType {}
func wonka() -> Z.AssocType {}
}
var xa : X.AssocType = Float()
var yf : Y<Float>.AssocType = Float()
var yd : Y<Double>.AssocType = Double()
var f : Float
f = xa
f = yf
var d : Double
d = yd
protocol P1 {
associatedtype Assoc1
func foo() -> Assoc1
}
struct S1 : P1 {
func foo() -> X {}
}
prefix operator %
protocol P2 {
associatedtype Assoc2
static prefix func %(target: Self) -> Assoc2
}
prefix func % <P:P1>(target: P) -> P.Assoc1 {
}
extension S1 : P2 {
typealias Assoc2 = X
}
// <rdar://problem/14418181>
protocol P3 {
associatedtype Assoc3
func foo() -> Assoc3
}
protocol P4 : P3 {
associatedtype Assoc4
func bar() -> Assoc4
}
func takeP4<T : P4>(_ x: T) { }
struct S4<T> : P3, P4 {
func foo() -> Int {}
func bar() -> Double {}
}
takeP4(S4<Int>())
// <rdar://problem/14680393>
infix operator ~>
protocol P5 { }
struct S7a {}
protocol P6 {
func foo<Target: P5>(_ target: inout Target)
}
protocol P7 : P6 {
associatedtype Assoc : P6
static func ~> (x: Self, _: S7a) -> Assoc
}
func ~> <T:P6>(x: T, _: S7a) -> S7b { return S7b() }
struct S7b : P7 {
typealias Assoc = S7b
func foo<Target: P5>(_ target: inout Target) {}
}
// <rdar://problem/14685674>
struct zip<A : IteratorProtocol, B : IteratorProtocol>
: IteratorProtocol, Sequence {
func next() -> (A.Element, B.Element)? { }
typealias Generator = zip
func makeIterator() -> zip { }
}
protocol P8 { }
protocol P9 {
associatedtype A1 : P8
}
protocol P10 {
associatedtype A1b : P8
associatedtype A2 : P9
func f()
func g(_ a: A1b)
func h(_ a: A2)
}
struct X8 : P8 { }
struct Y9 : P9 {
typealias A1 = X8
}
struct Z10 : P10 {
func f() { }
func g(_ a: X8) { }
func h(_ a: Y9) { }
}
struct W : Fooable {
func foo(_ x: String) {}
}
struct V<T> : Fooable {
func foo(_ x: T) {}
}
// FIXME: <rdar://problem/16123805> associated Inferred types can't be used in expression contexts
var w = W.AssocType()
var v = V<String>.AssocType()
//
// SR-427
protocol A {
func c()
}
protocol B : A {
associatedtype e : A = C<Self>
}
extension B {
func c() {
}
}
struct C<a : B> : B {
}
struct CC : B {
typealias e = CC
}
C<CC>().c()
// SR-511
protocol sr511 {
typealias Foo // expected-error {{type alias is missing an assigned type; use 'associatedtype' to define an associated type requirement}}
}
associatedtype Foo = Int // expected-error {{associated types can only be defined in a protocol; define a type or introduce a 'typealias' to satisfy an associated type requirement}}
// rdar://problem/29207581
protocol P {
associatedtype A
static var isP : Bool { get }
}
protocol M {
associatedtype B : P
}
extension M {
func g<C : P>(in c_: C)
where Self.B == C.A, C.A.A : P { // *clearly* implies Self.B.A : P
_ = B.A.isP
}
}
// SR-6097
protocol sr6097 {
associatedtype A : AnyObject
var aProperty: A { get }
}
class C1 {}
class C2 : sr6097 {
unowned let aProperty: C1 // should deduce A == C1 despite 'unowned'
init() { fatalError() }
}
protocol sr6097_b {
associatedtype A : AnyObject
var aProperty: A? { get }
}
class C3 : sr6097_b {
weak var aProperty: C1? // and same here, despite 'weak'
init() { fatalError() }
}
class G<T> : sr6097_b where T : AnyObject {
weak var aProperty: T?
}
|
apache-2.0
|
da6ca5db23ff1c066dcd98246323d807
| 15.590308 | 181 | 0.61949 | 2.935308 | false | false | false | false |
taketo1024/SwiftyAlgebra
|
Sources/SwmCore/Abstract/AdditiveGroup.swift
|
1
|
3961
|
public protocol AdditiveGroup: MathSet {
static var zero: Self { get }
var isZero: Bool { get }
var reduced: Self { get }
static func + (a: Self, b: Self) -> Self
prefix static func -(a: Self) -> Self
static func -(a: Self, b: Self) -> Self
static func sum<S: Sequence>(_ elements: S) -> Self where S.Element == Self
}
public extension AdditiveGroup {
@inlinable
var isZero: Bool {
self == .zero
}
@inlinable
var reduced: Self {
self
}
@inlinable
static func -(a: Self, b: Self) -> Self {
a + (-b)
}
@inlinable
static func sum<S: Sequence>(_ elements: S) -> Self where S.Element == Self {
elements.reduce(.zero){ (res, e) in res + e }
}
}
public extension Sequence where Element: AdditiveGroup {
@inlinable
func sum() -> Element {
Element.sum(self)
}
func accumulate() -> [Element] {
self.reduce(into: []) { (res, r) in
res.append( (res.last ?? .zero) + r)
}
}
}
public extension Sequence {
@inlinable
func sum<G: AdditiveGroup>(mapping f: (Element) -> G) -> G {
G.sum( self.map(f) )
}
}
public protocol AdditiveSubgroup: AdditiveGroup, Subset where Super: AdditiveGroup {}
public extension AdditiveSubgroup {
static var zero: Self {
Self(Super.zero)
}
static func +(a: Self, b: Self) -> Self {
Self(a.asSuper + b.asSuper)
}
prefix static func -(a: Self) -> Self {
Self(-a.asSuper)
}
}
public protocol AdditiveProductGroup: ProductSet, AdditiveGroup where Left: AdditiveGroup, Right: AdditiveGroup {}
public extension AdditiveProductGroup {
static var zero: Self {
Self(.zero, .zero)
}
static func +(a: Self, b: Self) -> Self {
Self(a.left + b.left, a.right + b.right)
}
static prefix func -(a: Self) -> Self {
Self(-a.left, -a.right)
}
}
extension Pair: AdditiveGroup, AdditiveProductGroup where Left: AdditiveGroup, Right: AdditiveGroup {}
public protocol AdditiveQuotientGroup: QuotientSet, AdditiveGroup where Base == Mod.Super {
associatedtype Mod: AdditiveSubgroup
}
public extension AdditiveQuotientGroup {
static var zero: Self {
Self(Base.zero)
}
static func + (a: Self, b: Self) -> Self {
Self(a.representative + b.representative)
}
static prefix func - (a: Self) -> Self {
Self(-a.representative)
}
static func isEquivalent(_ a: Base, _ b: Base) -> Bool {
Mod.contains( a - b )
}
static var symbol: String {
"\(Base.symbol)/\(Mod.symbol)"
}
}
public protocol AdditiveGroupHomType: MapType, AdditiveGroup where Domain: AdditiveGroup, Codomain: AdditiveGroup {}
public extension AdditiveGroupHomType {
static var zero: Self {
Self { x in .zero }
}
static func + (f: Self, g: Self) -> Self {
Self { x in f(x) + g(x) }
}
prefix static func - (f: Self) -> Self {
Self { x in -f(x) }
}
static func sum<S: Sequence>(_ elements: S) -> Self where S.Element == Self {
Self { x in
elements.map{ f in f(x) }.sum()
}
}
}
extension Map: AdditiveGroup, AdditiveGroupHomType where Domain: AdditiveGroup, Codomain: AdditiveGroup {}
public typealias AdditiveGroupHom<X: AdditiveGroup, Y: AdditiveGroup> = Map<X, Y>
public typealias AdditiveGroupEnd<X: AdditiveGroup> = AdditiveGroupHom<X, X>
public struct AsGroup<G: AdditiveGroup>: Group {
public let entity: G
public init(_ g: G) {
self.entity = g
}
public var inverse: Self? {
.init(-entity)
}
public static func * (a: Self, b: Self) -> Self {
.init(a.entity + b.entity)
}
public static var identity: Self {
.init(G.zero)
}
public var description: String {
entity.description
}
}
|
cc0-1.0
|
47d8c76f4dfe91932d984f8b4567f0d6
| 23.450617 | 116 | 0.587225 | 3.871945 | false | false | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.