more Kotlin, UIs now can open/close with animation, working world time with skybox colour changing (sunlight transition is still WIP), fixed project library settings so that the suggestion in IntelliJ IDEA would work properly

Former-commit-id: 82c857164f2636ad943d5a43f0690a3431ab0f26
Former-commit-id: 7c8b70e6b267f7c5c050d7d0902278739ec18b44
This commit is contained in:
Song Minjae
2016-03-22 15:45:31 +09:00
parent 9335046057
commit 511bbfdc8f
178 changed files with 5565 additions and 4952 deletions

View File

@@ -0,0 +1,82 @@
package com.Torvald.ColourUtil
import org.newdawn.slick.Color
/**
* 6-Step RGB with builtin utils.
* Created by minjaesong on 16-02-11.
*/
class Col216 : LimitedColours {
var raw: Byte = 0
private set
/**
* @param data
*/
constructor(data: Byte) {
create(data.toInt())
}
/**
* @param r 0-5
* *
* @param g 0-5
* *
* @param b 0-5
*/
constructor(r: Int, g: Int, b: Int) {
create(r, g, b)
}
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], LOOKUP[g], LOOKUP[b])
}
override fun create(raw: Int) {
assertRaw(raw)
this.raw = raw.toByte()
}
override fun create(r: Int, g: Int, b: Int) {
assertRGB(r, g, b)
raw = (MUL_2 * r + MUL * g + b).toByte()
}
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(0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF)
const val MUL = 6
const val MUL_2 = MUL * MUL
const val MAX_STEP = MUL - 1
const val COLOUR_DOMAIN_SIZE = MUL_2 * MUL
}
}