StyleKit.swift 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2019-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. import Foundation
  21. import UIKit
  22. @objc open class StyleKit : NSObject {
  23. // MARK: Cache
  24. private struct Cache {
  25. static var verificationSmall0: UIImage?
  26. static var verificationSmall1: UIImage?
  27. static var verificationSmall2: UIImage?
  28. static var verificationSmall3: UIImage?
  29. static var verificationSmall4: UIImage?
  30. static var verification0: UIImage?
  31. static var verification1: UIImage?
  32. static var verification2: UIImage?
  33. static var verification3: UIImage?
  34. static var verification4: UIImage?
  35. static var verificationBig0: UIImage?
  36. static var verificationBig1: UIImage?
  37. static var verificationBig2: UIImage?
  38. static var verificationBig3: UIImage?
  39. static var verificationBig4: UIImage?
  40. static var check: UIImage?
  41. static var uncheck: UIImage?
  42. static var workIcon: UIImage?
  43. static var houseIcon: UIImage?
  44. static var finger: UIImage?
  45. static var scrollDownButtonIcon: UIImage?
  46. static var checkedBackground: UIImage?
  47. }
  48. // MARK: Cache functions
  49. @objc public class func resetCache() {
  50. Cache.verificationSmall0 = nil
  51. Cache.verificationSmall1 = nil
  52. Cache.verificationSmall2 = nil
  53. Cache.verificationSmall3 = nil
  54. Cache.verificationSmall4 = nil
  55. Cache.verification0 = nil
  56. Cache.verification1 = nil
  57. Cache.verification2 = nil
  58. Cache.verification3 = nil
  59. Cache.verification4 = nil
  60. Cache.verificationBig0 = nil
  61. Cache.verificationBig1 = nil
  62. Cache.verificationBig2 = nil
  63. Cache.verificationBig3 = nil
  64. Cache.verificationBig4 = nil
  65. Cache.check = nil
  66. Cache.uncheck = nil
  67. Cache.workIcon = nil
  68. Cache.houseIcon = nil
  69. Cache.finger = nil
  70. Cache.scrollDownButtonIcon = nil
  71. Cache.checkedBackground = nil
  72. }
  73. /// Reset images that change depending on theme
  74. ///
  75. /// - Note: You will also have to reload the image where you used it
  76. @objc public class func resetThemedCache() {
  77. Cache.scrollDownButtonIcon = nil
  78. Cache.checkedBackground = nil
  79. }
  80. // MARK: Small Generated Images
  81. @objc public dynamic class var verificationSmall0: UIImage {
  82. if Cache.verificationSmall0 != nil {
  83. return Cache.verificationSmall0!
  84. }
  85. let width = StyleKit.scaleSize(32)
  86. let height = StyleKit.scaleSize(8)
  87. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  88. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 0)
  89. Cache.verificationSmall0 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  90. UIGraphicsEndImageContext()
  91. return Cache.verificationSmall0!
  92. }
  93. @objc public dynamic class var verificationSmall1: UIImage {
  94. if Cache.verificationSmall1 != nil {
  95. return Cache.verificationSmall1!
  96. }
  97. let width = StyleKit.scaleSize(32)
  98. let height = StyleKit.scaleSize(8)
  99. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  100. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 1)
  101. Cache.verificationSmall1 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  102. UIGraphicsEndImageContext()
  103. return Cache.verificationSmall1!
  104. }
  105. @objc public dynamic class var verificationSmall2: UIImage {
  106. if Cache.verificationSmall2 != nil {
  107. return Cache.verificationSmall2!
  108. }
  109. let width = StyleKit.scaleSize(32)
  110. let height = StyleKit.scaleSize(8)
  111. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  112. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 2)
  113. Cache.verificationSmall2 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  114. UIGraphicsEndImageContext()
  115. return Cache.verificationSmall2!
  116. }
  117. @objc public dynamic class var verificationSmall3: UIImage {
  118. if Cache.verificationSmall3 != nil {
  119. return Cache.verificationSmall3!
  120. }
  121. let width = StyleKit.scaleSize(32)
  122. let height = StyleKit.scaleSize(8)
  123. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  124. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 3)
  125. Cache.verificationSmall3 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  126. UIGraphicsEndImageContext()
  127. return Cache.verificationSmall3!
  128. }
  129. @objc public dynamic class var verificationSmall4: UIImage {
  130. if Cache.verificationSmall4 != nil {
  131. return Cache.verificationSmall4!
  132. }
  133. let width = StyleKit.scaleSize(32)
  134. let height = StyleKit.scaleSize(8)
  135. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  136. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 4)
  137. Cache.verificationSmall4 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  138. UIGraphicsEndImageContext()
  139. return Cache.verificationSmall4!
  140. }
  141. // MARK: Normal Generated Images
  142. @objc public dynamic class var verification0: UIImage {
  143. if Cache.verification0 != nil {
  144. return Cache.verification0!
  145. }
  146. let width = StyleKit.scaleSize(48)
  147. let height = StyleKit.scaleSize(12)
  148. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  149. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 0)
  150. Cache.verification0 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  151. UIGraphicsEndImageContext()
  152. return Cache.verification0!
  153. }
  154. @objc public dynamic class var verification1: UIImage {
  155. if Cache.verification1 != nil {
  156. return Cache.verification1!
  157. }
  158. let width = StyleKit.scaleSize(48)
  159. let height = StyleKit.scaleSize(12)
  160. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  161. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 1)
  162. Cache.verification1 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  163. UIGraphicsEndImageContext()
  164. return Cache.verification1!
  165. }
  166. @objc public dynamic class var verification2: UIImage {
  167. if Cache.verification2 != nil {
  168. return Cache.verification2!
  169. }
  170. let width = StyleKit.scaleSize(48)
  171. let height = StyleKit.scaleSize(12)
  172. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  173. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 2)
  174. Cache.verification2 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  175. UIGraphicsEndImageContext()
  176. return Cache.verification2!
  177. }
  178. @objc public dynamic class var verification3: UIImage {
  179. if Cache.verification3 != nil {
  180. return Cache.verification3!
  181. }
  182. let width = StyleKit.scaleSize(48)
  183. let height = StyleKit.scaleSize(12)
  184. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  185. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 3)
  186. Cache.verification3 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  187. UIGraphicsEndImageContext()
  188. return Cache.verification3!
  189. }
  190. @objc public dynamic class var verification4: UIImage {
  191. if Cache.verification4 != nil {
  192. return Cache.verification4!
  193. }
  194. let width = StyleKit.scaleSize(48)
  195. let height = StyleKit.scaleSize(12)
  196. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  197. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 4)
  198. Cache.verification4 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  199. UIGraphicsEndImageContext()
  200. return Cache.verification4!
  201. }
  202. // Mark: Icon for scroll to bottom button
  203. @objc public dynamic class var scrollDownButtonIcon: UIImage {
  204. if let cachedIcon = Cache.scrollDownButtonIcon {
  205. return cachedIcon
  206. }
  207. let dimentions = StyleKit.scaleSize(39)
  208. UIGraphicsBeginImageContext(CGSize(width: dimentions, height: dimentions))
  209. StyleKit.drawScrollDownButtonIcon(frame: CGRect(x: 0, y: 0, width: dimentions, height: dimentions))
  210. Cache.scrollDownButtonIcon = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: .zero, resizingMode: .stretch)
  211. return Cache.scrollDownButtonIcon!
  212. }
  213. // MARK: Big Generated Images
  214. @objc public dynamic class var verificationBig0: UIImage {
  215. if Cache.verificationBig0 != nil {
  216. return Cache.verificationBig0!
  217. }
  218. let width = StyleKit.scaleSize(163)
  219. let height = StyleKit.scaleSize(41)
  220. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  221. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 0)
  222. Cache.verificationBig0 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  223. UIGraphicsEndImageContext()
  224. return Cache.verificationBig0!
  225. }
  226. @objc public dynamic class var verificationBig1: UIImage {
  227. if Cache.verificationBig1 != nil {
  228. return Cache.verificationBig1!
  229. }
  230. let width = StyleKit.scaleSize(163)
  231. let height = StyleKit.scaleSize(41)
  232. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  233. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 1)
  234. Cache.verificationBig1 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  235. UIGraphicsEndImageContext()
  236. return Cache.verificationBig1!
  237. }
  238. @objc public dynamic class var verificationBig2: UIImage {
  239. if Cache.verificationBig2 != nil {
  240. return Cache.verificationBig2!
  241. }
  242. let width = StyleKit.scaleSize(163)
  243. let height = StyleKit.scaleSize(41)
  244. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  245. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 2)
  246. Cache.verificationBig2 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  247. UIGraphicsEndImageContext()
  248. return Cache.verificationBig2!
  249. }
  250. @objc public dynamic class var verificationBig3: UIImage {
  251. if Cache.verificationBig3 != nil {
  252. return Cache.verificationBig3!
  253. }
  254. let width = StyleKit.scaleSize(163)
  255. let height = StyleKit.scaleSize(41)
  256. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  257. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 3)
  258. Cache.verificationBig3 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  259. UIGraphicsEndImageContext()
  260. return Cache.verificationBig3!
  261. }
  262. @objc public dynamic class var verificationBig4: UIImage {
  263. if Cache.verificationBig4 != nil {
  264. return Cache.verificationBig4!
  265. }
  266. let width = StyleKit.scaleSize(163)
  267. let height = StyleKit.scaleSize(41)
  268. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  269. StyleKit.drawVerification(frame:CGRect(x: 0, y: 0, width: width, height: height), level: 4)
  270. Cache.verificationBig4 = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  271. UIGraphicsEndImageContext()
  272. return Cache.verificationBig4!
  273. }
  274. @objc public dynamic class var check: UIImage {
  275. if Cache.check != nil {
  276. return Cache.check!
  277. }
  278. let width = StyleKit.scaleSize(22)
  279. let height = StyleKit.scaleSize(22)
  280. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  281. StyleKit.drawCheck(frame:CGRect(x: 0, y: 0, width: width, height: height))
  282. Cache.check = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  283. UIGraphicsEndImageContext()
  284. return Cache.check!
  285. }
  286. @objc public dynamic class var uncheck: UIImage {
  287. if Cache.uncheck != nil {
  288. return Cache.uncheck!
  289. }
  290. let width = StyleKit.scaleSize(22)
  291. let height = StyleKit.scaleSize(22)
  292. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  293. StyleKit.drawUncheck(frame:CGRect(x: 0, y: 0, width: width, height: height))
  294. Cache.uncheck = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  295. UIGraphicsEndImageContext()
  296. return Cache.uncheck!
  297. }
  298. @objc public dynamic class var workIcon: UIImage {
  299. if Cache.workIcon != nil {
  300. return Cache.workIcon!
  301. }
  302. let width = StyleKit.scaleSize(20)
  303. let height = StyleKit.scaleSize(20)
  304. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  305. StyleKit.drawWorkIcon(frame:CGRect(x: 0, y: 0, width: width, height: height), resizing: .aspectFit)
  306. Cache.workIcon = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  307. UIGraphicsEndImageContext()
  308. return Cache.workIcon!
  309. }
  310. @objc public dynamic class var houseIcon: UIImage {
  311. if Cache.houseIcon != nil {
  312. return Cache.houseIcon!
  313. }
  314. let width = StyleKit.scaleSize(20)
  315. let height = StyleKit.scaleSize(20)
  316. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  317. StyleKit.drawHouseIcon(frame:CGRect(x: 0, y: 0, width: width, height: height), resizing: .aspectFit)
  318. Cache.houseIcon = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  319. UIGraphicsEndImageContext()
  320. return Cache.houseIcon!
  321. }
  322. @objc public dynamic class var finger: UIImage {
  323. if Cache.finger != nil {
  324. return Cache.finger!
  325. }
  326. let width = StyleKit.scaleSize(220)
  327. let height = StyleKit.scaleSize(250)
  328. UIGraphicsBeginImageContextWithOptions(CGSize(width: width, height: height), false, 0)
  329. StyleKit.drawFinger(frame:CGRect(x: 0, y: 0, width: width, height: height), resizing: .aspectFit)
  330. Cache.finger = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
  331. UIGraphicsEndImageContext()
  332. return Cache.finger!
  333. }
  334. // Mark: Selection image for image picker
  335. @objc public dynamic class var checkedBackground: UIImage {
  336. if let cachedIcon = Cache.checkedBackground {
  337. return cachedIcon
  338. }
  339. let dimentions = StyleKit.scaleSize(62)
  340. UIGraphicsBeginImageContext(CGSize(width: dimentions, height: dimentions))
  341. StyleKit.drawCheckedBackground(frame: CGRect(x: 0, y: 0, width: dimentions, height: dimentions))
  342. Cache.checkedBackground = UIGraphicsGetImageFromCurrentImageContext()!.resizableImage(withCapInsets: .zero, resizingMode: .stretch)
  343. return Cache.checkedBackground!
  344. }
  345. // MARK: Drawing Methods
  346. public dynamic class func drawVerification(frame: CGRect = CGRect(x: 0, y: 0, width: 32, height: 8), level: Int) {
  347. //// General Declarations
  348. // This non-generic function dramatically improves compilation times of complex expressions.
  349. func fastFloor(_ x: CGFloat) -> CGFloat { return floor(x) }
  350. //// Subframes
  351. let group: CGRect = CGRect(x: frame.minX, y: frame.minY, width: frame.width, height: frame.height)
  352. var width = fastFloor(group.width * 0.25000 + 0.5) - fastFloor(group.width * 0.00000 + 0.5)
  353. var height = fastFloor(group.height * 1.00000 + 0.5) - fastFloor(group.height * 0.00000 + 0.5)
  354. if height > width {
  355. height = width
  356. } else {
  357. width = height
  358. }
  359. let red: UIColor = Colors.red()
  360. let orange: UIColor = Colors.orange()
  361. let green: UIColor = Colors.verificationGreen()
  362. let gray: UIColor = Colors.gray()
  363. let blue: UIColor = Colors.workBlue()
  364. //// Group
  365. //// Oval Drawing
  366. let ovalPath = UIBezierPath(ovalIn: CGRect(x: group.minX + fastFloor(group.width * 0.00000 + 0.5), y: group.minY + fastFloor(group.height * 0.00000 + 0.5), width: width, height: height))
  367. switch level {
  368. case 0:
  369. red.setFill()
  370. break
  371. case 1:
  372. orange.setFill()
  373. break
  374. case 2:
  375. green.setFill()
  376. break
  377. case 3, 4:
  378. blue.setFill()
  379. break
  380. default:
  381. gray.setFill()
  382. }
  383. ovalPath.fill()
  384. //// Oval 2 Drawing
  385. let oval2Path = UIBezierPath(ovalIn: CGRect(x: group.minX + fastFloor(group.width * 0.37500 + 0.5), y: group.minY + fastFloor(group.height * 0.00000 + 0.5), width: width, height: height))
  386. switch level {
  387. case 1:
  388. orange.setFill()
  389. break
  390. case 2:
  391. green.setFill()
  392. break
  393. case 3, 4:
  394. blue.setFill()
  395. break
  396. default:
  397. gray.setFill()
  398. }
  399. oval2Path.fill()
  400. //// Oval 3 Drawing
  401. let oval3Path = UIBezierPath(ovalIn: CGRect(x: group.minX + fastFloor(group.width * 0.75000 + 0.5), y: group.minY + fastFloor(group.height * 0.00000 + 0.5), width: width, height: height))
  402. switch level {
  403. case 2:
  404. green.setFill()
  405. break
  406. case 4:
  407. blue.setFill()
  408. break
  409. default:
  410. gray.setFill()
  411. }
  412. oval3Path.fill()
  413. }
  414. @objc dynamic public class func drawCheck(frame: CGRect = CGRect(x: 0, y: 0, width: 22, height: 22)) {
  415. //// General Declarations
  416. // This non-generic function dramatically improves compilation times of complex expressions.
  417. func fastFloor(_ x: CGFloat) -> CGFloat { return floor(x) }
  418. //// Color Declarations
  419. let color2 = Colors.gray() as UIColor
  420. let color3 = UIColor.white
  421. let color4 = Colors.main() as UIColor
  422. //// Subframes
  423. let group: CGRect = CGRect(x: frame.minX + 1, y: frame.minY + 1, width: frame.width - 2, height: frame.height - 2)
  424. //// Group
  425. //// Oval 2 Drawing
  426. let oval2Path = UIBezierPath(ovalIn: CGRect(x: group.minX + fastFloor(group.width * 0.05000 + 0.5), y: group.minY + fastFloor(group.height * 0.05000 + 0.5), width: fastFloor(group.width * 0.95000 + 0.5) - fastFloor(group.width * 0.05000 + 0.5), height: fastFloor(group.height * 0.95000 + 0.5) - fastFloor(group.height * 0.05000 + 0.5)))
  427. color4.setFill()
  428. oval2Path.fill()
  429. oval2Path.lineWidth = 1
  430. //// Oval Drawing
  431. let ovalPath = UIBezierPath(ovalIn: CGRect(x: group.minX + fastFloor(group.width * 0.00000 + 0.5), y: group.minY + fastFloor(group.height * 0.00000 + 0.5), width: fastFloor(group.width * 1.00000 + 0.5) - fastFloor(group.width * 0.00000 + 0.5), height: fastFloor(group.height * 1.00000 + 0.5) - fastFloor(group.height * 0.00000 + 0.5)))
  432. color2.setStroke()
  433. ovalPath.lineWidth = 1
  434. ovalPath.stroke()
  435. //// Bezier Drawing
  436. let bezierPath = UIBezierPath()
  437. bezierPath.move(to: CGPoint(x: frame.minX + 0.26607 * frame.width, y: frame.minY + 0.46120 * frame.height))
  438. bezierPath.addCurve(to: CGPoint(x: frame.minX + 0.44789 * frame.width, y: frame.minY + 0.64302 * frame.height), controlPoint1: CGPoint(x: frame.minX + 0.44789 * frame.width, y: frame.minY + 0.64302 * frame.height), controlPoint2: CGPoint(x: frame.minX + 0.44789 * frame.width, y: frame.minY + 0.64302 * frame.height))
  439. bezierPath.addLine(to: CGPoint(x: frame.minX + 0.41575 * frame.width, y: frame.minY + 0.64302 * frame.height))
  440. bezierPath.addLine(to: CGPoint(x: frame.minX + 0.73393 * frame.width, y: frame.minY + 0.32484 * frame.height))
  441. bezierPath.addCurve(to: CGPoint(x: frame.minX + 0.76607 * frame.width, y: frame.minY + 0.32484 * frame.height), controlPoint1: CGPoint(x: frame.minX + 0.74280 * frame.width, y: frame.minY + 0.31596 * frame.height), controlPoint2: CGPoint(x: frame.minX + 0.75720 * frame.width, y: frame.minY + 0.31596 * frame.height))
  442. bezierPath.addCurve(to: CGPoint(x: frame.minX + 0.76607 * frame.width, y: frame.minY + 0.35698 * frame.height), controlPoint1: CGPoint(x: frame.minX + 0.77495 * frame.width, y: frame.minY + 0.33371 * frame.height), controlPoint2: CGPoint(x: frame.minX + 0.77495 * frame.width, y: frame.minY + 0.34810 * frame.height))
  443. bezierPath.addLine(to: CGPoint(x: frame.minX + 0.44789 * frame.width, y: frame.minY + 0.67516 * frame.height))
  444. bezierPath.addCurve(to: CGPoint(x: frame.minX + 0.41575 * frame.width, y: frame.minY + 0.67516 * frame.height), controlPoint1: CGPoint(x: frame.minX + 0.43901 * frame.width, y: frame.minY + 0.68404 * frame.height), controlPoint2: CGPoint(x: frame.minX + 0.42462 * frame.width, y: frame.minY + 0.68404 * frame.height))
  445. bezierPath.addCurve(to: CGPoint(x: frame.minX + 0.23393 * frame.width, y: frame.minY + 0.49334 * frame.height), controlPoint1: CGPoint(x: frame.minX + 0.41575 * frame.width, y: frame.minY + 0.67516 * frame.height), controlPoint2: CGPoint(x: frame.minX + 0.41575 * frame.width, y: frame.minY + 0.67516 * frame.height))
  446. bezierPath.addCurve(to: CGPoint(x: frame.minX + 0.23393 * frame.width, y: frame.minY + 0.46120 * frame.height), controlPoint1: CGPoint(x: frame.minX + 0.22505 * frame.width, y: frame.minY + 0.48447 * frame.height), controlPoint2: CGPoint(x: frame.minX + 0.22505 * frame.width, y: frame.minY + 0.47008 * frame.height))
  447. bezierPath.addCurve(to: CGPoint(x: frame.minX + 0.26607 * frame.width, y: frame.minY + 0.46120 * frame.height), controlPoint1: CGPoint(x: frame.minX + 0.24280 * frame.width, y: frame.minY + 0.45233 * frame.height), controlPoint2: CGPoint(x: frame.minX + 0.25720 * frame.width, y: frame.minY + 0.45233 * frame.height))
  448. bezierPath.close()
  449. color3.setFill()
  450. bezierPath.fill()
  451. }
  452. @objc dynamic public class func drawUncheck(frame: CGRect = CGRect(x: 0, y: 0, width: 22, height: 22)) {
  453. //// Color Declarations
  454. let color = Colors.gray() as UIColor
  455. //// Oval Drawing
  456. let ovalPath = UIBezierPath(ovalIn: CGRect(x: frame.minX + 1, y: frame.minY + 1, width: frame.width - 2, height: frame.height - 2))
  457. color.setStroke()
  458. ovalPath.lineWidth = 1
  459. ovalPath.stroke()
  460. }
  461. @objc dynamic public class func drawWorkIcon(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 20, height: 20), resizing: ResizingBehavior = .aspectFit) {
  462. //// General Declarations
  463. let context = UIGraphicsGetCurrentContext()!
  464. //// Resize to Target Frame
  465. context.saveGState()
  466. let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 20, height: 20), target: targetFrame)
  467. context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
  468. context.scaleBy(x: resizedFrame.width / 20, y: resizedFrame.height / 20)
  469. //// Color Declarations
  470. let fillColor = UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
  471. let fillColor2 = Colors.workBlue() as UIColor
  472. //// work_app_icon_mit_rand Group
  473. //// Path Drawing
  474. let pathPath = UIBezierPath()
  475. pathPath.move(to: CGPoint(x: 10, y: 0))
  476. pathPath.addLine(to: CGPoint(x: 10, y: 0))
  477. pathPath.addCurve(to: CGPoint(x: 20, y: 10), controlPoint1: CGPoint(x: 15.52, y: 0), controlPoint2: CGPoint(x: 20, y: 4.48))
  478. pathPath.addCurve(to: CGPoint(x: 10, y: 20), controlPoint1: CGPoint(x: 20, y: 15.52), controlPoint2: CGPoint(x: 15.52, y: 20))
  479. pathPath.addCurve(to: CGPoint(x: 0, y: 10), controlPoint1: CGPoint(x: 4.48, y: 20), controlPoint2: CGPoint(x: 0, y: 15.52))
  480. pathPath.addLine(to: CGPoint(x: 0, y: 10))
  481. pathPath.addCurve(to: CGPoint(x: 10, y: 0), controlPoint1: CGPoint(x: 0, y: 4.48), controlPoint2: CGPoint(x: 4.48, y: 0))
  482. pathPath.close()
  483. pathPath.move(to: CGPoint(x: 10, y: 0.91))
  484. pathPath.addLine(to: CGPoint(x: 10, y: 0.91))
  485. pathPath.addCurve(to: CGPoint(x: 0.91, y: 10), controlPoint1: CGPoint(x: 4.98, y: 0.91), controlPoint2: CGPoint(x: 0.91, y: 4.98))
  486. pathPath.addCurve(to: CGPoint(x: 10, y: 19.09), controlPoint1: CGPoint(x: 0.91, y: 15.02), controlPoint2: CGPoint(x: 4.98, y: 19.09))
  487. pathPath.addCurve(to: CGPoint(x: 19.09, y: 10), controlPoint1: CGPoint(x: 15.02, y: 19.09), controlPoint2: CGPoint(x: 19.09, y: 15.02))
  488. pathPath.addLine(to: CGPoint(x: 19.09, y: 10))
  489. pathPath.addCurve(to: CGPoint(x: 10, y: 0.91), controlPoint1: CGPoint(x: 19.09, y: 4.98), controlPoint2: CGPoint(x: 15.02, y: 0.91))
  490. pathPath.close()
  491. fillColor.setFill()
  492. pathPath.fill()
  493. //// Shape 2 Drawing
  494. let shape2Path = UIBezierPath()
  495. shape2Path.move(to: CGPoint(x: 10, y: 0.91))
  496. shape2Path.addLine(to: CGPoint(x: 10, y: 19.09))
  497. shape2Path.addLine(to: CGPoint(x: 10, y: 0.91))
  498. shape2Path.close()
  499. shape2Path.move(to: CGPoint(x: 11.36, y: 5.45))
  500. shape2Path.addLine(to: CGPoint(x: 8.64, y: 5.45))
  501. shape2Path.addLine(to: CGPoint(x: 8.64, y: 5.45))
  502. shape2Path.addCurve(to: CGPoint(x: 7.73, y: 6.36), controlPoint1: CGPoint(x: 8.13, y: 5.45), controlPoint2: CGPoint(x: 7.73, y: 5.86))
  503. shape2Path.addLine(to: CGPoint(x: 7.73, y: 7.27))
  504. shape2Path.addLine(to: CGPoint(x: 6.36, y: 7.27))
  505. shape2Path.addLine(to: CGPoint(x: 6.36, y: 7.27))
  506. shape2Path.addCurve(to: CGPoint(x: 5.45, y: 8.18), controlPoint1: CGPoint(x: 5.86, y: 7.27), controlPoint2: CGPoint(x: 5.45, y: 7.68))
  507. shape2Path.addLine(to: CGPoint(x: 5.45, y: 12.73))
  508. shape2Path.addLine(to: CGPoint(x: 5.45, y: 12.73))
  509. shape2Path.addCurve(to: CGPoint(x: 6.36, y: 13.64), controlPoint1: CGPoint(x: 5.45, y: 13.23), controlPoint2: CGPoint(x: 5.86, y: 13.64))
  510. shape2Path.addLine(to: CGPoint(x: 13.64, y: 13.64))
  511. shape2Path.addLine(to: CGPoint(x: 13.64, y: 13.64))
  512. shape2Path.addCurve(to: CGPoint(x: 14.55, y: 12.73), controlPoint1: CGPoint(x: 14.14, y: 13.64), controlPoint2: CGPoint(x: 14.55, y: 13.23))
  513. shape2Path.addLine(to: CGPoint(x: 14.55, y: 8.18))
  514. shape2Path.addLine(to: CGPoint(x: 14.55, y: 8.18))
  515. shape2Path.addCurve(to: CGPoint(x: 13.64, y: 7.27), controlPoint1: CGPoint(x: 14.55, y: 7.68), controlPoint2: CGPoint(x: 14.14, y: 7.27))
  516. shape2Path.addLine(to: CGPoint(x: 12.27, y: 7.27))
  517. shape2Path.addLine(to: CGPoint(x: 12.27, y: 6.36))
  518. shape2Path.addLine(to: CGPoint(x: 12.27, y: 6.36))
  519. shape2Path.addCurve(to: CGPoint(x: 11.36, y: 5.45), controlPoint1: CGPoint(x: 12.27, y: 5.86), controlPoint2: CGPoint(x: 11.87, y: 5.45))
  520. shape2Path.close()
  521. shape2Path.move(to: CGPoint(x: 11.36, y: 6.36))
  522. shape2Path.addLine(to: CGPoint(x: 11.36, y: 7.27))
  523. shape2Path.addLine(to: CGPoint(x: 8.64, y: 7.27))
  524. shape2Path.addLine(to: CGPoint(x: 8.64, y: 6.36))
  525. shape2Path.addLine(to: CGPoint(x: 11.36, y: 6.36))
  526. shape2Path.close()
  527. shape2Path.usesEvenOddFillRule = true
  528. fillColor.setFill()
  529. shape2Path.fill()
  530. //// Shape Drawing
  531. let shapePath = UIBezierPath()
  532. shapePath.move(to: CGPoint(x: 10, y: 0.91))
  533. shapePath.addLine(to: CGPoint(x: 10, y: 0.91))
  534. shapePath.addCurve(to: CGPoint(x: 19.09, y: 10), controlPoint1: CGPoint(x: 15.02, y: 0.91), controlPoint2: CGPoint(x: 19.09, y: 4.98))
  535. shapePath.addCurve(to: CGPoint(x: 10, y: 19.09), controlPoint1: CGPoint(x: 19.09, y: 15.02), controlPoint2: CGPoint(x: 15.02, y: 19.09))
  536. shapePath.addCurve(to: CGPoint(x: 0.91, y: 10), controlPoint1: CGPoint(x: 4.98, y: 19.09), controlPoint2: CGPoint(x: 0.91, y: 15.02))
  537. shapePath.addLine(to: CGPoint(x: 0.91, y: 10))
  538. shapePath.addCurve(to: CGPoint(x: 10, y: 0.91), controlPoint1: CGPoint(x: 0.91, y: 4.98), controlPoint2: CGPoint(x: 4.98, y: 0.91))
  539. shapePath.close()
  540. shapePath.move(to: CGPoint(x: 11.36, y: 5.45))
  541. shapePath.addLine(to: CGPoint(x: 8.64, y: 5.45))
  542. shapePath.addLine(to: CGPoint(x: 8.64, y: 5.45))
  543. shapePath.addCurve(to: CGPoint(x: 7.73, y: 6.36), controlPoint1: CGPoint(x: 8.13, y: 5.45), controlPoint2: CGPoint(x: 7.73, y: 5.86))
  544. shapePath.addLine(to: CGPoint(x: 7.73, y: 7.27))
  545. shapePath.addLine(to: CGPoint(x: 6.36, y: 7.27))
  546. shapePath.addLine(to: CGPoint(x: 6.36, y: 7.27))
  547. shapePath.addCurve(to: CGPoint(x: 5.45, y: 8.18), controlPoint1: CGPoint(x: 5.86, y: 7.27), controlPoint2: CGPoint(x: 5.45, y: 7.68))
  548. shapePath.addLine(to: CGPoint(x: 5.45, y: 12.73))
  549. shapePath.addLine(to: CGPoint(x: 5.45, y: 12.73))
  550. shapePath.addCurve(to: CGPoint(x: 6.36, y: 13.64), controlPoint1: CGPoint(x: 5.45, y: 13.23), controlPoint2: CGPoint(x: 5.86, y: 13.64))
  551. shapePath.addLine(to: CGPoint(x: 13.64, y: 13.64))
  552. shapePath.addLine(to: CGPoint(x: 13.64, y: 13.64))
  553. shapePath.addCurve(to: CGPoint(x: 14.55, y: 12.73), controlPoint1: CGPoint(x: 14.14, y: 13.64), controlPoint2: CGPoint(x: 14.55, y: 13.23))
  554. shapePath.addLine(to: CGPoint(x: 14.55, y: 8.18))
  555. shapePath.addLine(to: CGPoint(x: 14.55, y: 8.18))
  556. shapePath.addCurve(to: CGPoint(x: 13.64, y: 7.27), controlPoint1: CGPoint(x: 14.55, y: 7.68), controlPoint2: CGPoint(x: 14.14, y: 7.27))
  557. shapePath.addLine(to: CGPoint(x: 12.27, y: 7.27))
  558. shapePath.addLine(to: CGPoint(x: 12.27, y: 6.36))
  559. shapePath.addLine(to: CGPoint(x: 12.27, y: 6.36))
  560. shapePath.addCurve(to: CGPoint(x: 11.36, y: 5.45), controlPoint1: CGPoint(x: 12.27, y: 5.86), controlPoint2: CGPoint(x: 11.87, y: 5.45))
  561. shapePath.close()
  562. shapePath.move(to: CGPoint(x: 11.36, y: 6.36))
  563. shapePath.addLine(to: CGPoint(x: 11.36, y: 7.27))
  564. shapePath.addLine(to: CGPoint(x: 8.64, y: 7.27))
  565. shapePath.addLine(to: CGPoint(x: 8.64, y: 6.36))
  566. shapePath.addLine(to: CGPoint(x: 11.36, y: 6.36))
  567. shapePath.close()
  568. shapePath.usesEvenOddFillRule = true
  569. fillColor2.setFill()
  570. shapePath.fill()
  571. context.restoreGState()
  572. }
  573. @objc dynamic public class func drawHouseIcon(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 20, height: 20), resizing: ResizingBehavior = .aspectFit) {
  574. //// General Declarations
  575. let context = UIGraphicsGetCurrentContext()!
  576. //// Resize to Target Frame
  577. context.saveGState()
  578. let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 20, height: 20), target: targetFrame)
  579. context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
  580. context.scaleBy(x: resizedFrame.width / 20, y: resizedFrame.height / 20)
  581. //// Color Declarations
  582. let fillColor = UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
  583. let fillColor2 = Colors.green() as UIColor
  584. //// consumer_app_icon_mit_rand Group
  585. //// Path Drawing
  586. let pathPath = UIBezierPath()
  587. pathPath.move(to: CGPoint(x: 10, y: 0))
  588. pathPath.addLine(to: CGPoint(x: 10, y: 0))
  589. pathPath.addCurve(to: CGPoint(x: 20, y: 10), controlPoint1: CGPoint(x: 15.52, y: 0), controlPoint2: CGPoint(x: 20, y: 4.48))
  590. pathPath.addCurve(to: CGPoint(x: 10, y: 20), controlPoint1: CGPoint(x: 20, y: 15.52), controlPoint2: CGPoint(x: 15.52, y: 20))
  591. pathPath.addCurve(to: CGPoint(x: 0, y: 10), controlPoint1: CGPoint(x: 4.48, y: 20), controlPoint2: CGPoint(x: 0, y: 15.52))
  592. pathPath.addLine(to: CGPoint(x: 0, y: 10))
  593. pathPath.addCurve(to: CGPoint(x: 10, y: 0), controlPoint1: CGPoint(x: 0, y: 4.48), controlPoint2: CGPoint(x: 4.48, y: 0))
  594. pathPath.close()
  595. pathPath.move(to: CGPoint(x: 10, y: 0.91))
  596. pathPath.addLine(to: CGPoint(x: 10, y: 0.91))
  597. pathPath.addCurve(to: CGPoint(x: 0.91, y: 10), controlPoint1: CGPoint(x: 4.98, y: 0.91), controlPoint2: CGPoint(x: 0.91, y: 4.98))
  598. pathPath.addCurve(to: CGPoint(x: 10, y: 19.09), controlPoint1: CGPoint(x: 0.91, y: 15.02), controlPoint2: CGPoint(x: 4.98, y: 19.09))
  599. pathPath.addCurve(to: CGPoint(x: 19.09, y: 10), controlPoint1: CGPoint(x: 15.02, y: 19.09), controlPoint2: CGPoint(x: 19.09, y: 15.02))
  600. pathPath.addLine(to: CGPoint(x: 19.09, y: 10))
  601. pathPath.addCurve(to: CGPoint(x: 10, y: 0.91), controlPoint1: CGPoint(x: 19.09, y: 4.98), controlPoint2: CGPoint(x: 15.02, y: 0.91))
  602. pathPath.close()
  603. fillColor.setFill()
  604. pathPath.fill()
  605. //// Shape Drawing
  606. let shapePath = UIBezierPath()
  607. shapePath.move(to: CGPoint(x: 10, y: 0.91))
  608. shapePath.addLine(to: CGPoint(x: 10, y: 0.91))
  609. shapePath.addCurve(to: CGPoint(x: 19.09, y: 10), controlPoint1: CGPoint(x: 15.02, y: 0.91), controlPoint2: CGPoint(x: 19.09, y: 4.98))
  610. shapePath.addCurve(to: CGPoint(x: 10, y: 19.09), controlPoint1: CGPoint(x: 19.09, y: 15.02), controlPoint2: CGPoint(x: 15.02, y: 19.09))
  611. shapePath.addCurve(to: CGPoint(x: 0.91, y: 10), controlPoint1: CGPoint(x: 4.98, y: 19.09), controlPoint2: CGPoint(x: 0.91, y: 15.02))
  612. shapePath.addLine(to: CGPoint(x: 0.91, y: 10))
  613. shapePath.addCurve(to: CGPoint(x: 10, y: 0.91), controlPoint1: CGPoint(x: 0.91, y: 4.98), controlPoint2: CGPoint(x: 4.98, y: 0.91))
  614. shapePath.close()
  615. shapePath.move(to: CGPoint(x: 10, y: 7.27))
  616. shapePath.addLine(to: CGPoint(x: 6.36, y: 10.91))
  617. shapePath.addLine(to: CGPoint(x: 6.36, y: 14.09))
  618. shapePath.addLine(to: CGPoint(x: 6.36, y: 14.09))
  619. shapePath.addCurve(to: CGPoint(x: 6.82, y: 14.55), controlPoint1: CGPoint(x: 6.36, y: 14.34), controlPoint2: CGPoint(x: 6.57, y: 14.55))
  620. shapePath.addLine(to: CGPoint(x: 13.18, y: 14.55))
  621. shapePath.addLine(to: CGPoint(x: 13.18, y: 14.55))
  622. shapePath.addCurve(to: CGPoint(x: 13.64, y: 14.09), controlPoint1: CGPoint(x: 13.43, y: 14.55), controlPoint2: CGPoint(x: 13.64, y: 14.34))
  623. shapePath.addLine(to: CGPoint(x: 13.64, y: 10.91))
  624. shapePath.addLine(to: CGPoint(x: 10, y: 7.27))
  625. shapePath.close()
  626. shapePath.move(to: CGPoint(x: 10.32, y: 5.02))
  627. shapePath.addLine(to: CGPoint(x: 10.32, y: 5.02))
  628. shapePath.addCurve(to: CGPoint(x: 9.68, y: 5.02), controlPoint1: CGPoint(x: 10.14, y: 4.84), controlPoint2: CGPoint(x: 9.86, y: 4.84))
  629. shapePath.addLine(to: CGPoint(x: 4.86, y: 9.84))
  630. shapePath.addLine(to: CGPoint(x: 5.5, y: 10.48))
  631. shapePath.addLine(to: CGPoint(x: 10, y: 5.99))
  632. shapePath.addLine(to: CGPoint(x: 14.5, y: 10.49))
  633. shapePath.addLine(to: CGPoint(x: 15.14, y: 9.84))
  634. shapePath.addLine(to: CGPoint(x: 10.32, y: 5.02))
  635. shapePath.close()
  636. shapePath.usesEvenOddFillRule = true
  637. fillColor2.setFill()
  638. shapePath.fill()
  639. //// Shape 2 Drawing
  640. let shape2Path = UIBezierPath()
  641. shape2Path.move(to: CGPoint(x: 0.91, y: 10))
  642. shape2Path.addLine(to: CGPoint(x: 0.91, y: 10))
  643. shape2Path.addCurve(to: CGPoint(x: 0.91, y: 10), controlPoint1: CGPoint(x: 0.91, y: 4.98), controlPoint2: CGPoint(x: 0.91, y: 10))
  644. shape2Path.close()
  645. shape2Path.move(to: CGPoint(x: 10, y: 7.27))
  646. shape2Path.addLine(to: CGPoint(x: 6.36, y: 10.91))
  647. shape2Path.addLine(to: CGPoint(x: 6.36, y: 14.09))
  648. shape2Path.addLine(to: CGPoint(x: 6.36, y: 14.09))
  649. shape2Path.addCurve(to: CGPoint(x: 6.82, y: 14.55), controlPoint1: CGPoint(x: 6.36, y: 14.34), controlPoint2: CGPoint(x: 6.57, y: 14.55))
  650. shape2Path.addLine(to: CGPoint(x: 13.18, y: 14.55))
  651. shape2Path.addLine(to: CGPoint(x: 13.18, y: 14.55))
  652. shape2Path.addCurve(to: CGPoint(x: 13.64, y: 14.09), controlPoint1: CGPoint(x: 13.43, y: 14.55), controlPoint2: CGPoint(x: 13.64, y: 14.34))
  653. shape2Path.addLine(to: CGPoint(x: 13.64, y: 10.91))
  654. shape2Path.addLine(to: CGPoint(x: 10, y: 7.27))
  655. shape2Path.close()
  656. shape2Path.move(to: CGPoint(x: 10.32, y: 5.02))
  657. shape2Path.addLine(to: CGPoint(x: 10.32, y: 5.02))
  658. shape2Path.addCurve(to: CGPoint(x: 9.68, y: 5.02), controlPoint1: CGPoint(x: 10.14, y: 4.84), controlPoint2: CGPoint(x: 9.86, y: 4.84))
  659. shape2Path.addLine(to: CGPoint(x: 4.86, y: 9.84))
  660. shape2Path.addLine(to: CGPoint(x: 5.5, y: 10.48))
  661. shape2Path.addLine(to: CGPoint(x: 10, y: 5.99))
  662. shape2Path.addLine(to: CGPoint(x: 14.5, y: 10.49))
  663. shape2Path.addLine(to: CGPoint(x: 15.14, y: 9.84))
  664. shape2Path.addLine(to: CGPoint(x: 10.32, y: 5.02))
  665. shape2Path.close()
  666. shape2Path.usesEvenOddFillRule = true
  667. fillColor.setFill()
  668. shape2Path.fill()
  669. context.restoreGState()
  670. }
  671. @objc dynamic public class func drawFinger(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 220, height: 250), resizing: ResizingBehavior = .aspectFit) {
  672. //// General Declarations
  673. let context = UIGraphicsGetCurrentContext()!
  674. //// Resize to Target Frame
  675. context.saveGState()
  676. let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 220, height: 250), target: targetFrame)
  677. context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
  678. context.scaleBy(x: resizedFrame.width / 220, y: resizedFrame.height / 250)
  679. //// Color Declarations
  680. let fillColor = UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
  681. let fillColor5 = Colors.mainThemeDark() as UIColor
  682. let fillColor6 = UIColor(red: 0.847, green: 0.847, blue: 0.847, alpha: 1.000)
  683. //// finger_with_circles Group
  684. //// Bezier Drawing
  685. let bezierPath = UIBezierPath()
  686. bezierPath.move(to: CGPoint(x: 109.96, y: 53.34))
  687. bezierPath.addLine(to: CGPoint(x: 109.98, y: 53.34))
  688. bezierPath.addCurve(to: CGPoint(x: 166.5, y: 110.05), controlPoint1: CGPoint(x: 141.19, y: 53.34), controlPoint2: CGPoint(x: 166.5, y: 78.73))
  689. bezierPath.addCurve(to: CGPoint(x: 109.98, y: 166.76), controlPoint1: CGPoint(x: 166.5, y: 141.37), controlPoint2: CGPoint(x: 141.19, y: 166.76))
  690. bezierPath.addCurve(to: CGPoint(x: 53.47, y: 110.05), controlPoint1: CGPoint(x: 78.77, y: 166.76), controlPoint2: CGPoint(x: 53.47, y: 141.37))
  691. bezierPath.addCurve(to: CGPoint(x: 95.36, y: 55.27), controlPoint1: CGPoint(x: 53.47, y: 84.39), controlPoint2: CGPoint(x: 70.65, y: 61.92))
  692. bezierPath.addLine(to: CGPoint(x: 95.36, y: 55.27))
  693. bezierPath.addCurve(to: CGPoint(x: 109.98, y: 53.34), controlPoint1: CGPoint(x: 100.13, y: 53.99), controlPoint2: CGPoint(x: 105.04, y: 53.34))
  694. bezierPath.move(to: CGPoint(x: 109.96, y: 46.68))
  695. bezierPath.addLine(to: CGPoint(x: 109.96, y: 46.68))
  696. bezierPath.addLine(to: CGPoint(x: 109.91, y: 46.68))
  697. bezierPath.addCurve(to: CGPoint(x: 46.8, y: 110.01), controlPoint1: CGPoint(x: 75.06, y: 46.68), controlPoint2: CGPoint(x: 46.8, y: 75.03))
  698. bezierPath.addCurve(to: CGPoint(x: 109.91, y: 173.35), controlPoint1: CGPoint(x: 46.8, y: 145), controlPoint2: CGPoint(x: 75.06, y: 173.35))
  699. bezierPath.addCurve(to: CGPoint(x: 173.03, y: 110.01), controlPoint1: CGPoint(x: 144.77, y: 173.35), controlPoint2: CGPoint(x: 173.03, y: 145))
  700. bezierPath.addCurve(to: CGPoint(x: 170.88, y: 93.62), controlPoint1: CGPoint(x: 173.03, y: 104.48), controlPoint2: CGPoint(x: 172.31, y: 98.97))
  701. bezierPath.addLine(to: CGPoint(x: 170.91, y: 93.73))
  702. bezierPath.addCurve(to: CGPoint(x: 109.8, y: 46.68), controlPoint1: CGPoint(x: 163.5, y: 65.98), controlPoint2: CGPoint(x: 138.44, y: 46.68))
  703. bezierPath.addLine(to: CGPoint(x: 109.96, y: 46.68))
  704. bezierPath.close()
  705. fillColor5.setFill()
  706. bezierPath.fill()
  707. //// Bezier 2 Drawing
  708. context.saveGState()
  709. context.setAlpha(0.4)
  710. let bezier2Path = UIBezierPath()
  711. bezier2Path.move(to: CGPoint(x: 109.98, y: 30))
  712. bezier2Path.addLine(to: CGPoint(x: 110.01, y: 30))
  713. bezier2Path.addCurve(to: CGPoint(x: 189.79, y: 110.07), controlPoint1: CGPoint(x: 154.07, y: 30), controlPoint2: CGPoint(x: 189.79, y: 65.85))
  714. bezier2Path.addCurve(to: CGPoint(x: 110.01, y: 190.13), controlPoint1: CGPoint(x: 189.79, y: 154.28), controlPoint2: CGPoint(x: 154.07, y: 190.13))
  715. bezier2Path.addCurve(to: CGPoint(x: 30.23, y: 110.07), controlPoint1: CGPoint(x: 65.95, y: 190.13), controlPoint2: CGPoint(x: 30.23, y: 154.28))
  716. bezier2Path.addCurve(to: CGPoint(x: 89.36, y: 32.73), controlPoint1: CGPoint(x: 30.23, y: 73.83), controlPoint2: CGPoint(x: 54.48, y: 42.11))
  717. bezier2Path.addLine(to: CGPoint(x: 89.37, y: 32.73))
  718. bezier2Path.addCurve(to: CGPoint(x: 110.01, y: 30), controlPoint1: CGPoint(x: 96.1, y: 30.92), controlPoint2: CGPoint(x: 103.04, y: 30))
  719. bezier2Path.move(to: CGPoint(x: 109.98, y: 23.34))
  720. bezier2Path.addLine(to: CGPoint(x: 109.98, y: 30))
  721. bezier2Path.addLine(to: CGPoint(x: 109.98, y: 23.34))
  722. bezier2Path.addLine(to: CGPoint(x: 109.91, y: 23.34))
  723. bezier2Path.addCurve(to: CGPoint(x: 23.53, y: 110.02), controlPoint1: CGPoint(x: 62.2, y: 23.34), controlPoint2: CGPoint(x: 23.53, y: 62.15))
  724. bezier2Path.addCurve(to: CGPoint(x: 109.91, y: 196.7), controlPoint1: CGPoint(x: 23.53, y: 157.89), controlPoint2: CGPoint(x: 62.2, y: 196.7))
  725. bezier2Path.addCurve(to: CGPoint(x: 196.29, y: 110.02), controlPoint1: CGPoint(x: 157.61, y: 196.7), controlPoint2: CGPoint(x: 196.29, y: 157.89))
  726. bezier2Path.addCurve(to: CGPoint(x: 193.34, y: 87.58), controlPoint1: CGPoint(x: 196.29, y: 102.44), controlPoint2: CGPoint(x: 195.3, y: 94.9))
  727. bezier2Path.addLine(to: CGPoint(x: 193.39, y: 87.75))
  728. bezier2Path.addCurve(to: CGPoint(x: 109.73, y: 23.34), controlPoint1: CGPoint(x: 183.24, y: 49.76), controlPoint2: CGPoint(x: 148.93, y: 23.34))
  729. bezier2Path.addLine(to: CGPoint(x: 109.98, y: 23.34))
  730. bezier2Path.close()
  731. fillColor5.setFill()
  732. bezier2Path.fill()
  733. context.restoreGState()
  734. //// Bezier 3 Drawing
  735. context.saveGState()
  736. context.setAlpha(0.1)
  737. let bezier3Path = UIBezierPath()
  738. bezier3Path.move(to: CGPoint(x: 109.99, y: 6.67))
  739. bezier3Path.addLine(to: CGPoint(x: 110.03, y: 6.67))
  740. bezier3Path.addCurve(to: CGPoint(x: 213.09, y: 110.08), controlPoint1: CGPoint(x: 166.95, y: 6.67), controlPoint2: CGPoint(x: 213.09, y: 52.97))
  741. bezier3Path.addCurve(to: CGPoint(x: 110.03, y: 213.5), controlPoint1: CGPoint(x: 213.09, y: 167.2), controlPoint2: CGPoint(x: 166.95, y: 213.5))
  742. bezier3Path.addCurve(to: CGPoint(x: 6.98, y: 110.08), controlPoint1: CGPoint(x: 53.12, y: 213.5), controlPoint2: CGPoint(x: 6.98, y: 167.2))
  743. bezier3Path.addCurve(to: CGPoint(x: 83.36, y: 10.19), controlPoint1: CGPoint(x: 6.98, y: 63.28), controlPoint2: CGPoint(x: 38.31, y: 22.3))
  744. bezier3Path.addLine(to: CGPoint(x: 83.37, y: 10.19))
  745. bezier3Path.addCurve(to: CGPoint(x: 110.03, y: 6.67), controlPoint1: CGPoint(x: 92.06, y: 7.85), controlPoint2: CGPoint(x: 101.03, y: 6.67))
  746. bezier3Path.move(to: CGPoint(x: 110, y: -0))
  747. bezier3Path.addLine(to: CGPoint(x: 110, y: 6.67))
  748. bezier3Path.addLine(to: CGPoint(x: 110, y: -0))
  749. bezier3Path.addLine(to: CGPoint(x: 109.83, y: -0))
  750. bezier3Path.addCurve(to: CGPoint(x: 0, y: 110.21), controlPoint1: CGPoint(x: 49.17, y: -0), controlPoint2: CGPoint(x: 0, y: 49.34))
  751. bezier3Path.addCurve(to: CGPoint(x: 109.83, y: 220.43), controlPoint1: CGPoint(x: 0, y: 171.08), controlPoint2: CGPoint(x: 49.17, y: 220.43))
  752. bezier3Path.addCurve(to: CGPoint(x: 219.66, y: 110.21), controlPoint1: CGPoint(x: 170.49, y: 220.43), controlPoint2: CGPoint(x: 219.66, y: 171.08))
  753. bezier3Path.addCurve(to: CGPoint(x: 175.93, y: 22.19), controlPoint1: CGPoint(x: 219.66, y: 75.61), controlPoint2: CGPoint(x: 203.46, y: 43.02))
  754. bezier3Path.addLine(to: CGPoint(x: 175.96, y: 22.22))
  755. bezier3Path.addCurve(to: CGPoint(x: 109.78, y: -0), controlPoint1: CGPoint(x: 156.89, y: 7.8), controlPoint2: CGPoint(x: 133.66, y: -0))
  756. bezier3Path.addLine(to: CGPoint(x: 110, y: -0))
  757. bezier3Path.close()
  758. fillColor5.setFill()
  759. bezier3Path.fill()
  760. context.restoreGState()
  761. //// Bezier 4 Drawing
  762. let bezier4Path = UIBezierPath()
  763. bezier4Path.move(to: CGPoint(x: 101.24, y: 249.96))
  764. bezier4Path.addLine(to: CGPoint(x: 193.35, y: 249.96))
  765. bezier4Path.addLine(to: CGPoint(x: 152.9, y: 98.47))
  766. bezier4Path.addLine(to: CGPoint(x: 152.91, y: 98.52))
  767. bezier4Path.addCurve(to: CGPoint(x: 98.43, y: 66.95), controlPoint1: CGPoint(x: 146.55, y: 74.7), controlPoint2: CGPoint(x: 122.16, y: 60.57))
  768. bezier4Path.addCurve(to: CGPoint(x: 66.97, y: 121.63), controlPoint1: CGPoint(x: 74.69, y: 73.33), controlPoint2: CGPoint(x: 60.61, y: 97.81))
  769. bezier4Path.addLine(to: CGPoint(x: 101.24, y: 249.96))
  770. bezier4Path.close()
  771. fillColor.setFill()
  772. bezier4Path.fill()
  773. //// Bezier 5 Drawing
  774. let bezier5Path = UIBezierPath()
  775. bezier5Path.move(to: CGPoint(x: 100.77, y: 75.71))
  776. bezier5Path.addLine(to: CGPoint(x: 100.76, y: 75.71))
  777. bezier5Path.addCurve(to: CGPoint(x: 75.07, y: 103.85), controlPoint1: CGPoint(x: 87.48, y: 79.29), controlPoint2: CGPoint(x: 77.46, y: 90.26))
  778. bezier5Path.addLine(to: CGPoint(x: 84.33, y: 138.17))
  779. bezier5Path.addLine(to: CGPoint(x: 84.33, y: 138.17))
  780. bezier5Path.addCurve(to: CGPoint(x: 123.5, y: 160.87), controlPoint1: CGPoint(x: 88.9, y: 155.29), controlPoint2: CGPoint(x: 106.44, y: 165.46))
  781. bezier5Path.addCurve(to: CGPoint(x: 146.12, y: 121.56), controlPoint1: CGPoint(x: 140.57, y: 156.28), controlPoint2: CGPoint(x: 150.69, y: 138.68))
  782. bezier5Path.addLine(to: CGPoint(x: 136.9, y: 87.02))
  783. bezier5Path.addLine(to: CGPoint(x: 137.04, y: 87.19))
  784. bezier5Path.addCurve(to: CGPoint(x: 100.77, y: 75.71), controlPoint1: CGPoint(x: 128.2, y: 76.62), controlPoint2: CGPoint(x: 114.06, y: 72.14))
  785. bezier5Path.addLine(to: CGPoint(x: 100.77, y: 75.71))
  786. bezier5Path.close()
  787. fillColor6.setFill()
  788. bezier5Path.fill()
  789. context.restoreGState()
  790. }
  791. /// Draw image for scroll back to bottom icon
  792. ///
  793. /// - Parameter frame: Frame of the image
  794. @objc dynamic public class func drawScrollDownButtonIcon(frame: CGRect = CGRect(x: 0, y: 0, width: 39, height: 39)) {
  795. //// General Declarations
  796. // This non-generic function dramatically improves compilation times of complex expressions.
  797. func fastFloor(_ x: CGFloat) -> CGFloat { return floor(x) }
  798. //// Color Declarations
  799. let chatBarBackground: UIColor = Colors.chatBarBackground()
  800. let chatBarBorder: UIColor = Colors.chatBarBorder()
  801. let main: UIColor = Colors.main()
  802. //// Subframes
  803. let fullImage: CGRect = CGRect(x: frame.minX + fastFloor(frame.width * 0.02564 + 0.5), y: frame.minY + fastFloor(frame.height * 0.02564 + 0.5), width: fastFloor(frame.width * 0.97436 + 0.5) - fastFloor(frame.width * 0.02564 + 0.5), height: fastFloor(frame.height * 0.97436 + 0.5) - fastFloor(frame.height * 0.02564 + 0.5))
  804. //// fullImage
  805. //// circle Drawing
  806. let circlePath = UIBezierPath(ovalIn: CGRect(x: fullImage.minX + fastFloor(fullImage.width * 0.00000 + 0.5), y: fullImage.minY + fastFloor(fullImage.height * 0.00000 + 0.5), width: fastFloor(fullImage.width * 1.00000 + 0.5) - fastFloor(fullImage.width * 0.00000 + 0.5), height: fastFloor(fullImage.height * 1.00000 + 0.5) - fastFloor(fullImage.height * 0.00000 + 0.5)))
  807. chatBarBackground.setFill()
  808. circlePath.fill()
  809. chatBarBorder.setStroke()
  810. circlePath.lineWidth = 1
  811. circlePath.stroke()
  812. //// chevronDown Drawing
  813. let chevronDownPath = UIBezierPath()
  814. chevronDownPath.move(to: CGPoint(x: fullImage.minX + 0.50332 * fullImage.width, y: fullImage.minY + 0.70531 * fullImage.height))
  815. chevronDownPath.addCurve(to: CGPoint(x: fullImage.minX + 0.52567 * fullImage.width, y: fullImage.minY + 0.69566 * fullImage.height), controlPoint1: CGPoint(x: fullImage.minX + 0.51166 * fullImage.width, y: fullImage.minY + 0.70531 * fullImage.height), controlPoint2: CGPoint(x: fullImage.minX + 0.52000 * fullImage.width, y: fullImage.minY + 0.70198 * fullImage.height))
  816. chevronDownPath.addLine(to: CGPoint(x: fullImage.minX + 0.78385 * fullImage.width, y: fullImage.minY + 0.43189 * fullImage.height))
  817. chevronDownPath.addCurve(to: CGPoint(x: fullImage.minX + 0.79286 * fullImage.width, y: fullImage.minY + 0.41060 * fullImage.height), controlPoint1: CGPoint(x: fullImage.minX + 0.78952 * fullImage.width, y: fullImage.minY + 0.42623 * fullImage.height), controlPoint2: CGPoint(x: fullImage.minX + 0.79286 * fullImage.width, y: fullImage.minY + 0.41892 * fullImage.height))
  818. chevronDownPath.addCurve(to: CGPoint(x: fullImage.minX + 0.76250 * fullImage.width, y: fullImage.minY + 0.38000 * fullImage.height), controlPoint1: CGPoint(x: fullImage.minX + 0.79286 * fullImage.width, y: fullImage.minY + 0.39330 * fullImage.height), controlPoint2: CGPoint(x: fullImage.minX + 0.77985 * fullImage.width, y: fullImage.minY + 0.38000 * fullImage.height))
  819. chevronDownPath.addCurve(to: CGPoint(x: fullImage.minX + 0.74082 * fullImage.width, y: fullImage.minY + 0.38865 * fullImage.height), controlPoint1: CGPoint(x: fullImage.minX + 0.75416 * fullImage.width, y: fullImage.minY + 0.38000 * fullImage.height), controlPoint2: CGPoint(x: fullImage.minX + 0.74649 * fullImage.width, y: fullImage.minY + 0.38333 * fullImage.height))
  820. chevronDownPath.addLine(to: CGPoint(x: fullImage.minX + 0.50332 * fullImage.width, y: fullImage.minY + 0.63080 * fullImage.height))
  821. chevronDownPath.addLine(to: CGPoint(x: fullImage.minX + 0.26548 * fullImage.width, y: fullImage.minY + 0.38865 * fullImage.height))
  822. chevronDownPath.addCurve(to: CGPoint(x: fullImage.minX + 0.24380 * fullImage.width, y: fullImage.minY + 0.38000 * fullImage.height), controlPoint1: CGPoint(x: fullImage.minX + 0.26015 * fullImage.width, y: fullImage.minY + 0.38333 * fullImage.height), controlPoint2: CGPoint(x: fullImage.minX + 0.25247 * fullImage.width, y: fullImage.minY + 0.38000 * fullImage.height))
  823. chevronDownPath.addCurve(to: CGPoint(x: fullImage.minX + 0.21345 * fullImage.width, y: fullImage.minY + 0.41060 * fullImage.height), controlPoint1: CGPoint(x: fullImage.minX + 0.22645 * fullImage.width, y: fullImage.minY + 0.38000 * fullImage.height), controlPoint2: CGPoint(x: fullImage.minX + 0.21345 * fullImage.width, y: fullImage.minY + 0.39330 * fullImage.height))
  824. chevronDownPath.addCurve(to: CGPoint(x: fullImage.minX + 0.22245 * fullImage.width, y: fullImage.minY + 0.43222 * fullImage.height), controlPoint1: CGPoint(x: fullImage.minX + 0.21345 * fullImage.width, y: fullImage.minY + 0.41892 * fullImage.height), controlPoint2: CGPoint(x: fullImage.minX + 0.21678 * fullImage.width, y: fullImage.minY + 0.42623 * fullImage.height))
  825. chevronDownPath.addLine(to: CGPoint(x: fullImage.minX + 0.48064 * fullImage.width, y: fullImage.minY + 0.69566 * fullImage.height))
  826. chevronDownPath.addCurve(to: CGPoint(x: fullImage.minX + 0.50332 * fullImage.width, y: fullImage.minY + 0.70531 * fullImage.height), controlPoint1: CGPoint(x: fullImage.minX + 0.48697 * fullImage.width, y: fullImage.minY + 0.70198 * fullImage.height), controlPoint2: CGPoint(x: fullImage.minX + 0.49465 * fullImage.width, y: fullImage.minY + 0.70531 * fullImage.height))
  827. chevronDownPath.close()
  828. main.setFill()
  829. chevronDownPath.fill()
  830. }
  831. /// Draw image for image selection background
  832. ///
  833. /// - Parameter frame: Frame of the image
  834. @objc dynamic public class func drawCheckedBackground(frame: CGRect = CGRect(x: 0, y: 0, width: 62, height: 62)) {
  835. //// Color Declarations
  836. let color = Colors.main()!
  837. //// Bezier Drawing
  838. let bezierPath = UIBezierPath()
  839. bezierPath.move(to: CGPoint(x: frame.minX + 0.66129 * frame.width, y: frame.minY + 4))
  840. bezierPath.addLine(to: CGPoint(x: frame.minX + 8.59, y: frame.minY + 4))
  841. bezierPath.addCurve(to: CGPoint(x: frame.minX + 5.89, y: frame.minY + 4.22), controlPoint1: CGPoint(x: frame.minX + 7.27, y: frame.minY + 4), controlPoint2: CGPoint(x: frame.minX + 6.61, y: frame.minY + 4))
  842. bezierPath.addCurve(to: CGPoint(x: frame.minX + 4.22, y: frame.minY + 5.89), controlPoint1: CGPoint(x: frame.minX + 5.12, y: frame.minY + 4.51), controlPoint2: CGPoint(x: frame.minX + 4.51, y: frame.minY + 5.12))
  843. bezierPath.addLine(to: CGPoint(x: frame.minX + 4.2, y: frame.minY + 6.01))
  844. bezierPath.addCurve(to: CGPoint(x: frame.minX + 4, y: frame.minY + 8.59), controlPoint1: CGPoint(x: frame.minX + 4, y: frame.minY + 6.61), controlPoint2: CGPoint(x: frame.minX + 4, y: frame.minY + 7.27))
  845. bezierPath.addLine(to: CGPoint(x: frame.minX + 4, y: frame.maxY - 8.59))
  846. bezierPath.addCurve(to: CGPoint(x: frame.minX + 4.22, y: frame.maxY - 5.89), controlPoint1: CGPoint(x: frame.minX + 4, y: frame.maxY - 7.27), controlPoint2: CGPoint(x: frame.minX + 4, y: frame.maxY - 6.61))
  847. bezierPath.addCurve(to: CGPoint(x: frame.minX + 5.89, y: frame.maxY - 4.22), controlPoint1: CGPoint(x: frame.minX + 4.51, y: frame.maxY - 5.12), controlPoint2: CGPoint(x: frame.minX + 5.12, y: frame.maxY - 4.51))
  848. bezierPath.addLine(to: CGPoint(x: frame.minX + 6.01, y: frame.maxY - 4.2))
  849. bezierPath.addCurve(to: CGPoint(x: frame.minX + 8.59, y: frame.maxY - 4), controlPoint1: CGPoint(x: frame.minX + 6.61, y: frame.maxY - 4), controlPoint2: CGPoint(x: frame.minX + 7.27, y: frame.maxY - 4))
  850. bezierPath.addLine(to: CGPoint(x: frame.maxX - 8.59, y: frame.maxY - 4))
  851. bezierPath.addCurve(to: CGPoint(x: frame.maxX - 5.89, y: frame.maxY - 4.22), controlPoint1: CGPoint(x: frame.maxX - 7.27, y: frame.maxY - 4), controlPoint2: CGPoint(x: frame.maxX - 6.61, y: frame.maxY - 4))
  852. bezierPath.addCurve(to: CGPoint(x: frame.maxX - 4.22, y: frame.maxY - 5.89), controlPoint1: CGPoint(x: frame.maxX - 5.12, y: frame.maxY - 4.51), controlPoint2: CGPoint(x: frame.maxX - 4.51, y: frame.maxY - 5.12))
  853. bezierPath.addLine(to: CGPoint(x: frame.maxX - 4.2, y: frame.maxY - 6.01))
  854. bezierPath.addCurve(to: CGPoint(x: frame.maxX - 4, y: frame.maxY - 8.59), controlPoint1: CGPoint(x: frame.maxX - 4, y: frame.maxY - 6.61), controlPoint2: CGPoint(x: frame.maxX - 4, y: frame.maxY - 7.27))
  855. bezierPath.addLine(to: CGPoint(x: frame.maxX - 4, y: frame.minY + 0.33871 * frame.height))
  856. bezierPath.addLine(to: CGPoint(x: frame.minX + 0.69355 * frame.width, y: frame.minY + 0.33871 * frame.height))
  857. bezierPath.addCurve(to: CGPoint(x: frame.minX + 0.66129 * frame.width, y: frame.minY + 0.30645 * frame.height), controlPoint1: CGPoint(x: frame.minX + 0.69355 * frame.width, y: frame.minY + 0.33871 * frame.height), controlPoint2: CGPoint(x: frame.minX + 0.66129 * frame.width, y: frame.minY + 0.33871 * frame.height))
  858. bezierPath.addCurve(to: CGPoint(x: frame.minX + 0.66129 * frame.width, y: frame.minY + 4), controlPoint1: CGPoint(x: frame.minX + 0.66129 * frame.width, y: frame.minY + 0.27419 * frame.height), controlPoint2: CGPoint(x: frame.minX + 0.66129 * frame.width, y: frame.minY + 4))
  859. bezierPath.close()
  860. bezierPath.move(to: CGPoint(x: frame.maxX, y: frame.minY + 0))
  861. bezierPath.addCurve(to: CGPoint(x: frame.maxX, y: frame.maxY), controlPoint1: CGPoint(x: frame.maxX, y: frame.minY), controlPoint2: CGPoint(x: frame.maxX, y: frame.maxY))
  862. bezierPath.addLine(to: CGPoint(x: frame.minX, y: frame.maxY))
  863. bezierPath.addLine(to: CGPoint(x: frame.minX, y: frame.minY))
  864. bezierPath.addLine(to: CGPoint(x: frame.maxX, y: frame.minY))
  865. bezierPath.addLine(to: CGPoint(x: frame.maxX, y: frame.minY + 0))
  866. bezierPath.close()
  867. color.setFill()
  868. bezierPath.fill()
  869. }
  870. class func scaleSize(_ value: Int) -> Int {
  871. return value * Int(UIScreen.main.scale)
  872. }
  873. @objc(StyleKitNameResizingBehavior)
  874. public enum ResizingBehavior: Int {
  875. case aspectFit /// The content is proportionally resized to fit into the target rectangle.
  876. case aspectFill /// The content is proportionally resized to completely fill the target rectangle.
  877. case stretch /// The content is stretched to match the entire target rectangle.
  878. case center /// The content is centered in the target rectangle, but it is NOT resized.
  879. public func apply(rect: CGRect, target: CGRect) -> CGRect {
  880. if rect == target || target == CGRect.zero {
  881. return rect
  882. }
  883. var scales = CGSize.zero
  884. scales.width = abs(target.width / rect.width)
  885. scales.height = abs(target.height / rect.height)
  886. switch self {
  887. case .aspectFit:
  888. scales.width = min(scales.width, scales.height)
  889. scales.height = scales.width
  890. case .aspectFill:
  891. scales.width = max(scales.width, scales.height)
  892. scales.height = scales.width
  893. case .stretch:
  894. break
  895. case .center:
  896. scales.width = 1
  897. scales.height = 1
  898. }
  899. var result = rect.standardized
  900. result.size.width *= scales.width
  901. result.size.height *= scales.height
  902. result.origin.x = target.minX + (target.width - result.width) / 2
  903. result.origin.y = target.minY + (target.height - result.height) / 2
  904. return result
  905. }
  906. }
  907. }