Start maybe working on a native app

This commit is contained in:
2026-11-22 17:38:28 -03:00
parent 681d3afb4d
commit a552883795
31 changed files with 1881 additions and 678 deletions
+6 -11
View File
@@ -2,19 +2,14 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { load_texture, type Texture } from "./renderer/mod.ts";
import { decode_png } from "./png.ts";
// a player's skin as the server sends it (a base64 64x64 png), undefined when it can't be decoded
export async function decode_skin(skin: string): Promise<Texture | undefined> {
// a player's skin as the server sends it (a base64 64x64 png), undefined when it can't be decoded. pixels are as
// stored, so pngs with a color profile look the same as in an editor that ignores it
export function decode_skin(skin: string): Texture | undefined {
try {
const bytes = Uint8Array.from(atob(skin), (char) => char.charCodeAt(0));
// as stored, so pngs with a color profile look the same as in an editor that ignores it, like minecraft
const image = await createImageBitmap(new Blob([bytes], { type: "image/png" }), {
colorSpaceConversion: "none",
premultiplyAlpha: "none",
});
const texture = image.width === 64 && image.height === 64 ? load_texture(image) : undefined;
image.close();
return texture;
const image = decode_png(Uint8Array.from(atob(skin), (char) => char.charCodeAt(0)));
return image.width === 64 && image.height === 64 ? load_texture(image) : undefined;
} catch {
return undefined;
}