You should not post code in comments, they mess it. So I had to rebuild it.
Note: I do find it confusing to name the class and the struct inside by the same name…
Why do you declare public ? And not simply extension Bitmap {} for instance ?
You did not answer my other questions :
Cannot convert value of type 'CGImage' to expected argument type 'Bitmap'
Which is logic, as cgImage is CGImage and not Bitmap
In addition, you call the convenience initialiser within itself… I must be missing something
import UIKit
class Color: UIViewController {
public struct Color {
public var r, g, b, a: UInt8
public init(r: UInt8, g: UInt8, b: UInt8, a: UInt8 = 255) {
self.r = r
self.g = g
self.b = b
self.a = a
}
}
override func viewDidLoad() {
super.viewDidLoad() // Do any additional setup after loading the view.
}
}
extension Color {
static let clear = Color(r: 0, g: 0, b: 0, a: 0)
static let black = Color(r: 0, g: 0, b: 0)
static let white = Color(r: 255, g: 255, b: 255)
static let gray = Color(r: 192, g: 192, b: 192)
static let red = Color(r: 255, g: 0, b: 0)
static let green = Color(r: 0, g: 255, b: 0)
static let blue = Color(r: 0, g: 0, b: 255)
}