mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
Finally fixed CIELabUtil's anomaly; apparently past me was dumb fucking perkeleen vittupää
Former-commit-id: 731df40639ccf1463238f70dd615bd1771eee259 Former-commit-id: fdf00fbe30f876731d9d952b2a65f448b90c7913
This commit is contained in:
@@ -15,7 +15,7 @@ import org.newdawn.slick.Color
|
||||
|
||||
object CIELChUtil {
|
||||
|
||||
/** Sweet Lch linear gradient */
|
||||
/** Sweet LCh linear gradient */
|
||||
fun getGradient(scale: Float, fromCol: Color, toCol: Color): Color {
|
||||
val from = fromCol.toLCh()
|
||||
val to = toCol.toLCh()
|
||||
|
||||
@@ -60,20 +60,20 @@ object CIELabUtil {
|
||||
}
|
||||
|
||||
fun CIEXYZ.toRGB(): Color {
|
||||
var r = 3.2404542f * x + -1.5371385f * y + -0.4985314f * z
|
||||
var g = -0.9692660f * x + 1.8760108f * y + 0.0415560f * z
|
||||
var b = 0.0556434f * x + -0.2040259f * y + 1.0572252f * z
|
||||
var r = 3.2404542f * x - 1.5371385f * y - 0.4985314f * z
|
||||
var g = -0.9692660f * x + 1.8760108f * y + 0.0415560f * z
|
||||
var b = 0.0556434f * x - 0.2040259f * y + 1.0572252f * z
|
||||
|
||||
if (r > 0.0031308f)
|
||||
r = 1.055f * r.powerOf(1f / 2.4f) - 0.055f
|
||||
else
|
||||
r *= 12.92f
|
||||
if (g > 0.0031308f)
|
||||
g = 1.055f * r.powerOf(1f / 2.4f) - 0.055f
|
||||
g = 1.055f * g.powerOf(1f / 2.4f) - 0.055f
|
||||
else
|
||||
g *= 12.92f
|
||||
if (b > 0.0031308f)
|
||||
b = 1.055f * r.powerOf(1f / 2.4f) - 0.055f
|
||||
b = 1.055f * b.powerOf(1f / 2.4f) - 0.055f
|
||||
else
|
||||
b *= 12.92f
|
||||
|
||||
|
||||
Reference in New Issue
Block a user