LibGDX, here I am.

This commit is contained in:
minjaesong
2017-06-22 02:31:07 +09:00
parent ae00e2b8a6
commit 8e5e95e5a9
356 changed files with 3125 additions and 21138 deletions

View File

@@ -7,8 +7,7 @@ import net.torvald.colourutil.CIELabUtil.toLab
import net.torvald.colourutil.CIEXYZUtil.toXYZ
import net.torvald.colourutil.CIEXYZUtil.toColor
import net.torvald.colourutil.CIELabUtil.toXYZ
import org.newdawn.slick.Color
import com.badlogic.gdx.graphics.Color
/**
* Cylindrical modification of CIELab colour space
*

View File

@@ -6,7 +6,7 @@ import net.torvald.colourutil.CIEXYZUtil.toColor
import net.torvald.colourutil.CIEXYZUtil.toRGB
import net.torvald.colourutil.CIEXYZUtil.toXYZ
import net.torvald.colourutil.CIELabUtil.toXYZ
import org.newdawn.slick.Color
import com.badlogic.gdx.graphics.Color
/**
* A modification of CIEXYZ that is useful for surface colours

View File

@@ -1,7 +1,7 @@
package net.torvald.colourutil
import com.jme3.math.FastMath
import org.newdawn.slick.Color
import com.badlogic.gdx.graphics.Color
import net.torvald.colourutil.CIELabUtil.toXYZ
import net.torvald.colourutil.CIEXYZUtil.toColor
import net.torvald.colourutil.CIEXYZUtil.toRGB

View File

@@ -1,7 +1,7 @@
package net.torvald.colourutil
import com.jme3.math.FastMath
import org.newdawn.slick.Color
import com.badlogic.gdx.graphics.Color
/**
* Created by minjaesong on 2017-01-12.

View File

@@ -1,6 +1,6 @@
package net.torvald.colourutil
import org.newdawn.slick.Color
import com.badlogic.gdx.graphics.Color
/**
* 6-Step RGB with builtin utils.
@@ -31,18 +31,18 @@ class Col216 : LimitedColours {
create(r, g, b)
}
override fun createSlickColor(raw: Int): Color {
override fun createGdxColor(raw: Int): Color {
assertRaw(raw)
val r = raw / MUL_2
val g = raw % MUL_2 / MUL
val b = raw % MUL
return createSlickColor(r, g, b)
return createGdxColor(r, g, b)
}
override fun createSlickColor(r: Int, g: Int, b: Int): Color {
override fun createGdxColor(r: Int, g: Int, b: Int): Color {
assertRGB(r, g, b)
return Color(LOOKUP[r], LOOKUP[g], LOOKUP[b])
return Color((LOOKUP[r] shl 24) + (LOOKUP[g] shl 16) + (LOOKUP[b] shl 8) + 255)
}
override fun create(raw: Int) {
@@ -55,7 +55,7 @@ class Col216 : LimitedColours {
raw = (MUL_2 * r + MUL * g + b).toByte()
}
override fun toSlickColour(): Color = createSlickColor(raw.toUint())
override fun toGdxColour(): Color = createGdxColor(raw.toUint())
private fun assertRaw(i: Int) {
if (i >= COLOUR_RANGE_SIZE || i < 0) {

View File

@@ -1,72 +0,0 @@
package com.torvald.colourutil
import org.newdawn.slick.Color
/**
* 40-Step RGB with builtin utils.
* Created by minjaesong on 16-02-20.
*/
class Col40 : LimitedColours {
var raw: Char = ' '
private set
override fun createSlickColor(raw: Int): Color {
assertRaw(raw)
val r = raw / MUL_2
val g = raw % MUL_2 / MUL
val b = raw % MUL
return createSlickColor(r, g, b)
}
override fun createSlickColor(r: Int, g: Int, b: Int): Color {
assertRGB(r, g, b)
return Color(LOOKUP[r] shl 16 or (LOOKUP[g] shl 8) or LOOKUP[b])
}
override fun create(raw: Int) {
assertRaw(raw)
this.raw = raw.toChar()
}
override fun create(r: Int, g: Int, b: Int) {
assertRGB(r, g, b)
raw = (MUL_2 * r + MUL * g + b).toChar()
}
constructor() {
}
constructor(c: Color) {
create(
Math.round(c.r * (MUL - 1)),
Math.round(c.g * (MUL - 1)),
Math.round(c.b * (MUL - 1)))
}
private fun assertRaw(i: Int) {
if (i >= COLOUR_DOMAIN_SIZE || i < 0) {
println("i: " + i.toString())
throw IllegalArgumentException()
}
}
private fun assertRGB(r: Int, g: Int, b: Int) {
if (r !in 0..MAX_STEP || g !in 0..MAX_STEP || b !in 0..MAX_STEP) {
println("r: " + r.toString())
println("g: " + g.toString())
println("b: " + b.toString())
throw IllegalArgumentException()
}
}
companion object {
@Transient private val LOOKUP = intArrayOf(0, 7, 13, 20, 26, 33, 39, 46, 52, 59, 65, 72, 78, 85, 92, 98, 105, 111, 118, 124, 131, 137, 144, 150, 157, 163, 170, 177, 183, 190, 196, 203, 209, 216, 222, 229, 235, 242, 248, 255)
const val MUL = 40
const val MUL_2 = MUL * MUL
const val MAX_STEP = MUL - 1
const val COLOUR_DOMAIN_SIZE = MUL_2 * MUL
}
}

View File

@@ -1,6 +1,6 @@
package net.torvald.colourutil
import org.newdawn.slick.Color
import com.badlogic.gdx.graphics.Color
/**
* 12-bit (16-step) RGB with builtin utils.
@@ -41,7 +41,7 @@ class Col4096 : LimitedColours {
* *
* @return
*/
override fun createSlickColor(raw: Int): Color {
override fun createGdxColor(raw: Int): Color {
assertRaw(raw)
val a: Int
@@ -57,22 +57,22 @@ class Col4096 : LimitedColours {
a = raw and 0xF000 shr 12
return Color(
r.shl(4) or r, g.shl(4) or g, b.shl(4) or b, a.shl(4) or a)
(r.shl(4) or r).shl(24) + (g.shl(4) or g).shl(16) + (b.shl(4) or b).shl(8) + (a.shl(4) or a))
}
else {
return Color(
r.shl(4) or r, g.shl(4) or g, b.shl(4) or b)
(r.shl(4) or r).shl(24) + (g.shl(4) or g).shl(16) + (b.shl(4) or b).shl(8) + 255)
}
}
override fun createSlickColor(r: Int, g: Int, b: Int): Color {
override fun createGdxColor(r: Int, g: Int, b: Int): Color {
assertARGB(0, r, g, b)
return createSlickColor(r.shl(8) or g.shl(4) or b)
return createGdxColor(r.shl(8) or g.shl(4) or b)
}
fun createSlickColor(a: Int, r: Int, g: Int, b: Int): Color {
assertARGB(a, r, g, b)
return createSlickColor(a.shl(12) or r.shl(8) or g.shl(4) or b)
return createGdxColor(a.shl(12) or r.shl(8) or g.shl(4) or b)
}
override fun create(raw: Int) {
@@ -107,7 +107,7 @@ class Col4096 : LimitedColours {
return ret
}
override fun toSlickColour(): Color = createSlickColor(raw.toUint())
override fun toGdxColour(): Color = createGdxColor(raw.toUint())
private fun assertRaw(i: Int) {
if (i > 0xFFFF || i < 0) {

View File

@@ -1,10 +1,8 @@
package net.torvald.colourutil
import net.torvald.terrarum.getPixel
import net.torvald.terrarum.weather.toColor
import org.newdawn.slick.Color
import org.newdawn.slick.Image
import com.badlogic.gdx.graphics.Color
import net.torvald.colourutil.CIEXYZUtil.toColor
import net.torvald.terrarum.GdxColorMap
import net.torvald.terrarum.ModMgr
/**
@@ -12,7 +10,7 @@ import net.torvald.terrarum.ModMgr
* Created by minjaesong on 16-07-26.
*/
object ColourTemp {
private var clut = Image(ModMgr.getPath("basegame", "colourmap/black_body_col_1000_40000_K.tga"))
private var clut = GdxColorMap(ModMgr.getGdxFile("basegame", "colourmap/black_body_col_1000_40000_K.tga"))
private fun colTempToImagePos(K: Int): Int {
if (K < 1000 || K >= 40000) throw IllegalArgumentException("K: out of range. ($K)")
@@ -21,7 +19,7 @@ object ColourTemp {
/** returns sRGB-normalised colour */
operator fun invoke(temp: Int): Color =
clut.getPixel(colTempToImagePos(temp), 0).toColor()
clut.get(colTempToImagePos(temp))
/** returns CIExyY-based colour converted to slick.color
* @param CIE_Y 0.0 - 1.0+ */

View File

@@ -1,13 +1,13 @@
package net.torvald.colourutil
import com.jme3.math.FastMath
import org.newdawn.slick.Color
import com.badlogic.gdx.graphics.Color
/**
* Created by minjaesong on 16-07-26.
*/
object ColourUtil {
fun toSlickColor(r: Int, g: Int, b: Int) = Color(r.shl(16) or g.shl(8) or b)
fun toColor(r: Int, g: Int, b: Int) = Color(r.shl(24) or g.shl(16) or b.shl(8) or 0xff)
/**
* Use CIELabUtil.getGradient for natural-looking colour

View File

@@ -1,7 +1,7 @@
package net.torvald.colourutil
import com.jme3.math.FastMath
import org.newdawn.slick.Color
import com.badlogic.gdx.graphics.Color
/**
* OBSOLETE; use CIELchUtil for natural-looking colour
@@ -17,9 +17,6 @@ object HSVUtil {
* @param S 0-1 Saturation
* *
* @param V 0-1 Value
* *
* @return org.newdawn.slick.Color
* *
* @link http://www.rapidtables.com/convert/color/hsv-to-rgb.htm
*/
fun toRGB(H: Float, S: Float, V: Float, alpha: Float = 1f): Color {

View File

@@ -1,17 +1,17 @@
package net.torvald.colourutil
import org.newdawn.slick.Color
import com.badlogic.gdx.graphics.Color
/**
* Created by minjaesong on 16-02-11.
*/
interface LimitedColours {
fun createSlickColor(raw: Int): Color
fun createSlickColor(r: Int, g: Int, b: Int): Color
fun createGdxColor(raw: Int): Color
fun createGdxColor(r: Int, g: Int, b: Int): Color
fun create(raw: Int)
fun create(r: Int, g: Int, b: Int)
fun toSlickColour(): Color
fun toGdxColour(): Color
}