mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
btex: default colour change
This commit is contained in:
@@ -30,8 +30,8 @@ class BTeXDocument {
|
|||||||
get() = 2 * pageMarginV + textHeight
|
get() = 2 * pageMarginV + textHeight
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val DEFAULT_PAGE_BACK = Color(0xe1e1d7ff.toInt())
|
val DEFAULT_PAGE_BACK = Color(0xe0dfdb_ff.toInt())
|
||||||
val DEFAULT_PAGE_FORE = Color(0x131311ff)
|
val DEFAULT_PAGE_FORE = Color(0x151110ff)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val pages = ArrayList<BTeXPage>()
|
private val pages = ArrayList<BTeXPage>()
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ package net.torvald.btex
|
|||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle
|
import com.badlogic.gdx.files.FileHandle
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.jme3.math.FastMath.DEG_TO_RAD
|
||||||
|
import net.torvald.colourutil.OKLch
|
||||||
|
import net.torvald.colourutil.tosRGB
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
import net.torvald.terrarum.btex.BTeXDocument
|
import net.torvald.terrarum.btex.BTeXDocument
|
||||||
|
import net.torvald.terrarum.btex.BTeXDocument.Companion.DEFAULT_PAGE_FORE
|
||||||
import net.torvald.terrarum.btex.BTeXDrawCall
|
import net.torvald.terrarum.btex.BTeXDrawCall
|
||||||
import net.torvald.terrarum.btex.MovableTypeDrawCall
|
import net.torvald.terrarum.btex.MovableTypeDrawCall
|
||||||
import net.torvald.terrarum.gameitems.ItemID
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
@@ -14,8 +17,9 @@ import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
|||||||
import org.xml.sax.Attributes
|
import org.xml.sax.Attributes
|
||||||
import org.xml.sax.InputSource
|
import org.xml.sax.InputSource
|
||||||
import org.xml.sax.helpers.DefaultHandler
|
import org.xml.sax.helpers.DefaultHandler
|
||||||
import java.io.*
|
import java.io.File
|
||||||
import java.util.*
|
import java.io.FileInputStream
|
||||||
|
import java.io.StringReader
|
||||||
import javax.xml.parsers.SAXParserFactory
|
import javax.xml.parsers.SAXParserFactory
|
||||||
import kotlin.reflect.KFunction
|
import kotlin.reflect.KFunction
|
||||||
import kotlin.reflect.full.declaredFunctions
|
import kotlin.reflect.full.declaredFunctions
|
||||||
@@ -47,7 +51,7 @@ object BTeXParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal class BTeXHandler(val doc: BTeXDocument) : DefaultHandler() {
|
internal class BTeXHandler(val doc: BTeXDocument) : DefaultHandler() {
|
||||||
private val DEFAULT_FONTCOL = Color(0x222222ff)
|
private val DEFAULT_FONTCOL = DEFAULT_PAGE_FORE
|
||||||
private val LINE_HEIGHT = doc.lineHeightInPx
|
private val LINE_HEIGHT = doc.lineHeightInPx
|
||||||
|
|
||||||
private var cover = ""
|
private var cover = ""
|
||||||
@@ -472,7 +476,10 @@ object BTeXParser {
|
|||||||
|
|
||||||
@OpenTag // reflective access is impossible with 'private'
|
@OpenTag // reflective access is impossible with 'private'
|
||||||
fun processElemCOVER(handler: BTeXHandler, doc: BTeXDocument, theTag: String, uri: String, attribs: HashMap<String, String>, siblingIndex: Int) {
|
fun processElemCOVER(handler: BTeXHandler, doc: BTeXDocument, theTag: String, uri: String, attribs: HashMap<String, String>, siblingIndex: Int) {
|
||||||
doc.addNewPage(Color(0x6f4a45ff))
|
val hue = (attribs["hue"]?.toFloatOrNull() ?: 28f) * DEG_TO_RAD
|
||||||
|
val coverCol = OKLch(hue, 0.05f, 0.36f)
|
||||||
|
val (r, g, b) = coverCol.tosRGB()
|
||||||
|
doc.addNewPage(Color(r, g, b, 1f))
|
||||||
handler.spanColour = "white"
|
handler.spanColour = "white"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ import kotlin.math.min
|
|||||||
data class OKHsv(var h: Float, var s: Float, var v: Float)
|
data class OKHsv(var h: Float, var s: Float, var v: Float)
|
||||||
data class OKHsl(var h: Float, var s: Float, var l: Float)
|
data class OKHsl(var h: Float, var s: Float, var l: Float)
|
||||||
data class OKLab(var L: Float, var a: Float, var b: Float)
|
data class OKLab(var L: Float, var a: Float, var b: Float)
|
||||||
|
data class OKLch(var H: Float, var C: Float, var L: Float)
|
||||||
|
|
||||||
|
fun OKLch.toOKLab() = OKLab(L, C * cos(H), C * sin(H))
|
||||||
|
fun OKLch.tosRGB() = this.toOKLab().toLinearRGB().unLinearise()
|
||||||
|
|
||||||
object OKHsvUtil {
|
object OKHsvUtil {
|
||||||
internal data class LC(var L: Float, var C: Float)
|
internal data class LC(var L: Float, var C: Float)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class BTeXTest : ApplicationAdapter() {
|
|||||||
val csi0 = "\u001B[m"
|
val csi0 = "\u001B[m"
|
||||||
|
|
||||||
val tex = """<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
val tex = """<btexdoc cover="hardcover" inner="standard" papersize="standard">
|
||||||
<cover>
|
<cover hue="160">
|
||||||
<title>The Way to Mastery of Lorem Ipsum<br />Or, How To Write and Publish a Book</title>
|
<title>The Way to Mastery of Lorem Ipsum<br />Or, How To Write and Publish a Book</title>
|
||||||
<author>Terran Publishing</author>
|
<author>Terran Publishing</author>
|
||||||
<edition>Test Edition</edition>
|
<edition>Test Edition</edition>
|
||||||
|
|||||||
Reference in New Issue
Block a user