Closed CrisFavero closed 4 years ago
import Foundation
open class ColorMatrix {
public static let identity = ColorMatrix(
values: [1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0])
public static let luminanceToAlpha = ColorMatrix(
values: [1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0.2125, 0.7154, 0.0721, 0, 0])
public let values: [Double]
public init(values: [Double]) {
if values.count != 20 {
fatalError("ColorMatrix: wrong matrix count")
}
self.values = values
}
public convenience init(color: Color) {
self.init(values: [0, 0, 0, 0, Double(color.r()) / 255.0,
0, 0, 0, 0, Double(color.g()) / 255.0,
0, 0, 0, 0, Double(color.b()) / 255.0,
0, 0, 0, Double(color.a()) / 255.0, 0])
}
public convenience init(saturate: Double) {
let s = max(min(saturate, 1), 0)
self.init(values: [0.213 + 0.787 * s, 0.715 - 0.715 * s, 0.072 - 0.072 * s, 0, 0,
0.213 - 0.213 * s, 0.715 + 0.285 * s, 0.072 - 0.072 * s, 0, 0,
0.213 - 0.213 * s, 0.715 - 0.715 * s, 0.072 + 0.928 * s, 0, 0,
0, 0, 0, 1, 0])
}
public convenience init(hueRotate: Double) {
let c = cos(hueRotate)
let s = sin(hueRotate)
let m1 = [0.213, 0.715, 0.072,
0.213, 0.715, 0.072,
0.213, 0.715, 0.072]
let m2 = [0.787, -0.715, -0.072,
-0.213, 0.285, -0.072,
-0.213, -0.715, 0.928]
let m3 = [-0.213, -0.715, 0.928,
0.143, 0.140, -0.283,
-0.787, 0.715, 0.072]
/*
let a = { i in
m1[i] + c * m2[i] + s * m3[i]
}
*/ self.init(values: [ acal(i:0, m1: m1, c: c, m2: m2, s: s, m3: m3), acal(i:1, m1: m1, c: c, m2: m2, s: s, m3: m3), acal(i:2, m1: m1, c: c, m2: m2, s: s, m3: m3), 0, 0, acal(i:3, m1: m1, c: c, m2: m2, s: s, m3: m3), acal(i:4, m1: m1, c: c, m2: m2, s: s, m3: m3), acal(i:5, m1: m1, c: c, m2: m2, s: s, m3: m3), 0, 0, acal(i:6, m1: m1, c: c, m2: m2, s: s, m3: m3), acal(i:7, m1: m1, c: c, m2: m2, s: s, m3: m3), acal(i:8, m1: m1, c: c, m2: m2, s: s, m3: m3), 0, 0,0, 0, 0, 1, 0]) }
}
func acal(i:Int,m1:[Double],c:Double,m2:[Double],s:Double,m3:[Double]) -> Double { return m1[i] + c m2[i] + s m3[i]
}
This issue fixed in the master branch.
So now we can use it in iOS 14.0 beta Thanks mate!
i have this problem in the Colors.swift file, in the line 56. I use in xcode 11.6.
Hi @IngMarFlo,
Please you the latest release version 0.9.7
.
Thanks, i'll try
El mar., 11 de agosto de 2020 1:30 a. m., Yuri Strot < notifications@github.com> escribió:
Hi @IngMarFlo https://github.com/IngMarFlo,
Please you the latest release version 0.9.7.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/exyte/Macaw/issues/709#issuecomment-671755936, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFZ3VISGGMIU2BGJVAPMYFTSADQQXANCNFSM4OKTDCPA .
While building Macaw with xcode12-beta We get the build error
The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
on line sixty in colorMatrixhttps://github.com/exyte/Macaw/blob/master/Source/model/draw/ColorMatrix.swift#L60