slightly decrease texture size of sign, fix test

This commit is contained in:
Vitaly Turovsky 2024-02-07 03:40:42 +03:00
commit 83b76ea7e6
3 changed files with 7 additions and 14 deletions

View file

@ -33,7 +33,9 @@ const parseSafe = (text: string, task: string) => {
}
export const renderSign = (blockEntity: SignBlockEntity, PrismarineChat: typeof ChatMessage, ctxHook = (ctx) => { }) => {
const factor = 50
// todo don't use texture rendering, investigate the font rendering when possible
// or increase factor when needed
const factor = 40
const signboardY = [16, 9]
const heightOffset = signboardY[0] - signboardY[1]
const heightScalar = heightOffset / 16

View file

@ -19,11 +19,14 @@ const blockEntity = {
"Text1": "{\"extra\":[{\"color\":\"dark_green\",\"text\":\"Minecraft \"},{\"text\":\"Tools\"}],\"text\":\"\"}"
} as const
await document.fonts.load('1em mojangles')
const canvas = renderSign(blockEntity, PrismarineChat, (ctx) => {
ctx.drawImage(img, 0, 0, ctx.canvas.width, ctx.canvas.height)
})
if (canvas) {
canvas.style.imageRendering = 'pixelated'
document.body.appendChild(canvas)
} else {
console.log('Render skipped')

View file

@ -23,7 +23,7 @@ global.document = {
const render = (entity) => {
ctxTexts = []
renderSign(entity, PrismarineChat)
return ctxTexts.map(({ text, y }) => [y / 80, text])
return ctxTexts.map(({ text, y }) => [y / 64, text])
}
test('sign renderer', () => {
@ -49,18 +49,6 @@ test('sign renderer', () => {
1,
"Tools",
],
[
2,
"",
],
[
3,
"",
],
[
4,
"",
],
]
`)