Initial commit.

This commit is contained in:
Signal 2026-02-14 12:36:36 -05:00
commit b5c753ff4d
129 changed files with 4472 additions and 0 deletions

View file

@ -0,0 +1,61 @@
from PIL import Image
def adjust_font_atlas(input_path, output_path, current_width, current_height, new_width, new_height):
"""
Adjusts the cell dimensions of a pixel font atlas sprite sheet by creating larger cells
and placing the original sprites in the top-left corner of each new cell, filling
the extra space with the background color detected from the top-left pixel of the
original image. This allows for manual extension of sprites without repositioning them.
Args:
input_path (str): Path to the input atlas image.
output_path (str): Path to save the output atlas image.
current_width (int): Current width of each cell (in pixels).
current_height (int): Current height of each cell (in pixels).
new_width (int): New larger width for each cell (in pixels).
new_height (int): New larger height for each cell (in pixels).
"""
if new_width < current_width or new_height < current_height:
raise ValueError("New dimensions must be larger than the current dimensions.")
img = Image.open(input_path)
width, height = img.size
if width % current_width != 0 or height % current_height != 0:
raise ValueError("Image dimensions are not multiples of the current cell dimensions.")
cols = width // current_width
rows = height // current_height
# Create a new image with the same mode
new_img = Image.new(img.mode, (cols * new_width, rows * new_height))
# Detect background color from top-left pixel (assuming it's background)
bg_color = img.getpixel((0, 0))
# Fill the new image with the background color
new_img.paste(bg_color, (0, 0, new_img.width, new_img.height))
# Copy each original sprite into the top-left of its new larger cell
for r in range(rows):
for c in range(cols):
# Crop the original sprite
left = c * current_width
top = r * current_height
right = left + current_width
bottom = top + current_height
sprite = img.crop((left, top, right, bottom))
# Paste into new position
new_left = c * new_width
new_top = r * new_height
new_img.paste(sprite, (new_left, new_top))
# Save the new atlas
new_img.save(output_path)
# Example usage:
base_path = "/Users/iboettcher/eclipse-workspace/firefly/mods/firefly_font/fonts/"
adjust_font_atlas(f'{base_path}firefly_normal.png',
f'{base_path}firefly_wide.png', 8, 17, 17, 17)

View file

@ -0,0 +1,20 @@
{
"A": {
"width": 7,
"height": 10,
"base": 0,
"advance": 2
},
"B": {
"width": 7,
"height": 10,
"base": 0,
"advance": 2
},
"C": {
"width": 7,
"height": 10,
"base": 0,
"advance": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.