SnowyGUI/common/src/main/kotlin/fr/username404/snowygui/utils/FontUtil.kt
Username404-59 2341dafe1b
Fix FontUtil.drawScaled
Signed-off-by: Username404-59 <w.iron.zombie@gmail.com>
2026-02-22 01:44:14 +01:00

21 lines
754 B
Kotlin

package fr.username404.snowygui.utils
import net.minecraft.client.Minecraft
import fr.username404.snowygui.gui.feature.Colors
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.util.ARGB
object FontUtil {
fun drawScaled(guiGraphics: GuiGraphics, text: String, x: Double, y: Double, scaleFactor: Float, color: Colors = Colors.BLACK) {
val stack = guiGraphics.pose()
stack.scale(scaleFactor, scaleFactor)
guiGraphics.drawString(
Minecraft.getInstance().font, text,
(x / scaleFactor).toInt(), (y / scaleFactor).toInt(),
ARGB.opaque(color.hexValue), false
)
val factorToOriginal = 1F / scaleFactor
stack.scale(factorToOriginal, factorToOriginal)
}
}