test / test (push) Successful in 1m59s
- Layer rows can name a floor cover, soft pockets and a sea row. The underworld uses ash for both, and every cave cell at or below WORLD_BOTTOM + 28 is lava: a sea that is held in on every side, so it doesn't flow when woken. - Emberite ore in basalt (about 1.5% of the layer): glows, group level 4, so no current pickaxe (maxlevel 3) digs it. It waits for the top pre-hard-mode pickaxe in v0.5. - Ruined towers move to the structure framework (#24). Tests: 3 new cases in tests/underworld.lua (emberite tool gate, the lava sea, ash floors/pockets and ore share); the layer tests accept the underworld's ash. 109/109 pass, no ERROR lines. Closes #25 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
629 lines
21 KiB
Python
629 lines
21 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate Strata's placeholder pixel-art textures.
|
|
|
|
Deterministic: the same script always produces the same PNGs, so the
|
|
generated files can be committed and regenerated at will. Real art is
|
|
tracked on the roadmap; these are programmer-art placeholders.
|
|
|
|
Usage: python3 tools/gen_textures.py (run from the repository root)
|
|
"""
|
|
import os
|
|
import random
|
|
|
|
from PIL import Image
|
|
|
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
MODS = os.path.join(ROOT, "mods")
|
|
|
|
|
|
def out(mod, name, img):
|
|
path = os.path.join(MODS, mod, "textures", name)
|
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
img.save(path)
|
|
|
|
|
|
def clamp(v):
|
|
return max(0, min(255, int(v)))
|
|
|
|
|
|
def shade(rgb, f):
|
|
return tuple(clamp(c * f) for c in rgb[:3])
|
|
|
|
|
|
def noisy(base, var, seed, size=(16, 16)):
|
|
rng = random.Random(seed)
|
|
img = Image.new("RGBA", size)
|
|
for y in range(size[1]):
|
|
for x in range(size[0]):
|
|
f = 1 + rng.uniform(-var, var)
|
|
img.putpixel((x, y), shade(base, f) + (255,))
|
|
return img
|
|
|
|
|
|
def speckle(img, color, count, seed, cluster=2):
|
|
rng = random.Random(seed)
|
|
w, h = img.size
|
|
for _ in range(count):
|
|
cx, cy = rng.randrange(1, w - 1), rng.randrange(1, h - 1)
|
|
for _ in range(cluster * 2):
|
|
x = clamp(cx + rng.randint(-1, 1))
|
|
y = clamp(cy + rng.randint(-1, 1))
|
|
if x < w and y < h:
|
|
img.putpixel((x, y), shade(color, rng.uniform(0.85, 1.15)) + (255,))
|
|
return img
|
|
|
|
|
|
def border(img, f=0.7):
|
|
w, h = img.size
|
|
for x in range(w):
|
|
for y in (0, h - 1):
|
|
img.putpixel((x, y), shade(img.getpixel((x, y)), f) + (255,))
|
|
for y in range(h):
|
|
for x in (0, w - 1):
|
|
img.putpixel((x, y), shade(img.getpixel((x, y)), f) + (255,))
|
|
return img
|
|
|
|
|
|
def darken(img, f):
|
|
res = img.copy()
|
|
for y in range(img.size[1]):
|
|
for x in range(img.size[0]):
|
|
p = img.getpixel((x, y))
|
|
res.putpixel((x, y), shade(p, f) + (p[3],))
|
|
return res
|
|
|
|
|
|
def line(img, p0, p1, color):
|
|
(x0, y0), (x1, y1) = p0, p1
|
|
n = max(abs(x1 - x0), abs(y1 - y0))
|
|
for i in range(n + 1):
|
|
t = i / n if n else 0
|
|
img.putpixel((round(x0 + (x1 - x0) * t), round(y0 + (y1 - y0) * t)), color)
|
|
|
|
|
|
def rect(img, x0, y0, x1, y1, color):
|
|
for y in range(y0, y1 + 1):
|
|
for x in range(x0, x1 + 1):
|
|
img.putpixel((x, y), color)
|
|
|
|
|
|
DIRT = (134, 96, 67)
|
|
STONE = (125, 125, 130)
|
|
SAND = (219, 201, 140)
|
|
SLATE = (84, 96, 122)
|
|
BASALT = (74, 52, 50)
|
|
BEDROCK = (48, 46, 52)
|
|
WOOD = (168, 120, 72)
|
|
TRUNK = (110, 78, 48)
|
|
GRASS = (92, 170, 60)
|
|
COPPER = (205, 120, 60)
|
|
IRON = (190, 175, 160)
|
|
HANDLE = (120, 82, 45)
|
|
SNOW = (232, 240, 248)
|
|
ICE = (150, 200, 235)
|
|
SANDSTONE = (196, 160, 104)
|
|
MUD = (88, 64, 58)
|
|
JUNGLE_GRASS = (54, 150, 72)
|
|
FROSTPINE = (78, 62, 52)
|
|
NEEDLES = (44, 96, 80)
|
|
REDHEART = (128, 52, 40)
|
|
REDHEART_LEAVES = (70, 160, 40)
|
|
|
|
|
|
def terrain():
|
|
m = "strata_core"
|
|
dirt = noisy(DIRT, 0.12, 1)
|
|
out(m, "strata_dirt.png", dirt)
|
|
|
|
grass = dirt.copy()
|
|
rng = random.Random(2)
|
|
for x in range(16):
|
|
depth = rng.choice([2, 3, 3, 4])
|
|
for y in range(depth):
|
|
grass.putpixel((x, y), shade(GRASS, rng.uniform(0.85, 1.15)) + (255,))
|
|
out(m, "strata_grass.png", grass)
|
|
out(m, "strata_grass_top.png", noisy(GRASS, 0.12, 3))
|
|
|
|
stone = noisy(STONE, 0.10, 4)
|
|
speckle(stone, shade(STONE, 0.7), 6, 5, 1)
|
|
out(m, "strata_stone.png", stone)
|
|
out(m, "strata_sand.png", noisy(SAND, 0.07, 6))
|
|
|
|
planks = noisy(WOOD, 0.08, 7)
|
|
for y in (3, 7, 11, 15):
|
|
for x in range(16):
|
|
planks.putpixel((x, y), shade(WOOD, 0.6) + (255,))
|
|
for (x, y0) in ((5, 0), (12, 4), (3, 8), (10, 12)):
|
|
for y in range(y0, y0 + 3):
|
|
planks.putpixel((x, y), shade(WOOD, 0.6) + (255,))
|
|
out(m, "strata_wood.png", planks)
|
|
|
|
trunk = noisy(TRUNK, 0.08, 8)
|
|
for x in (2, 6, 11, 14):
|
|
for y in range(16):
|
|
trunk.putpixel((x, y), shade(TRUNK, 0.7) + (255,))
|
|
out(m, "strata_tree.png", trunk)
|
|
|
|
rng = random.Random(9)
|
|
leaves = Image.new("RGBA", (16, 16))
|
|
for y in range(16):
|
|
for x in range(16):
|
|
if rng.random() < 0.82:
|
|
leaves.putpixel((x, y), shade((60, 140, 50), rng.uniform(0.7, 1.2)) + (255,))
|
|
out(m, "strata_leaves.png", leaves)
|
|
|
|
out(m, "strata_copper_ore.png", speckle(stone.copy(), COPPER, 5, 10))
|
|
out(m, "strata_iron_ore.png", speckle(stone.copy(), IRON, 5, 11))
|
|
|
|
# deeper layers
|
|
slate = noisy(SLATE, 0.08, 21)
|
|
for y in (4, 9, 13):
|
|
for x in range(16):
|
|
if (x + y) % 5:
|
|
slate.putpixel((x, y), shade(SLATE, 0.78) + (255,))
|
|
out(m, "strata_slate.png", slate)
|
|
basalt = noisy(BASALT, 0.14, 22)
|
|
speckle(basalt, shade(BASALT, 1.9), 5, 23, 1)
|
|
out(m, "strata_basalt.png", basalt)
|
|
bedrock = noisy(BEDROCK, 0.3, 24)
|
|
speckle(bedrock, shade(BEDROCK, 0.4), 8, 25, 2)
|
|
out(m, "strata_bedrock.png", bedrock)
|
|
out(m, "strata_slate_copper_ore.png", speckle(slate.copy(), COPPER, 5, 10))
|
|
out(m, "strata_slate_iron_ore.png", speckle(slate.copy(), IRON, 5, 11))
|
|
out(m, "strata_wall_slate.png", border(darken(slate, 0.5), 0.8))
|
|
out(m, "strata_wall_basalt.png", border(darken(basalt, 0.55), 0.8))
|
|
|
|
biomes(dirt)
|
|
|
|
# background walls: darker, framed
|
|
out(m, "strata_wall_dirt.png", border(darken(dirt, 0.5), 0.8))
|
|
out(m, "strata_wall_stone.png", border(darken(stone, 0.5), 0.8))
|
|
out(m, "strata_wall_wood.png", border(darken(planks, 0.5), 0.8))
|
|
|
|
torch = Image.new("RGBA", (16, 16))
|
|
rect(torch, 7, 7, 8, 15, HANDLE + (255,))
|
|
rect(torch, 6, 3, 9, 6, (255, 170, 40, 255))
|
|
rect(torch, 7, 1, 8, 4, (255, 240, 120, 255))
|
|
out(m, "strata_torch.png", torch)
|
|
|
|
# wall-mounted torch: handle leans out to the right from a block on the
|
|
# left (mirrored in Lua for the other side)
|
|
wtorch = Image.new("RGBA", (16, 16))
|
|
for i in range(6):
|
|
rect(wtorch, 1 + i, 13 - i, 2 + i, 13 - i, HANDLE + (255,))
|
|
rect(wtorch, 6, 4, 9, 7, (255, 170, 40, 255))
|
|
rect(wtorch, 7, 2, 8, 5, (255, 240, 120, 255))
|
|
out(m, "strata_torch_wall.png", wtorch)
|
|
|
|
furnace = noisy(STONE, 0.06, 12)
|
|
for y in (4, 8, 12):
|
|
for x in range(16):
|
|
furnace.putpixel((x, y), shade(STONE, 0.6) + (255,))
|
|
furnace = border(furnace, 0.6)
|
|
out(m, "strata_furnace.png", furnace)
|
|
front = furnace.copy()
|
|
rect(front, 5, 8, 10, 13, (40, 20, 10, 255))
|
|
rect(front, 6, 10, 9, 13, (255, 140, 30, 255))
|
|
out(m, "strata_furnace_front.png", front)
|
|
|
|
out(m, "strata_workbench.png", border(planks.copy(), 0.6))
|
|
out(m, "strata_anvil.png", border(noisy((70, 70, 78), 0.08, 13), 0.7))
|
|
|
|
|
|
def building():
|
|
m = "strata_core"
|
|
planks = Image.open(os.path.join(MODS, m, "textures", "strata_wood.png")).convert("RGBA")
|
|
|
|
# platform: a 3 px plank strip along the top with two little brackets
|
|
plat = Image.new("RGBA", (16, 16))
|
|
for y in range(3):
|
|
for x in range(16):
|
|
plat.putpixel((x, y), planks.getpixel((x, y + 4)))
|
|
for x in range(16):
|
|
plat.putpixel((x, 2), shade(WOOD, 0.6) + (255,))
|
|
out(m, "strata_platform_wood.png", plat)
|
|
|
|
|
|
def furniture():
|
|
m = "strata_core"
|
|
planks = Image.open(os.path.join(MODS, m, "textures", "strata_wood.png")).convert("RGBA")
|
|
|
|
# door: three cells, framed planks, a handle in the middle cell
|
|
frame = shade(WOOD, 0.55) + (255,)
|
|
door_full = Image.new("RGBA", (16, 48))
|
|
for y in range(48):
|
|
for x in range(16):
|
|
door_full.putpixel((x, y), planks.getpixel((x, y % 16)))
|
|
for y in range(48):
|
|
for x in (0, 1, 14, 15):
|
|
door_full.putpixel((x, y), frame)
|
|
for x in range(16):
|
|
for y in (0, 1, 23, 46, 47):
|
|
door_full.putpixel((x, y), frame)
|
|
rect(door_full, 11, 22, 12, 25, (60, 60, 66, 255))
|
|
for i, seg in enumerate(("top", "middle", "bottom")):
|
|
out(m, "strata_door_wood_%s.png" % seg, door_full.crop((0, i * 16, 16, i * 16 + 16)))
|
|
item = Image.new("RGBA", (16, 16))
|
|
small = door_full.resize((6, 16), Image.NEAREST)
|
|
item.paste(small, (5, 0))
|
|
out(m, "strata_door_wood_item.png", item)
|
|
|
|
# chest: planks with an iron band and lock on the front
|
|
band = (90, 90, 98, 255)
|
|
side = border(planks.copy(), 0.6)
|
|
for x in range(16):
|
|
side.putpixel((x, 6), band)
|
|
side.putpixel((x, 7), band)
|
|
out(m, "strata_chest_side.png", side)
|
|
out(m, "strata_chest_top.png", border(planks.copy(), 0.6))
|
|
front = side.copy()
|
|
rect(front, 6, 5, 9, 9, (200, 180, 90, 255))
|
|
rect(front, 7, 7, 8, 8, (40, 30, 20, 255))
|
|
out(m, "strata_chest_front.png", front)
|
|
|
|
|
|
def items():
|
|
m = "strata_core"
|
|
gel = Image.new("RGBA", (16, 16))
|
|
for y in range(16):
|
|
for x in range(16):
|
|
dx, dy = x - 7.5, y - 9
|
|
if dx * dx + dy * dy * 1.3 < 30 and not (y < 5 and abs(dx) > 7 - y):
|
|
gel.putpixel((x, y), (80, 150, 255, 220))
|
|
rect(gel, 5, 7, 6, 8, (200, 230, 255, 255))
|
|
out(m, "strata_gel.png", gel)
|
|
|
|
for name, col in (("copper", COPPER), ("iron", IRON)):
|
|
bar = Image.new("RGBA", (16, 16))
|
|
rect(bar, 2, 7, 13, 11, shade(col, 0.8) + (255,))
|
|
rect(bar, 4, 5, 11, 7, shade(col, 1.15) + (255,))
|
|
out(m, "strata_%s_bar.png" % name, bar)
|
|
|
|
for name, col in (("wood", WOOD), ("copper", COPPER), ("iron", IRON)):
|
|
c = col + (255,)
|
|
dark = shade(col, 0.7) + (255,)
|
|
h = HANDLE + (255,)
|
|
|
|
pick = Image.new("RGBA", (16, 16))
|
|
line(pick, (3, 14), (11, 4), h)
|
|
line(pick, (4, 2), (9, 1), c)
|
|
line(pick, (9, 1), (13, 3), c)
|
|
line(pick, (13, 3), (14, 7), c)
|
|
line(pick, (4, 3), (8, 2), dark)
|
|
out(m, "strata_%s_pickaxe.png" % name, pick)
|
|
|
|
axe = Image.new("RGBA", (16, 16))
|
|
line(axe, (3, 14), (11, 4), h)
|
|
rect(axe, 9, 1, 13, 5, c)
|
|
rect(axe, 12, 2, 14, 7, dark)
|
|
out(m, "strata_%s_axe.png" % name, axe)
|
|
|
|
ham = Image.new("RGBA", (16, 16))
|
|
line(ham, (3, 14), (10, 5), h)
|
|
rect(ham, 7, 1, 14, 5, c)
|
|
rect(ham, 7, 4, 14, 5, dark)
|
|
out(m, "strata_%s_hammer.png" % name, ham)
|
|
|
|
sword = Image.new("RGBA", (16, 16))
|
|
line(sword, (5, 10), (14, 1), c)
|
|
line(sword, (6, 10), (14, 2), dark)
|
|
line(sword, (3, 8), (7, 12), (90, 90, 90, 255))
|
|
line(sword, (2, 13), (5, 10), h)
|
|
out(m, "strata_%s_sword.png" % name, sword)
|
|
|
|
short = Image.new("RGBA", (16, 16))
|
|
line(short, (7, 8), (12, 3), c)
|
|
line(short, (5, 7), (8, 10), (90, 90, 90, 255))
|
|
line(short, (3, 12), (6, 9), h)
|
|
out(m, "strata_%s_shortsword.png" % name, short)
|
|
|
|
hand = noisy((230, 180, 140), 0.04, 14)
|
|
out(m, "strata_hand.png", hand)
|
|
|
|
|
|
# Avatar sprite sheet: 16x32 frames in one row, facing right. The order
|
|
# must match the FRAME_* constants in mods/strata_player/appearance.lua.
|
|
PLAYER_FRAMES = [
|
|
# (name, back leg dx, front leg dx, leg lift, arm pose)
|
|
("idle", 0, 0, 0, "down"),
|
|
("walk1", -2, 2, 0, "back"),
|
|
("walk2", -1, 1, 1, "down"),
|
|
("walk3", 2, -2, 0, "front"),
|
|
("walk4", 1, -1, 1, "down"),
|
|
("jump", -2, 2, 2, "up"),
|
|
("fall", -1, 1, 0, "out"),
|
|
("swing1", 0, 1, 0, "raised"),
|
|
("swing2", 0, 1, 0, "forward"),
|
|
]
|
|
|
|
|
|
def player_frame(back_dx, front_dx, lift, arm):
|
|
p = Image.new("RGBA", (16, 32))
|
|
skin = (230, 180, 140, 255)
|
|
hair = (90, 55, 30, 255)
|
|
shirt = (60, 110, 200, 255)
|
|
sleeve = shade(shirt, 0.8) + (255,)
|
|
pants = (70, 60, 50, 255)
|
|
shoe = (40, 30, 25, 255)
|
|
# legs: back leg darker, drawn first
|
|
bx, fx = 5 + back_dx, 8 + front_dx
|
|
rect(p, bx, 20, bx + 2, 28 - lift, shade(pants, 0.7) + (255,))
|
|
rect(p, bx, 29 - lift, bx + 2, 30 - lift, shade(shoe, 0.8) + (255,))
|
|
rect(p, fx, 20, fx + 2, 28 - lift, pants)
|
|
rect(p, fx, 29 - lift, fx + 3, 30 - lift, shoe)
|
|
rect(p, 5, 20, 10, 21, pants) # hips
|
|
rect(p, 4, 2, 11, 9, skin) # head
|
|
rect(p, 4, 1, 11, 3, hair)
|
|
rect(p, 4, 1, 6, 7, hair)
|
|
rect(p, 9, 5, 9, 6, (30, 30, 60, 255)) # eye
|
|
rect(p, 4, 10, 11, 19, shirt) # torso
|
|
# arm (shoulder at about (9, 12)), hand drawn last
|
|
if arm == "down":
|
|
rect(p, 8, 12, 10, 19, sleeve)
|
|
rect(p, 8, 20, 10, 21, skin)
|
|
elif arm == "back":
|
|
line(p, (8, 12), (6, 18), sleeve)
|
|
line(p, (9, 12), (7, 18), sleeve)
|
|
rect(p, 5, 19, 7, 20, skin)
|
|
elif arm == "front":
|
|
line(p, (9, 12), (11, 18), sleeve)
|
|
line(p, (10, 12), (12, 18), sleeve)
|
|
rect(p, 11, 19, 13, 20, skin)
|
|
elif arm == "up":
|
|
line(p, (10, 12), (13, 9), sleeve)
|
|
line(p, (10, 13), (13, 10), sleeve)
|
|
rect(p, 14, 8, 15, 9, skin)
|
|
elif arm == "out":
|
|
rect(p, 10, 11, 14, 13, sleeve)
|
|
rect(p, 14, 11, 15, 13, skin)
|
|
elif arm == "raised":
|
|
rect(p, 9, 2, 11, 11, sleeve)
|
|
rect(p, 9, 0, 11, 1, skin)
|
|
elif arm == "forward":
|
|
rect(p, 10, 13, 14, 15, sleeve)
|
|
rect(p, 14, 13, 15, 15, skin)
|
|
return p
|
|
|
|
|
|
def characters():
|
|
sheet = Image.new("RGBA", (16 * len(PLAYER_FRAMES), 32))
|
|
for i, (_, back_dx, front_dx, lift, arm) in enumerate(PLAYER_FRAMES):
|
|
sheet.paste(player_frame(back_dx, front_dx, lift, arm), (16 * i, 0))
|
|
out("strata_player", "strata_player_sheet.png", sheet)
|
|
|
|
s = Image.new("RGBA", (16, 12))
|
|
for y in range(12):
|
|
for x in range(16):
|
|
dx, dy = (x - 7.5) / 8, (y - 11) / 11
|
|
if dx * dx + dy * dy < 1:
|
|
s.putpixel((x, y), (70, 200, 80, 200))
|
|
rect(s, 5, 5, 5, 6, (10, 40, 10, 255))
|
|
rect(s, 10, 5, 10, 6, (10, 40, 10, 255))
|
|
rect(s, 3, 3, 4, 4, (200, 255, 200, 230))
|
|
out("strata_mobs", "strata_slime.png", s)
|
|
|
|
|
|
def leafy(color, seed, fill=0.82):
|
|
rng = random.Random(seed)
|
|
img = Image.new("RGBA", (16, 16))
|
|
for y in range(16):
|
|
for x in range(16):
|
|
if rng.random() < fill:
|
|
img.putpixel((x, y), shade(color, rng.uniform(0.7, 1.2)) + (255,))
|
|
return img
|
|
|
|
|
|
def bark(color, seed, lines):
|
|
img = noisy(color, 0.08, seed)
|
|
for x in lines:
|
|
for y in range(16):
|
|
img.putpixel((x, y), shade(color, 0.7) + (255,))
|
|
return img
|
|
|
|
|
|
def biomes(dirt):
|
|
"""Snow, desert and jungle biome blocks, trees and walls (#21)."""
|
|
m = "strata_core"
|
|
snow = noisy(SNOW, 0.04, 31)
|
|
speckle(snow, shade(SNOW, 0.88), 4, 32, 1)
|
|
out(m, "strata_snow.png", snow)
|
|
ice = noisy(ICE, 0.05, 33)
|
|
for i in range(4, 13): # a glint
|
|
ice.putpixel((i, 15 - i), shade(ICE, 1.35) + (255,))
|
|
out(m, "strata_ice.png", ice)
|
|
sandstone = noisy(SANDSTONE, 0.06, 34)
|
|
for y in (5, 11):
|
|
for x in range(16):
|
|
sandstone.putpixel((x, y), shade(SANDSTONE, 0.8) + (255,))
|
|
out(m, "strata_sandstone.png", sandstone)
|
|
mud = noisy(MUD, 0.14, 35)
|
|
speckle(mud, shade(MUD, 0.7), 5, 36, 2)
|
|
out(m, "strata_mud.png", mud)
|
|
|
|
jgrass = mud.copy()
|
|
rng = random.Random(37)
|
|
for x in range(16):
|
|
for y in range(rng.choice([3, 4, 4, 5])):
|
|
jgrass.putpixel((x, y), shade(JUNGLE_GRASS, rng.uniform(0.8, 1.15)) + (255,))
|
|
out(m, "strata_jungle_grass.png", jgrass)
|
|
out(m, "strata_jungle_grass_top.png", noisy(JUNGLE_GRASS, 0.14, 38))
|
|
|
|
out(m, "strata_frostpine_tree.png", bark(FROSTPINE, 39, (3, 8, 12)))
|
|
out(m, "strata_frostpine_needles.png", leafy(NEEDLES, 40, 0.88))
|
|
out(m, "strata_redheart_tree.png", bark(REDHEART, 41, (1, 5, 9, 13)))
|
|
out(m, "strata_redheart_leaves.png", leafy(REDHEART_LEAVES, 42, 0.86))
|
|
|
|
out(m, "strata_wall_snow.png", border(darken(snow, 0.62), 0.8))
|
|
out(m, "strata_wall_ice.png", border(darken(ice, 0.5), 0.8))
|
|
out(m, "strata_wall_sandstone.png", border(darken(sandstone, 0.5), 0.8))
|
|
out(m, "strata_wall_mud.png", border(darken(mud, 0.55), 0.8))
|
|
|
|
|
|
WATER = (52, 110, 220)
|
|
LAVA = (240, 96, 24)
|
|
ASHGLASS = (40, 30, 52)
|
|
|
|
|
|
def liquids():
|
|
m = "strata_core"
|
|
rng = random.Random(41)
|
|
water = Image.new("RGBA", (16, 16))
|
|
for y in range(16):
|
|
for x in range(16):
|
|
f = 1 + rng.uniform(-0.06, 0.06) + (0.25 if y == 0 else 0)
|
|
water.putpixel((x, y), shade(WATER, f) + (170,))
|
|
out(m, "strata_water.png", water)
|
|
|
|
lava = noisy(LAVA, 0.1, 42)
|
|
speckle(lava, (255, 200, 60), 6, 43)
|
|
speckle(lava, (170, 40, 10), 5, 44)
|
|
out(m, "strata_lava.png", lava)
|
|
|
|
glass = noisy(ASHGLASS, 0.15, 45)
|
|
speckle(glass, (120, 90, 160), 4, 46, cluster=1)
|
|
out(m, "strata_ashglass.png", border(glass, 0.75))
|
|
|
|
for name, fill in (("bucket", None), ("bucket_water", WATER), ("bucket_lava", LAVA)):
|
|
b = Image.new("RGBA", (16, 16))
|
|
metal = IRON + (255,)
|
|
dark = shade(IRON, 0.65) + (255,)
|
|
for y in range(5, 15):
|
|
inset = (y - 5) // 4
|
|
for x in range(3 + inset, 13 - inset):
|
|
b.putpixel((x, y), dark if x in (3 + inset, 12 - inset) or y == 14 else metal)
|
|
if fill:
|
|
rect(b, 4, 5, 11, 6, shade(fill, 1.1) + (255,))
|
|
line(b, (3, 5), (5, 1), dark)
|
|
line(b, (5, 1), (10, 1), dark)
|
|
line(b, (10, 1), (12, 5), dark)
|
|
out(m, "strata_%s.png" % name, b)
|
|
|
|
bubble = Image.new("RGBA", (16, 16))
|
|
for y in range(16):
|
|
for x in range(16):
|
|
d = (x - 7.5) ** 2 + (y - 7.5) ** 2
|
|
if d < 42:
|
|
a = 255 if d > 28 else 110
|
|
bubble.putpixel((x, y), (190, 225, 255, a))
|
|
rect(bubble, 4, 4, 5, 5, (255, 255, 255, 255))
|
|
out("strata_player", "strata_bubble.png", bubble)
|
|
|
|
|
|
MYCEL = (150, 110, 190)
|
|
SILT = (110, 112, 96)
|
|
GLIMMER = (120, 235, 210)
|
|
PRISM = (190, 150, 255)
|
|
DRIPVINE = (90, 200, 150)
|
|
UMBREL_STALK = (214, 204, 180)
|
|
UMBREL_CAP = (92, 168, 220)
|
|
|
|
|
|
def caverns():
|
|
"""Cavern biome floors, flora and the umbrel mushroom (#70)."""
|
|
m = "strata_core"
|
|
slate = Image.open(os.path.join(MODS, m, "textures", "strata_slate.png")).convert("RGBA")
|
|
turf = slate.copy()
|
|
rng = random.Random(51)
|
|
for x in range(16):
|
|
for y in range(rng.choice([2, 3, 3, 4, 5])):
|
|
turf.putpixel((x, y), shade(MYCEL, rng.uniform(0.8, 1.2)) + (255,))
|
|
out(m, "strata_mycel_turf.png", turf)
|
|
top = noisy(MYCEL, 0.15, 52)
|
|
speckle(top, GLIMMER, 3, 53, 1)
|
|
out(m, "strata_mycel_turf_top.png", top)
|
|
silt = noisy(SILT, 0.08, 54)
|
|
for y in (4, 9, 13):
|
|
for x in range(16):
|
|
silt.putpixel((x, y), shade(SILT, 0.85) + (255,))
|
|
out(m, "strata_silt.png", silt)
|
|
|
|
# glimmercap: three small glowing mushrooms
|
|
cap = Image.new("RGBA", (16, 16))
|
|
for (cx, base, r) in ((4, 15, 2), (10, 15, 3), (13, 15, 1)):
|
|
stem_top = base - 2 - r
|
|
rect(cap, cx, stem_top, cx, base, shade(UMBREL_STALK, 0.9) + (255,))
|
|
for dx in range(-r, r + 1):
|
|
for dy in range(0, max(1, r)):
|
|
cap.putpixel((cx + dx, stem_top - dy), shade(GLIMMER, 1 - 0.1 * dy) + (255,))
|
|
out(m, "strata_glimmercap.png", cap)
|
|
|
|
# prism cluster: three crystals pointing up
|
|
prism = Image.new("RGBA", (16, 16))
|
|
for (cx, hgt, w) in ((5, 9, 1), (9, 14, 2), (12, 7, 1)):
|
|
for y in range(16 - hgt, 16):
|
|
half = min(w, (y - (16 - hgt)) // 2)
|
|
for dx in range(-half, half + 1):
|
|
f = 1.25 if dx == -half else (0.8 if dx == half else 1.0)
|
|
prism.putpixel((cx + dx, y), shade(PRISM, f) + (235,))
|
|
out(m, "strata_prism_cluster.png", prism)
|
|
|
|
# dripvine: a hanging strand with glowing beads
|
|
vine = Image.new("RGBA", (16, 16))
|
|
rng = random.Random(55)
|
|
for x0 in (5, 10):
|
|
x = x0
|
|
for y in range(16):
|
|
vine.putpixel((x, y), shade(DRIPVINE, rng.uniform(0.7, 0.9)) + (255,))
|
|
if y % 5 == 2:
|
|
vine.putpixel((x + 1, y), (200, 255, 230, 255))
|
|
if rng.random() < 0.2:
|
|
x = max(3, min(12, x + rng.choice([-1, 1])))
|
|
out(m, "strata_dripvine.png", vine)
|
|
|
|
out(m, "strata_umbrel_stalk.png", bark(UMBREL_STALK, 56, (4, 11)))
|
|
ucap = noisy(UMBREL_CAP, 0.1, 57)
|
|
speckle(ucap, (210, 240, 255), 4, 58, 1)
|
|
out(m, "strata_umbrel_cap.png", border(ucap, 0.8))
|
|
|
|
spore = Image.new("RGBA", (16, 16))
|
|
for y in range(16):
|
|
for x in range(16):
|
|
d = (x - 7.5) ** 2 + (y - 8.5) ** 2
|
|
if d < 20:
|
|
spore.putpixel((x, y), shade(GLIMMER, 1.1 - d / 40) + (255,))
|
|
out(m, "strata_glowspore.png", spore)
|
|
|
|
shard = Image.new("RGBA", (16, 16))
|
|
for y in range(2, 15):
|
|
half = min(y - 2, 14 - y) // 2
|
|
for dx in range(-half, half + 1):
|
|
f = 1.3 if dx == -half else (0.75 if dx == half else 1.0)
|
|
shard.putpixel((8 + dx, y), shade(PRISM, f) + (255,))
|
|
out(m, "strata_prism_shard.png", shard)
|
|
|
|
|
|
ASH = (96, 90, 88)
|
|
EMBER = (255, 110, 40)
|
|
|
|
|
|
def underworld():
|
|
"""Underworld ash and emberite ore (#25)."""
|
|
m = "strata_core"
|
|
ash = noisy(ASH, 0.12, 61)
|
|
speckle(ash, shade(ASH, 1.35), 5, 62, 1)
|
|
speckle(ash, shade(ASH, 0.65), 4, 63, 1)
|
|
out(m, "strata_ash.png", ash)
|
|
basalt = Image.open(os.path.join(MODS, m, "textures", "strata_basalt.png")).convert("RGBA")
|
|
ore = basalt.copy()
|
|
speckle(ore, EMBER, 5, 64, 2)
|
|
speckle(ore, (255, 220, 120), 3, 65, 1)
|
|
out(m, "strata_emberite_ore.png", ore)
|
|
|
|
|
|
def menu():
|
|
g = Image.open(os.path.join(MODS, "strata_core", "textures", "strata_grass.png"))
|
|
g.resize((128, 128), Image.NEAREST).save(os.path.join(ROOT, "menu", "icon.png"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
terrain()
|
|
building()
|
|
furniture()
|
|
items()
|
|
liquids()
|
|
caverns()
|
|
underworld()
|
|
characters()
|
|
menu()
|
|
print("textures generated")
|