mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
somewhat successful walk/idle anim impl
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package net.torvald.colourutil
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.colourutil.CIEXYZUtil.linearise
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-07-26.
|
||||
@@ -20,4 +21,17 @@ object ColourUtil {
|
||||
|
||||
return Color(r, g, b, a)
|
||||
}
|
||||
|
||||
/** Get luminosity level using CIEXYZ colour space. Slow but accurate. */
|
||||
fun RGB.getLuminosity(): Float {
|
||||
val new = this.linearise()
|
||||
return 0.2126729f * new.r + 0.7151522f * new.g + 0.0721750f * new.b // from RGB.toXYZ
|
||||
}
|
||||
/** Get luminosity level using CIEXYZ colour space. Slow but accurate. */
|
||||
fun Color.getLuminosity() = RGB(this).getLuminosity()
|
||||
|
||||
/** Get luminosity level using NTSC standard. Fast, less accurate but should be good enough. */
|
||||
fun RGB.getLuminosityQuick() = 0.3f * this.r + 0.59f * this.g + 0.11f * this.b // NTSC standard
|
||||
/** Get luminosity level using NTSC standard. Fast, less accurate but should be good enough. */
|
||||
fun Color.getLuminosityQuick() = 0.3f * this.r + 0.59f * this.g + 0.11f * this.b // NTSC standard
|
||||
}
|
||||
Reference in New Issue
Block a user