From 3089bd2ea6a3952e3ea0f31d8fc5eca1864cefab Mon Sep 17 00:00:00 2001 From: yum Date: Sun, 1 Dec 2024 00:11:04 -0800 Subject: Add small programmable text display gimmick Use Third_Party/gen_atlas to create a 512x512 texture and put it in the texture slot (the resolution is hardcoded to 512 in shader). Use sliders to control the grid size. If desired, use global offset to make it possible to linearly animate between e.g. 0-9 and have it display as ASCII '0'-'9'. --- Third_Party/gen_atlas | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'Third_Party') diff --git a/Third_Party/gen_atlas b/Third_Party/gen_atlas index dfb0e61..b880ac8 100644 --- a/Third_Party/gen_atlas +++ b/Third_Party/gen_atlas @@ -10,7 +10,7 @@ from PIL import Image CHAR_RANGES = [ (32, 126), # Printable ASCII # Add more ranges here as needed, e.g.: - # (160, 255), # Extended Latin + (160, 255), # Extended Latin ] def calculate_grid_size(char_ranges): @@ -32,21 +32,18 @@ def generate_atlas(font_path, resolution, draw_grid=False): cmd = [ "msdf-atlas-gen/build/bin/Debug/msdf-atlas-gen.exe", "-font", font_path, - "-type", "mtsdf", + "-type", "msdf", "-format", "png", "-imageout", "atlas.png", - "-json", "atlas.json", - "-size", "32", + "-size", "28", "-pxrange", "2", "-dimensions", str(resolution), str(resolution), "-chars", chars_str, "-uniformgrid", "-uniformcols", str(grid_size), "-uniformcell", str(cell_size), str(cell_size), - "-uniformorigin", "on", - "-coloringstrategy", "inktrap", +# "-uniformorigin", "on", "-errorcorrection", "auto", - "-miterlimit", "1.0", "-scanline" ] @@ -89,7 +86,7 @@ def draw_grid_lines(image, resolution): def rearrange_atlas(resolution, cell_width, cell_height, draw_grid=False): """Rearrange the atlas to include gaps for non-printable characters""" original = Image.open("atlas.png") - new_atlas = Image.new('RGBA', (resolution, resolution), (0, 0, 0, 255)) + new_atlas = Image.new('RGB', (resolution, resolution), (0, 0, 0)) grid_size = calculate_grid_size(CHAR_RANGES) cell_size = resolution // grid_size -- cgit v1.2.3