- Makefile: alvos "appdir" (monta build/TinyBlocks.AppDir), "appimage"
(baixa o appimagetool e gera build/TinyBlocks-<ver>-x86_64.AppImage),
"run-appimage" e "icon".
- packaging/: tinyblocks.desktop, AppRun, tinyblocks.png (icone 256x256)
e make_icon.py (gera o icone sem dependencias externas).
- appdir:
* empacota o editor + SDL2/SDL2_ttf (com uma excludelist das libs do
sistema: glibc, X11/GL, som, dbus, systemd...);
* copia as libraries de extensao (.so + library.toml) para
usr/share/tinyblocks/libraries/<nome>/build;
- libman: tb_libman_scan_defaults agora tambem varre libraries ao lado do
executavel (usr/share/tinyblocks/libraries e usr/lib/...), de modo que o
AppImage acha suas extensoes mesmo rodando fora do repositorio.
Verificado: AppImage monta, abre o editor e carrega um .so empacotado
(TOML) pela tela "Escolha uma Extensao".
92 lines
2.9 KiB
Python
92 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Gera packaging/tinyblocks.png (icone 256x256 do editor TinyBlocks).
|
|
|
|
Sem dependencias: escreve o PNG direto com zlib + struct. Faz supersampling
|
|
4x para bordas suaves. Uso: python3 packaging/make_icon.py [saida.png]
|
|
"""
|
|
import struct, sys, zlib
|
|
|
|
S = 4 # supersampling
|
|
OUT = 256
|
|
W = OUT * S
|
|
|
|
def rrect(x, y, x0, y0, x1, y1, r):
|
|
if x < x0 or x > x1 or y < y0 or y > y1:
|
|
return False
|
|
cx = min(max(x, x0 + r), x1 - r)
|
|
cy = min(max(y, y0 + r), y1 - r)
|
|
dx, dy = x - cx, y - cy
|
|
return dx * dx + dy * dy <= r * r
|
|
|
|
def rect(x, y, x0, y0, x1, y1):
|
|
return x0 <= x <= x1 and y0 <= y <= y1
|
|
|
|
def tri_signed(px, py, ax, ay, bx, by, cx, cy):
|
|
return (px - bx) * (ay - by) - (ax - bx) * (py - by)
|
|
|
|
def in_tri(x, y, ax, ay, bx, by, cx, cy):
|
|
d1 = tri_signed(x, y, ax, ay, bx, by, cx, cy)
|
|
d2 = tri_signed(x, y, bx, by, cx, cy, ax, ay)
|
|
d3 = tri_signed(x, y, cx, cy, ax, ay, bx, by)
|
|
neg = (d1 < 0) or (d2 < 0) or (d3 < 0)
|
|
pos = (d1 > 0) or (d2 > 0) or (d3 > 0)
|
|
return not (neg and pos)
|
|
|
|
def px(x, y):
|
|
# coords em escala OUT (0..256)
|
|
X, Y = x / S, y / S
|
|
# fundo arredondado azul
|
|
if rrect(X, Y, 4, 4, 252, 252, 54):
|
|
c = (74, 144, 226)
|
|
else:
|
|
return (0, 0, 0, 0)
|
|
# brilho no topo
|
|
if Y < 128:
|
|
t = 1.0 - Y / 128.0
|
|
c = (int(c[0] + 40 * t), int(c[1] + 30 * t), int(c[2] + 20 * t))
|
|
# haste da bandeira
|
|
if rect(X, Y, 176, 44, 182, 124):
|
|
c = (240, 80, 80)
|
|
# triangulo verde
|
|
if in_tri(X, Y, 183, 44, 216, 58, 183, 74):
|
|
c = (76, 175, 80)
|
|
# corpo do bloco (branco)
|
|
if rrect(X, Y, 60, 108, 196, 200, 16):
|
|
c = (245, 247, 250)
|
|
# encaixe no topo do bloco
|
|
if rrect(X, Y, 106, 86, 150, 118, 9):
|
|
c = (245, 247, 250)
|
|
# "janela" escura no bloco
|
|
if rrect(X, Y, 80, 130, 176, 150, 6):
|
|
c = (74, 144, 226)
|
|
return (c[0], c[1], c[2], 255)
|
|
|
|
def main():
|
|
out = sys.argv[1] if len(sys.argv) > 1 else "packaging/tinyblocks.png"
|
|
buf = bytearray()
|
|
for oy in range(OUT):
|
|
buf.append(0) # filtro 0 por scanline
|
|
for ox in range(OUT):
|
|
r = g = b = a = 0
|
|
for dy in range(S):
|
|
for dx in range(S):
|
|
p = px(ox * S + dx, oy * S + dy)
|
|
r += p[0]; g += p[1]; b += p[2]; a += p[3]
|
|
n = S * S
|
|
buf += bytes((r // n, g // n, b // n, a // n))
|
|
|
|
def chunk(tag, data):
|
|
return (struct.pack(">I", len(data)) + tag + data +
|
|
struct.pack(">I", zlib.crc32(tag + data) & 0xffffffff))
|
|
|
|
png = b"\x89PNG\r\n\x1a\n"
|
|
png += chunk(b"IHDR", struct.pack(">IIBBBBB", OUT, OUT, 8, 6, 0, 0, 0))
|
|
png += chunk(b"IDAT", zlib.compress(bytes(buf), 9))
|
|
png += chunk(b"IEND", b"")
|
|
with open(out, "wb") as f:
|
|
f.write(png)
|
|
print("icone escrito:", out)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|