core: rename script folder to tools
This commit is contained in:
37
tools/icon_maker.py
Normal file
37
tools/icon_maker.py
Normal file
@ -0,0 +1,37 @@
|
||||
from PIL import Image
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
if (len(sys.argv) < 2):
|
||||
print("Error: usage python icon_maker.py {img}")
|
||||
|
||||
image = Image.open(sys.argv[1])
|
||||
|
||||
width, height = image.size
|
||||
pixels = list(image.getdata())
|
||||
pixels = [r << 16 | g << 8 | b for r, g, b in pixels]
|
||||
|
||||
string = str(pixels).replace("(", "{").replace(")", "}").replace("[", "{").replace("]", "}")
|
||||
|
||||
filename: str = os.path.basename(sys.argv[1]).split(".")[0]
|
||||
|
||||
string = f"""\
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "icon.h"
|
||||
|
||||
uint32_t {filename}_color_map[{width} * {height}] = {string};
|
||||
|
||||
struct icon {filename}_icon = {{
|
||||
.height = {height},
|
||||
.width = {width},
|
||||
.pixels = {filename}_color_map
|
||||
}};
|
||||
|
||||
"""
|
||||
|
||||
with open(f"./headers/icons/{filename}.h", "w") as f:
|
||||
f.write(string)
|
Reference in New Issue
Block a user