276 lines
11 KiB
Python
276 lines
11 KiB
Python
"""Currency, Spy Module, planet sigils, office crests, extra item icons."""
|
|
import math
|
|
from PIL import Image
|
|
from dunelib import *
|
|
|
|
# ---------------------------------------------------------------- coins
|
|
COINS = {
|
|
# name: (label, sub, c_hi, c_lo, glow)
|
|
"coin_001": ("1", "CENT", "#d9a070", "#6b3f25", "#e8913a"),
|
|
"coin_002": ("2", "CENT", "#dba878", "#70432a", "#e8913a"),
|
|
"coin_005": ("5", "CENT", "#e0b080", "#754a2d", "#ffb347"),
|
|
"coin_010": ("10", "CENT", "#cfd9d6", "#5a6b68", "#6ee7d8"),
|
|
"coin_020": ("20", "CENT", "#d6e0dd", "#5f726e", "#6ee7d8"),
|
|
"coin_050": ("50", "CENT", "#e2ecea", "#667a76", "#9ff3e8"),
|
|
"coin_1dm": ("1", "DM", "#f2d593", "#8a6a2a", "#e5b95e"),
|
|
"coin_1dm_gold": ("1", "DM", "#ffe9a8", "#9a7420", "#ffd35e"),
|
|
"coin_1dm_silver": ("1", "DM", "#eef3f2", "#6d7d7a", "#cfe9e6"),
|
|
"coin_2dm": ("2", "DM", "#f6dc9c", "#8f6c22", "#ffb347"),
|
|
}
|
|
|
|
|
|
def worm_arc(cv, cx, cy, r, color, w=2.2, a=1.0):
|
|
"""segmented crescent (sandworm ring) emblem"""
|
|
for i in range(9):
|
|
t0 = math.radians(200 + i * 17)
|
|
t1 = t0 + math.radians(13)
|
|
pts = [(cx + r * math.cos(t0), cy + r * math.sin(t0)), (cx + r * math.cos(t1), cy + r * math.sin(t1))]
|
|
cv.solid(cv.line(pts, w * (0.55 + 0.45 * math.sin(i / 8 * math.pi))), color, a)
|
|
|
|
|
|
def coin(name):
|
|
label, sub, hi, lo, gl = COINS[name]
|
|
cv = Cv(128)
|
|
c = 64
|
|
outer = cv.circle(c, c, 56)
|
|
cv.glow(outer, gl, 5, .55)
|
|
cv.fill(outer, hi, lo)
|
|
cv.bevel(outer, .6, .45, 1.8)
|
|
ring = cv.circle(c, c, 49)
|
|
cv.fill(ring, lo, hi)
|
|
face = cv.circle(c, c, 45)
|
|
cv.fill(face, mix(hi, "#000000", .45), mix(lo, "#000000", .35))
|
|
hex_lattice(cv, face, hi, .16, 7, .6)
|
|
# tick ring
|
|
for i in range(48):
|
|
a = math.radians(i * 7.5)
|
|
r0, r1 = 47, 52 if i % 4 == 0 else 50
|
|
cv.solid(cv.line([(c + r0 * math.cos(a), c + r0 * math.sin(a)), (c + r1 * math.cos(a), c + r1 * math.sin(a))], .9), lo, .9)
|
|
worm_arc(cv, c, c, 38, hi, 2.4, .9)
|
|
big = 44 if len(label) == 1 else 36
|
|
t = cv.text((c, c - 4), label, big)
|
|
cv.glow(t, gl, 3, .9)
|
|
cv.fill(t, "#ffffff", hi)
|
|
s = cv.text((c, c + 27), sub, 11)
|
|
cv.solid(s, hi, .95)
|
|
sparkle(cv, 36, 34, 7, "#ffffff")
|
|
return cv.out()
|
|
|
|
|
|
# ---------------------------------------------------------------- notes
|
|
NOTES = {
|
|
"note_5": ("5", "#58be87", "#0f3a2a"),
|
|
"note_10": ("10", "#6ee7d8", "#0c3a3d"),
|
|
"note_20": ("20", "#65a9ff", "#0d2a4d"),
|
|
"note_50": ("50", "#8a8cff", "#1a1f55"),
|
|
"note_100": ("100", "#b78bed", "#2a1650"),
|
|
"note_200": ("200", "#e58bd9", "#4a1646"),
|
|
"note_500": ("500", "#ff9a5e", "#4a2210"),
|
|
"note_1000": ("1000", "#ffd35e", "#4a3410"),
|
|
"note_5000": ("5000", "#ffffff", "#5a1f0a"),
|
|
"note_0_house": ("", "#e5b95e", "#102a23"),
|
|
"note_0_leto": ("", "#ffb347", "#2a1408"),
|
|
}
|
|
|
|
|
|
def note(name):
|
|
label, tint, dark = NOTES[name]
|
|
cv = Cv(128)
|
|
body = cv.rrect(4, 26, 124, 102, 9)
|
|
cv.glow(body, tint, 4, .55)
|
|
cv.fill(body, mix(dark, tint, .18), mix(dark, "#000000", .35))
|
|
hex_lattice(cv, body, tint, .14, 6.5, .55)
|
|
cv.bevel(body, .35, .35, 1.2)
|
|
cv.edge(body, tint, 1.4, .95)
|
|
inner = cv.rrect(9, 31, 119, 97, 6)
|
|
cv.edge(inner, "gold", .6, .55)
|
|
# holo emblem on the right: concentric hex + worm arc
|
|
ex, ey = 93, 64
|
|
hx = cv.poly(hexagon(ex, ey, 24, 0))
|
|
cv.fill(hx, mix(dark, tint, .35), mix(dark, "#000000", .2), .9)
|
|
cv.edge(hx, tint, 1.1, .9)
|
|
hx2 = cv.poly(hexagon(ex, ey, 16, 30))
|
|
cv.edge(hx2, "gold3", .8, .8)
|
|
if name == "note_0_house": # house crest: crown of five points, original
|
|
pts = [(ex - 11, ey + 6), (ex - 12, ey - 7), (ex - 6, ey - 1), (ex, ey - 10), (ex + 6, ey - 1), (ex + 12, ey - 7), (ex + 11, ey + 6)]
|
|
cv.solid(cv.line(pts + [pts[0]], 1.6), "gold3")
|
|
cv.solid(cv.line([(ex - 11, ey + 10), (ex + 11, ey + 10)], 1.6), "gold3")
|
|
elif name == "note_0_leto": # abstract worm coil, no portrait
|
|
for i, r in enumerate((13, 9, 5)):
|
|
worm_arc(cv, ex, ey, r, "spice2", 1.8)
|
|
cv.solid(cv.circle(ex, ey, 2.2), "#ffffff")
|
|
else:
|
|
worm_arc(cv, ex, ey, 11, tint, 2.4)
|
|
cv.glow(cv.circle(ex, ey, 3), tint, 3, 1)
|
|
cv.solid(cv.circle(ex, ey, 2.4), "#ffffff")
|
|
# denomination
|
|
if label:
|
|
size = {1: 40, 2: 34, 3: 28, 4: 21}[len(label)]
|
|
t = cv.text((34, 56), label, size)
|
|
cv.glow(t, tint, 3, .8)
|
|
cv.fill(t, "#ffffff", mix("#ffffff", tint, .55))
|
|
else:
|
|
t = cv.text((34, 56), "0", 34)
|
|
cv.glow(t, tint, 3, .8)
|
|
cv.fill(t, "#ffffff", mix("#ffffff", tint, .55))
|
|
cv.solid(cv.text((34, 82), "DUNEMARK", 8.2), tint, .95)
|
|
cv.solid(cv.line([(14, 90), (60, 90)], .8), tint, .6)
|
|
cv.solid(cv.line([(14, 38), (44, 38)], .8), tint, .6)
|
|
sparkle(cv, 112, 38, 5, "#ffffff")
|
|
return cv.out()
|
|
|
|
|
|
# ---------------------------------------------------------------- legacy DM notes (old GUI wallet ids)
|
|
def legacy_note(value):
|
|
# dunemark_1/5/100/1000/5000 reuse the note look
|
|
m = {"1": "note_5", "5": "note_5", "100": "note_100", "1000": "note_1000", "5000": "note_5000", "note": "note_100"}
|
|
img = note(m[value])
|
|
return img
|
|
|
|
|
|
# ---------------------------------------------------------------- spy module
|
|
def spy_module():
|
|
cv = Cv(128)
|
|
# egg-shaped capsule (the item is an egg-based device)
|
|
pts = []
|
|
for i in range(72):
|
|
t = i / 72 * 2 * math.pi
|
|
x = 64 + 36 * math.sin(t)
|
|
y = 66 - 46 * math.cos(t) * (1.0 if math.cos(t) > 0 else .86)
|
|
# egg narrowing toward the top
|
|
if math.cos(t) > 0:
|
|
x = 64 + 36 * math.sin(t) * (1 - .18 * math.cos(t))
|
|
pts.append((x, y))
|
|
body = cv.poly(pts)
|
|
cv.glow(body, "ixian", 6, .55)
|
|
cv.fill(body, "#1d4a45", "#06191a")
|
|
cv.bevel(body, .5, .45, 2)
|
|
cv.edge(body, "ixian", 1.6, .95)
|
|
hex_lattice(cv, body, "ixian", .2, 7, .6)
|
|
# scanner ring + lens
|
|
ring = cv.circle(64, 64, 22)
|
|
cv.fill(ring, "#0a2a2c", "#041012")
|
|
cv.edge(ring, "ixian", 1.6, 1)
|
|
for i in range(24):
|
|
a = math.radians(i * 15)
|
|
cv.solid(cv.line([(64 + 25 * math.cos(a), 64 + 25 * math.sin(a)), (64 + 28 * math.cos(a), 64 + 28 * math.sin(a))], 1), "ixian", .8)
|
|
lens = cv.circle(64, 64, 12)
|
|
cv.glow(lens, "ixian", 5, 1)
|
|
cv.fill(lens, "#bffcf4", "#2fb5ab")
|
|
# Fremen blue-within-blue iris
|
|
cv.solid(cv.circle(64, 64, 7), "fremen2")
|
|
cv.solid(cv.circle(64, 64, 3.6), "#03121f")
|
|
sparkle(cv, 58, 58, 3.4, "#ffffff")
|
|
# antenna blades
|
|
for sx in (-1, 1):
|
|
cv.solid(cv.poly([(64 + sx * 34, 40), (64 + sx * 46, 30), (64 + sx * 40, 46)]), "gold")
|
|
return cv.out()
|
|
|
|
|
|
# ---------------------------------------------------------------- planet sigils (reuse existing glyph line-art)
|
|
PLANET_TINT = {
|
|
"nivareth": "#8fd3ff", "orivane": "#e5b95e", "pelareth": "#9ff3e8", "serevan": "#b78bed", "varkesh": "#ff9a5e",
|
|
}
|
|
|
|
|
|
def planet(name, src_img):
|
|
tint = PLANET_TINT[name]
|
|
cv = Cv(128)
|
|
disc = cv.circle(64, 64, 58)
|
|
cv.glow(disc, tint, 5, .6)
|
|
cv.fill(disc, "#0c2a24", "#040f0c")
|
|
hex_lattice(cv, disc, tint, .13, 7.5, .55)
|
|
cv.edge(disc, tint, 1.3, .9)
|
|
for r, a in ((52, .35), (46, .18)):
|
|
cv.edge(cv.circle(64, 64, r), tint, .5, a)
|
|
layer = cv.out((128 * SS, 128 * SS))
|
|
# recolor the source glyph to the planet tint, keep its alpha
|
|
s = src_img.convert("RGBA").resize((128 * SS, 128 * SS), Image.LANCZOS)
|
|
a = s.getchannel("A").point(lambda v: min(255, int(v * 1.25)))
|
|
tl = Image.new("RGBA", s.size, rgb(tint))
|
|
tl.putalpha(a)
|
|
layer = Image.alpha_composite(layer, tl)
|
|
return layer.resize((128, 128), Image.LANCZOS)
|
|
|
|
|
|
# ---------------------------------------------------------------- office crests
|
|
def office(kind):
|
|
cv = Cv(64)
|
|
sh = cv.poly([(32, 4), (56, 13), (56, 34), (32, 60), (8, 34), (8, 13)])
|
|
tint = {"crown": "#e5b95e", "spice": "#ff9a3d", "water": "#58a8ff"}[kind]
|
|
cv.glow(sh, tint, 3, .6)
|
|
cv.fill(sh, "#17372c", "#06150f")
|
|
cv.bevel(sh, .4, .4, 1)
|
|
cv.edge(sh, tint, 1.2, 1)
|
|
cv.edge(cv.poly([(32, 9), (51, 16), (51, 33), (32, 53), (13, 33), (13, 16)]), tint, .5, .5)
|
|
if kind == "crown":
|
|
pts = [(18, 38), (17, 20), (25, 28), (32, 16), (39, 28), (47, 20), (46, 38)]
|
|
cv.glow(cv.line(pts + [pts[0]], 2), tint, 2, .8)
|
|
cv.solid(cv.line(pts + [pts[0]], 2), "gold3")
|
|
elif kind == "spice":
|
|
d = cv.poly([(32, 14), (44, 30), (32, 48), (20, 30)])
|
|
cv.glow(d, tint, 3, .9)
|
|
cv.fill(d, "#ffd08a", "#e8913a")
|
|
cv.edge(d, "#ffffff", .7, .7)
|
|
cv.solid(cv.line([(32, 14), (32, 48)], .8), "#ffffff", .6)
|
|
else:
|
|
drop = cv.circle(32, 36, 11)
|
|
tri = cv.poly([(32, 12), (42, 31), (22, 31)])
|
|
full = ImageChops.lighter(drop, tri)
|
|
cv.glow(full, tint, 3, .9)
|
|
cv.fill(full, "#bfe3ff", "#2f7fe0")
|
|
sparkle(cv, 28, 33, 3, "#ffffff")
|
|
return cv.out()
|
|
|
|
|
|
# ---------------------------------------------------------------- extra item icons
|
|
def spice_crystal(tint_a, tint_b, glow, smuggled=False, dense=False):
|
|
cv = Cv(64)
|
|
base = cv.circle(32, 40, 16)
|
|
cv.glow(base, glow, 6, .35 if not dense else .6)
|
|
shards = [([(32, 8), (42, 30), (32, 52), (22, 30)], 1.0), ([(16, 22), (24, 40), (14, 54), (8, 38)], .75), ([(48, 20), (56, 38), (48, 54), (40, 38)], .8)]
|
|
if dense:
|
|
shards.append(([(32, 24), (38, 40), (32, 58), (26, 40)], .9))
|
|
for pts, k in shards:
|
|
m = cv.poly(pts)
|
|
cv.glow(m, glow, 2, .7)
|
|
cv.fill(m, mix(tint_a, "#ffffff", .15 * k), tint_b)
|
|
cv.bevel(m, .55, .4, 1)
|
|
cv.edge(m, "#ffffff", .5, .35)
|
|
if smuggled:
|
|
cv.solid(cv.line([(8, 54), (56, 54)], 2.2), "#101a1f")
|
|
cv.solid(cv.line([(8, 54), (56, 54)], .6), "#58a8ff")
|
|
sparkle(cv, 36, 18, 4, "#ffffff")
|
|
return cv.out()
|
|
|
|
|
|
def water_vial(tint="#58a8ff", smuggled=False):
|
|
cv = Cv(64)
|
|
glass = cv.rrect(22, 14, 42, 56, 8)
|
|
cv.glow(glass, tint, 3, .6)
|
|
cv.fill(glass, "#d6f1ff", "#2f7fe0", .55)
|
|
liquid = cv.rrect(24, 30, 40, 54, 7)
|
|
cv.fill(liquid, "#bfe3ff", tint)
|
|
cv.edge(glass, "#e8f6ff", 1, .9)
|
|
cv.solid(cv.rrect(25, 7, 39, 16, 2.5), "gold")
|
|
cv.solid(cv.line([(27, 24), (27, 46)], 1.6), "#ffffff", .55)
|
|
if smuggled:
|
|
cv.solid(cv.rrect(21, 36, 43, 40, 1), "#e8913a")
|
|
return cv.out()
|
|
|
|
|
|
def imperial_codex():
|
|
cv = Cv(64)
|
|
book = cv.rrect(12, 6, 52, 58, 4)
|
|
cv.glow(book, "gold", 3, .6)
|
|
cv.fill(book, "#1d4a3a", "#06150f")
|
|
cv.bevel(book, .4, .4, 1)
|
|
cv.edge(book, "gold", 1.1, 1)
|
|
cv.solid(cv.rrect(12, 6, 18, 58, 2), "#0a2018")
|
|
hx = cv.poly(hexagon(35, 32, 12, 0))
|
|
cv.edge(hx, "gold3", 1, 1)
|
|
cv.glow(cv.circle(35, 32, 4), "gold3", 3, 1)
|
|
cv.solid(cv.circle(35, 32, 3), "#ffffff")
|
|
for y in (14, 50):
|
|
cv.solid(cv.line([(24, y), (46, y)], .9), "gold", .8)
|
|
return cv.out()
|

Staff