color code utils; colour-coded sample text

This commit is contained in:
minjaesong
2017-07-02 12:45:58 +09:00
parent 4cd29b5230
commit e23c0090f4
3 changed files with 21 additions and 0 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View File

@@ -748,6 +748,10 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
else throw IllegalArgumentException("Font scale cannot be zero or negative (input: $value)")
}
fun toColorCode(rgba4444: Int): String = GameFontBase.toColorCode(rgba4444)
fun toColorCode(r: Int, g: Int, b: Int, a: Int = 0x0F): String = toColorCode(r.shl(12) or g.shl(8) or b.shl(4) or a)
val noColorCode = toColorCode(0x0000)
companion object {
internal val JUNG_COUNT = 21
internal val JONG_COUNT = 28
@@ -785,6 +789,13 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
internal val SHEET_CUSTOM_SYM = 16
internal val SHEET_UNKNOWN = 254
fun toColorCode(rgba4444: Int): String = Character.toChars(0x100000 + rgba4444).toColCode()
fun toColorCode(r: Int, g: Int, b: Int, a: Int = 0x0F): String = toColorCode(r.shl(12) or g.shl(8) or b.shl(4) or a)
private fun CharArray.toColCode(): String = "${this[0]}${this[1]}"
val noColorCode = toColorCode(0x0000)
}
}

View File

@@ -753,5 +753,15 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false) : Font {
else throw IllegalArgumentException("Font scale cannot be zero or negative (input: $value)")
}
fun toColorCode(rgba4444: Int): String = GameFontBase.toColorCode(rgba4444)
fun toColorCode(r: Int, g: Int, b: Int, a: Int = 0x0F): String = toColorCode(r.shl(12) or g.shl(8) or b.shl(4) or a)
val noColorCode = toColorCode(0x0000)
companion object {
fun toColorCode(rgba4444: Int): String = Character.toChars(0x100000 + rgba4444).toColCode()
fun toColorCode(r: Int, g: Int, b: Int, a: Int = 0x0F): String = toColorCode(r.shl(12) or g.shl(8) or b.shl(4) or a)
private fun CharArray.toColCode(): String = "${this[0]}${this[1]}"
val noColorCode = toColorCode(0x0000)
}
}