Skip to content

Commit

Permalink
Adds Color initializer to Pixel (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
traviskirton authored and alejandro-isaza committed May 12, 2016
1 parent 2635f1a commit 9b8388a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion C4/UI/Pixel.swift
Expand Up @@ -43,10 +43,15 @@ public struct Pixel {
/// - parameter g: the green component
/// - parameter b: the blue component
/// - parameter a: the alpha component
public init(_ r: Int, _ g: Int, _ b: Int, _ a: UInt8) {
public init(_ r: Int, _ g: Int, _ b: Int, _ a: Int) {
self.r = UInt8(r)
self.g = UInt8(g)
self.b = UInt8(b)
self.a = UInt8(a)
}

public init(_ color: Color) {
let rgba: [Int] = color.components.map({ Int($0 * 255.0) })
self.init(rgba[0], rgba[1], rgba[2], rgba[3])
}
}

0 comments on commit 9b8388a

Please sign in to comment.