Initial sanctuary sources
This commit is contained in:
@@ -0,0 +1,298 @@
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class GenerateGuiTextures {
|
||||
private static final Path OUT = Path.of("src/main/resources/assets/blocodex/textures/gui");
|
||||
|
||||
private static final int TRANSPARENT = 0x00000000;
|
||||
private static final int DARK = 0xFF211F1C;
|
||||
private static final int BLACK = 0xFF050606;
|
||||
private static final int BODY = 0xFFE5DED0;
|
||||
private static final int BODY_SHADOW = 0xFF8F887D;
|
||||
private static final int BODY_MID = 0xFFD9D1C2;
|
||||
private static final int BODY_LIGHT = 0xFFFFFAF0;
|
||||
private static final int BUTTON = 0xFFC9C1B3;
|
||||
private static final int SCREEN = 0xFF0A0D0C;
|
||||
private static final int SCREEN_MID = 0xFF121614;
|
||||
private static final int GRID = 0x66000000;
|
||||
|
||||
private GenerateGuiTextures() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Files.createDirectories(OUT);
|
||||
write("device_panel.png", devicePanel());
|
||||
write("screen_frame.png", screenFrame());
|
||||
write("bottom_panel.png", bottomPanel());
|
||||
write("button_square.png", button(24, 24));
|
||||
write("button_wide.png", button(34, 24));
|
||||
write("slider_well.png", sliderWell());
|
||||
write("slider_knob.png", sliderKnob());
|
||||
write("vent_slots.png", ventSlots());
|
||||
write("status_light.png", statusLight());
|
||||
write("icon_menu.png", iconMenu());
|
||||
write("icon_arrow_left.png", iconArrow(true));
|
||||
write("icon_arrow_right.png", iconArrow(false));
|
||||
write("selection_frame.png", selectionFrame());
|
||||
write("grid_overlay_9x9.png", gridOverlay());
|
||||
write("blocodex_wordmark.png", wordmark());
|
||||
write("_gui_texture_preview.png", preview());
|
||||
}
|
||||
|
||||
private static BufferedImage devicePanel() {
|
||||
BufferedImage image = image(32, 32);
|
||||
cutPanel(image, BODY_SHADOW, BODY, BODY_MID, BODY_LIGHT, DARK);
|
||||
rect(image, 8, 8, 24, 24, BODY_MID);
|
||||
line(image, 8, 9, 23, 9, 0x22FFFFFF);
|
||||
line(image, 8, 22, 23, 22, 0x18000000);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage screenFrame() {
|
||||
BufferedImage image = image(32, 32);
|
||||
rect(image, 2, 2, 30, 30, 0xFF33302A);
|
||||
rect(image, 4, 4, 28, 28, BODY_LIGHT);
|
||||
rect(image, 6, 6, 26, 26, BLACK);
|
||||
rect(image, 8, 8, 24, 24, SCREEN);
|
||||
rect(image, 10, 10, 22, 22, SCREEN_MID);
|
||||
line(image, 5, 4, 27, 4, 0xFFFFFFFF);
|
||||
line(image, 4, 5, 4, 27, 0xFFFFFFFF);
|
||||
line(image, 5, 27, 27, 27, DARK);
|
||||
line(image, 27, 5, 27, 27, DARK);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage bottomPanel() {
|
||||
BufferedImage image = image(32, 24);
|
||||
rect(image, 1, 1, 31, 23, 0xFF5A554D);
|
||||
rect(image, 2, 2, 30, 22, 0xFFFFFFFF);
|
||||
rect(image, 3, 3, 29, 21, 0xFFD8D0C2);
|
||||
rect(image, 5, 5, 27, 19, 0xFFDED6C8);
|
||||
line(image, 3, 21, 29, 21, 0xFF5A554D);
|
||||
line(image, 29, 3, 29, 21, 0xFF5A554D);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage button(int width, int height) {
|
||||
BufferedImage image = image(width, height);
|
||||
rect(image, 1, 1, width - 1, height - 1, 0xFF111111);
|
||||
rect(image, 2, 2, width - 2, height - 2, 0xFF4C4842);
|
||||
rect(image, 4, 4, width - 3, height - 3, BUTTON);
|
||||
rect(image, 5, 5, width - 5, height - 5, 0xFFD7D0C3);
|
||||
line(image, 3, 3, width - 3, 3, 0xFFFFFFFF);
|
||||
line(image, 3, 3, 3, height - 3, 0xFFFFFFFF);
|
||||
line(image, 3, height - 3, width - 3, height - 3, 0xFF191817);
|
||||
line(image, width - 3, 3, width - 3, height - 3, 0xFF191817);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage sliderWell() {
|
||||
BufferedImage image = image(20, 32);
|
||||
rect(image, 2, 1, 18, 31, DARK);
|
||||
rect(image, 4, 3, 16, 29, BODY_LIGHT);
|
||||
rect(image, 6, 5, 14, 27, BLACK);
|
||||
rect(image, 8, 7, 12, 25, SCREEN);
|
||||
rect(image, 9, 9, 11, 23, 0xFF060807);
|
||||
line(image, 5, 4, 15, 4, 0xFFFFFFFF);
|
||||
line(image, 5, 4, 5, 28, 0xFFFFFFFF);
|
||||
line(image, 5, 28, 15, 28, DARK);
|
||||
line(image, 15, 4, 15, 28, DARK);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage sliderKnob() {
|
||||
BufferedImage image = image(18, 12);
|
||||
rect(image, 1, 1, 17, 11, 0xFF151515);
|
||||
rect(image, 2, 2, 16, 10, BODY_LIGHT);
|
||||
rect(image, 4, 3, 15, 9, 0xFFE8E0D2);
|
||||
line(image, 2, 2, 15, 2, 0xFFFFFFFF);
|
||||
line(image, 2, 10, 16, 10, 0xFF4A453F);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage ventSlots() {
|
||||
BufferedImage image = image(96, 24);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int y = 3 + i * 4;
|
||||
rect(image, 0, y, 96, y + 2, 0xFF181817);
|
||||
line(image, 0, y + 2, 95, y + 2, 0xFFFFFFFF);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage statusLight() {
|
||||
BufferedImage image = image(12, 12);
|
||||
rect(image, 3, 2, 9, 10, 0xFF202020);
|
||||
rect(image, 2, 3, 10, 9, 0xFF202020);
|
||||
rect(image, 4, 4, 8, 8, 0xFFBFC7C9);
|
||||
set(image, 5, 5, 0xFFE7F0F0);
|
||||
set(image, 8, 8, 0xFF626B6B);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage iconMenu() {
|
||||
BufferedImage image = image(16, 16);
|
||||
for (int y : new int[]{4, 8, 12}) {
|
||||
rect(image, 3, y, 13, y + 2, DARK);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage iconArrow(boolean left) {
|
||||
BufferedImage image = image(16, 16);
|
||||
if (left) {
|
||||
rect(image, 6, 7, 13, 9, DARK);
|
||||
rect(image, 5, 6, 8, 10, DARK);
|
||||
rect(image, 4, 5, 7, 11, DARK);
|
||||
rect(image, 3, 4, 6, 12, DARK);
|
||||
} else {
|
||||
rect(image, 3, 7, 10, 9, DARK);
|
||||
rect(image, 8, 6, 11, 10, DARK);
|
||||
rect(image, 9, 5, 12, 11, DARK);
|
||||
rect(image, 10, 4, 13, 12, DARK);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage selectionFrame() {
|
||||
BufferedImage image = image(16, 16);
|
||||
line(image, 0, 0, 15, 0, 0xFFFFFFFF);
|
||||
line(image, 0, 0, 0, 15, 0xFFFFFFFF);
|
||||
line(image, 0, 15, 15, 15, 0xFF000000);
|
||||
line(image, 15, 0, 15, 15, 0xFF000000);
|
||||
line(image, 1, 1, 14, 1, 0xCCFFFFFF);
|
||||
line(image, 1, 1, 1, 14, 0xCCFFFFFF);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage gridOverlay() {
|
||||
BufferedImage image = image(144, 144);
|
||||
for (int i = 0; i <= 9; i++) {
|
||||
int p = Math.min(143, i * 16);
|
||||
line(image, p, 0, p, 143, GRID);
|
||||
line(image, 0, p, 143, p, GRID);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage wordmark() {
|
||||
BufferedImage image = image(80, 16);
|
||||
drawTinyText(image, "BLOCODEX", 0, 4, 0xFF111111);
|
||||
drawTinyText(image, "BLOCODEX", 1, 5, 0xFFFFFFFF);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage preview() {
|
||||
BufferedImage image = image(256, 160);
|
||||
rect(image, 0, 0, 256, 160, 0xFF2C2925);
|
||||
copy(image, devicePanel(), 8, 8);
|
||||
copy(image, screenFrame(), 50, 8);
|
||||
copy(image, bottomPanel(), 92, 8);
|
||||
copy(image, button(24, 24), 136, 8);
|
||||
copy(image, button(34, 24), 168, 8);
|
||||
copy(image, sliderWell(), 214, 6);
|
||||
copy(image, sliderKnob(), 215, 42);
|
||||
copy(image, ventSlots(), 8, 64);
|
||||
copy(image, statusLight(), 112, 66);
|
||||
copy(image, iconMenu(), 136, 64);
|
||||
copy(image, iconArrow(true), 160, 64);
|
||||
copy(image, iconArrow(false), 184, 64);
|
||||
copy(image, selectionFrame(), 212, 64);
|
||||
copy(image, wordmark(), 8, 104);
|
||||
copy(image, gridOverlay(), 104, 96, 72, 72);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static BufferedImage image(int width, int height) {
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
rect(image, 0, 0, width, height, TRANSPARENT);
|
||||
return image;
|
||||
}
|
||||
|
||||
private static void cutPanel(BufferedImage image, int shadow, int fill, int inner, int light, int dark) {
|
||||
rect(image, 2, 0, image.getWidth() - 2, image.getHeight(), dark);
|
||||
rect(image, 0, 2, image.getWidth(), image.getHeight() - 2, dark);
|
||||
rect(image, 3, 1, image.getWidth() - 3, image.getHeight() - 1, shadow);
|
||||
rect(image, 1, 3, image.getWidth() - 1, image.getHeight() - 3, shadow);
|
||||
rect(image, 4, 2, image.getWidth() - 4, image.getHeight() - 2, fill);
|
||||
rect(image, 2, 4, image.getWidth() - 2, image.getHeight() - 4, fill);
|
||||
rect(image, 6, 6, image.getWidth() - 6, image.getHeight() - 6, inner);
|
||||
line(image, 3, 2, image.getWidth() - 4, 2, light);
|
||||
line(image, 2, 3, 2, image.getHeight() - 4, light);
|
||||
line(image, 3, image.getHeight() - 3, image.getWidth() - 4, image.getHeight() - 3, shadow);
|
||||
line(image, image.getWidth() - 3, 3, image.getWidth() - 3, image.getHeight() - 4, shadow);
|
||||
}
|
||||
|
||||
private static void drawTinyText(BufferedImage image, String text, int x, int y, int color) {
|
||||
int cursor = x;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
drawGlyph(image, text.charAt(i), cursor, y, color);
|
||||
cursor += 6;
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawGlyph(BufferedImage image, char c, int x, int y, int color) {
|
||||
String[] glyph = switch (c) {
|
||||
case 'B' -> new String[]{"1110", "1001", "1110", "1001", "1110"};
|
||||
case 'L' -> new String[]{"1000", "1000", "1000", "1000", "1111"};
|
||||
case 'O' -> new String[]{"0110", "1001", "1001", "1001", "0110"};
|
||||
case 'C' -> new String[]{"0111", "1000", "1000", "1000", "0111"};
|
||||
case 'D' -> new String[]{"1110", "1001", "1001", "1001", "1110"};
|
||||
case 'E' -> new String[]{"1111", "1000", "1110", "1000", "1111"};
|
||||
case 'X' -> new String[]{"1001", "1001", "0110", "1001", "1001"};
|
||||
default -> new String[]{"0000", "0000", "0000", "0000", "0000"};
|
||||
};
|
||||
for (int row = 0; row < glyph.length; row++) {
|
||||
for (int col = 0; col < glyph[row].length(); col++) {
|
||||
if (glyph[row].charAt(col) == '1') {
|
||||
set(image, x + col, y + row, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy(BufferedImage target, BufferedImage source, int x, int y) {
|
||||
copy(target, source, x, y, source.getWidth(), source.getHeight());
|
||||
}
|
||||
|
||||
private static void copy(BufferedImage target, BufferedImage source, int x, int y, int width, int height) {
|
||||
for (int yy = 0; yy < height; yy++) {
|
||||
for (int xx = 0; xx < width; xx++) {
|
||||
int sx = xx * source.getWidth() / width;
|
||||
int sy = yy * source.getHeight() / height;
|
||||
set(target, x + xx, y + yy, source.getRGB(sx, sy));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void rect(BufferedImage image, int x1, int y1, int x2, int y2, int color) {
|
||||
for (int y = Math.max(0, y1); y < Math.min(image.getHeight(), y2); y++) {
|
||||
for (int x = Math.max(0, x1); x < Math.min(image.getWidth(), x2); x++) {
|
||||
set(image, x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void line(BufferedImage image, int x1, int y1, int x2, int y2, int color) {
|
||||
if (x1 == x2) {
|
||||
rect(image, x1, Math.min(y1, y2), x1 + 1, Math.max(y1, y2) + 1, color);
|
||||
return;
|
||||
}
|
||||
if (y1 == y2) {
|
||||
rect(image, Math.min(x1, x2), y1, Math.max(x1, x2) + 1, y1 + 1, color);
|
||||
}
|
||||
}
|
||||
|
||||
private static void set(BufferedImage image, int x, int y, int color) {
|
||||
if (x >= 0 && y >= 0 && x < image.getWidth() && y < image.getHeight()) {
|
||||
image.setRGB(x, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
private static void write(String name, BufferedImage image) throws IOException {
|
||||
ImageIO.write(image, "png", OUT.resolve(name).toFile());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user