// SPDX-FileCopyrightText: 2026 Paula Wisnievski // SPDX-License-Identifier: AGPL-3.0-or-later import { AssetManager } from "@/client/assets.ts"; import type { Texture } from "@/client/renderer/mod.ts"; import { draw_nine_slice } from "@/client/rendering/render_utils.ts"; import { GUI_ATLAS, type GuiSprite } from "./gui_atlas.ts"; // gui sprites are drawn 3 times bigger, like minecraft at gui scale 3. SLOT_SIZE is its 18 pixel slot at this scale export const GUI_SCALE = 3; // a sprite from assets/sprites/gui.png, see tools/pack_gui.ts. nine slice ones stretch to the size given with their // borders kept at GUI_SCALE, the rest are drawn at their size times GUI_SCALE unless given one export function draw_gui_sprite( name: GuiSprite, x: number, y: number, width?: number, height?: number, color = [1, 1, 1, 1], ) { const texture = AssetManager.instance.get("cubi:gui"); const sprite = GUI_ATLAS[name]; const [left, top, right, bottom] = sprite.border; draw_nine_slice( texture, sprite.x, sprite.y, sprite.width, sprite.height, left, right, top, bottom, x, y, width ?? sprite.width * GUI_SCALE, height ?? sprite.height * GUI_SCALE, color, GUI_SCALE, ); }