sten.wtf / STEN Vault source

In-house snapshot of sten-vault 2.3.2. GPL-3.0-or-later. Isolated from the dashboard.

src/main/java/wtf/sten/vault/ui/Glass.java

package wtf.sten.vault.ui;

import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.network.chat.Component;

public final class Glass {
	public static final int BG = 0xFF0A0B12;
	public static final int PANEL = 0xCC12141C;
	public static final int PANEL_STRONG = 0xE0181B27;
	public static final int STROKE = 0x665A7FFF;
	public static final int STROKE_SOFT = 0x335A7FFF;
	public static final int CYAN = 0xFF67E8F9;
	public static final int BLUE = 0xFF5A7FFF;
	public static final int INK = 0xFFE6EAF4;
	public static final int INK_SOFT = 0xFF9AA3B5;
	public static final int DANGER = 0xFFFF5C7A;
	public static final int SUCCESS = 0xFF3DDC97;
	public static final int GLOW = 0x335A7FFF;

	private Glass() {
	}

	public static void atmosphere(GuiGraphicsExtractor g, int width, int height) {
		g.fill(0, 0, width, height, BG);
		g.fill(0, 0, width, 90, 0x332447FF);
		g.fill(width - 180, 0, width, 160, 0x2214C8C8);
		g.fill(0, height - 8, width, height, BLUE);
	}

	public static void panel(GuiGraphicsExtractor g, int x, int y, int w, int h, int fill) {
		g.fill(x + 1, y, x + w - 1, y + h, fill);
		g.fill(x, y + 1, x + 1, y + h - 1, fill);
		g.fill(x + w - 1, y + 1, x + w, y + h - 1, fill);
		g.fill(x, y, x + w, y + 1, STROKE);
		g.fill(x, y + h - 1, x + w, y + h, STROKE_SOFT);
		g.fill(x, y, x + 1, y + h, STROKE_SOFT);
		g.fill(x + w - 1, y, x + w, y + h, STROKE_SOFT);
	}

	public static void wordmark(GuiGraphicsExtractor g, Font font, int x, int y) {
		g.text(font, Component.literal("sten"), x, y, INK, false);
		int sw = font.width("sten");
		g.text(font, Component.literal(".wtf"), x + sw, y, CYAN, false);
	}

	public static int mix(int a, int b, float t) {
		int ar = (a >> 16) & 255, ag = (a >> 8) & 255, ab = a & 255, aa = (a >>> 24) & 255;
		int br = (b >> 16) & 255, bg = (b >> 8) & 255, bb = b & 255, ba = (b >>> 24) & 255;
		int r = (int) (ar + (br - ar) * t);
		int g = (int) (ag + (bg - ag) * t);
		int bl = (int) (ab + (bb - ab) * t);
		int al = (int) (aa + (ba - aa) * t);
		return (al << 24) | (r << 16) | (g << 8) | bl;
	}
}