tapestry sprite to draw frame

This commit is contained in:
minjaesong
2022-02-28 11:39:29 +09:00
parent 142fcab930
commit 68d8bf13b7
8 changed files with 118 additions and 24 deletions

View File

@@ -37,6 +37,7 @@ import java.io.PrintStream
import java.util.*
import kotlin.math.absoluteValue
import kotlin.math.round
import kotlin.math.roundToInt
@@ -348,6 +349,20 @@ inline fun FrameBuffer.inActionF(camera: OrthographicCamera?, batch: SpriteBatch
}
private val rgbMultLUT = Array(256) { y -> IntArray(256) { x ->
val i = (x % 256) / 255f
val j = (y / 256) / 255f
(i * j).times(255f).roundToInt()
} }
infix fun Int.rgbamul(other: Int): Int {
val r = rgbMultLUT[this.ushr(24).and(255)][other.ushr(24).and(255)]
val g = rgbMultLUT[this.ushr(16).and(255)][other.ushr(16).and(255)]
val b = rgbMultLUT[this.ushr(8).and(255)][other.ushr(8).and(255)]
val a = rgbMultLUT[this.ushr(0).and(255)][other.ushr(0).and(255)]
return r.shl(24) or g.shl(16) or b.shl(8) or a
}
infix fun Color.mul(other: Color): Color = this.cpy().mul(other)
infix fun Color.mulAndAssign(other: Color): Color {
this.r *= other.r