"""Generates the IRON ARC brand art: launcher icon (legacy + adaptive + monochrome), splash lockup and the Play feature graphic. python3 tools/art/artgen.py brand All output is derived from ../palette.json, so a colour change propagates everywhere. Art is authored as SVG and rasterised, never painted pixel by pixel. """ from __future__ import annotations import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) import artlib as A P = A.Palette.load() INK0 = P.color("ink.0") INK1 = P.color("ink.1") INK2 = P.color("ink.2") INK3 = P.color("ink.3") SOLAR_L = P.color("solar.light") SOLAR = P.color("solar.base") SOLAR_D = P.color("solar.deep") STEEL_L = P.color("steel.light") STEEL = P.color("steel.base") RIM = P.color("terrain.rim") SOIL = P.color("terrain.soil") DEEP = P.color("terrain.deep") TEXT_HI = P.color("text.hi") TEXT_MID = P.color("text.mid") WEIGHT = int(P.value("type.displayWeight")) TRACK = float(P.value("type.trackingEm")) ANDROID = A.ROOT / "app" / "android" / "app" / "src" / "main" / "res" APP_ASSETS = A.ROOT / "app" / "assets" STORE = A.ROOT / "store" / "assets" PREVIEW = A.ROOT / "build" / "art-preview" # --------------------------------------------------------------------------- # # shared scene pieces # --------------------------------------------------------------------------- # def sky_defs(tag: str, w: float, h: float, horizon: float) -> str: """Dusk gradient plus a warm glow sitting on the horizon.""" return ( A.linear_gradient( f"sky{tag}", [ (0.00, INK0, 1), (0.45, INK1, 1), (0.78, "#132135", 1), (1.00, "#1B2C44", 1), ], ) + A.radial_gradient( f"glow{tag}", [(0.00, SOLAR_D, 0.55), (0.45, SOLAR_D, 0.20), (1.00, SOLAR_D, 0.0)], cx=0.5, cy=horizon / h, r=0.62, ) + A.blur_filter(f"soft{tag}", 6) ) def sky(w: float, h: float, horizon: float, tag: str = "") -> str: return ( f'' f'' ) def sun(cx: float, cy: float, r: float, tag: str = "") -> str: """Sun disc with a soft corona - the light source of every composition.""" return ( f'' f'' ) def sun_defs(tag: str) -> str: return A.radial_gradient( f"sun{tag}", [ (0.00, "#FFF3DC", 1), (0.42, SOLAR_L, 1), (0.78, SOLAR, 1), (1.00, SOLAR_D, 1), ], cx=0.42, cy=0.38, r=0.62, ) def ridge( points: list[tuple[float, float]], fill: str, rim: str, rim_width: float, tag: str = "", ) -> str: fill = fill.replace("{tag}", tag) """Silhouette plus the warm rim light that separates it from the sky.""" d = A.smooth_path(points, closed=True) open_d = A.smooth_path(points[:-2]) if len(points) > 2 else d return ( f'' f'' ) def shot_trail(pts: list[tuple[float, float]], width: float, *, dots: int = 10) -> str: """Directional trail: fading dots behind, one crisp stroke in front. A full parabola reads as a dome (and as a rainbow); letting the shot leave the frame keeps the icon dynamic.""" cut = int(len(pts) * 0.30) trail = "" for i in range(dots): t = i / max(dots - 1, 1) x, y = pts[int(t * cut)] r = width * (0.18 + 0.26 * t) trail += ( f'' ) head = A.smooth_path(pts[cut:]) head_full = A.smooth_path(pts) return ( trail + f'' + f'' ) def arc_defs() -> str: return A.linear_gradient( "arc", [(0.0, SOLAR_L, 1), (0.55, SOLAR, 1), (1.0, SOLAR_D, 1)] ) + A.blur_filter("softx", 5) def finish(w: float, h: float, grain: float = 0.06, vig: float = 0.5) -> str: """Grain + vignette over the whole frame - the cheap trick that sells depth.""" return ( f'' f'' ) # --------------------------------------------------------------------------- # # the glyph: sun, two ridges, one ballistic arc # --------------------------------------------------------------------------- # def tank( cx: float, base_y: float, size: float, *, fill: str, rim: str, angle: float = -32.0, flip: bool = False, ) -> str: """A silhouette tank: hull, turret, barrel. Only reads below ~64 px as a bump with a stick, which is exactly what a launcher icon needs.""" w = size * (1 if not flip else -1) hull_h = size * 0.30 turret_w = size * 0.44 turret_h = size * 0.20 barrel_w = size * 0.11 barrel_l = size * 0.62 body = ( # hull: slightly tapered block f'' # turret f'' # barrel, pivoting at the turret centre f'' f'' f'' # rim light on the hull top edge f'' ) return ( f'' + body ) def muzzle_glow(x: float, y: float, r: float) -> str: """Warm bloom right at the barrel mouth - the shot just left.""" return ( f'' ) def stars(S: float, count: int = 7, seed: int = 3, size: float | None = None, x0: float = 0.05) -> str: """A few dim points of light: fills the empty sky without becoming noise.""" import random rnd = random.Random(seed) unit = size if size is not None else S out = "" for _ in range(count): x = rnd.uniform(x0, 0.95) * S y = rnd.uniform(0.04, 0.42) * S r = rnd.uniform(0.0025, 0.0055) * unit a = rnd.uniform(0.20, 0.55) out += f'' return out def glyph( S: float, tag: str, *, with_sky: bool = True, k: float = 1.0, dy: float = 0.0, rim_alpha: float = 1.0, ) -> str: """Drawable in a 0..S box; `k` shrinks it for the adaptive safe zone.""" horizon = 0.715 * S body = "" if with_sky: body += sky(S, S, horizon, tag) # The shot leaves the frame at the top right: no dome, no rainbow. # muzzle sits at the barrel tip (see tank(): pivot + L at 38 deg) shot = A.ballistic_arc( 0.340 * S, 0.623 * S, 1.080 * S, -0.180 * S, apex_y=0.155 * S, steps=48 ) inner = ( stars(S) + sun(0.690 * S, 0.640 * S, 0.135 * S, tag) + ridge( A.hill_ridge(S, 0.775 * S, 0.046 * S, seed=7, steps=6, foot=S), "#0F1B2E", A.rgba(RIM, 0.20), 0.007 * S, tag, ) + shot_trail(shot, 0.024 * S) + muzzle_glow(0.340 * S, 0.623 * S, 0.024 * S) + ridge( A.hill_ridge(S, 0.862 * S, 0.030 * S, seed=11, steps=4, phase=0.42, foot=S), "url(#ground{tag})", A.rgba(SOLAR_L, 0.38 * rim_alpha), 0.009 * S, tag, ) + tank( 0.225 * S, 0.884 * S, 0.30 * S, fill="#0B1420", rim=A.rgba(SOLAR_L, 0.60), angle=38, ) ) if k >= 1.0: return body + inner t = S * (1 - k) / 2 return body + f'{inner}' def glyph_defs(tag: str) -> str: return ( A.linear_gradient( f"ground{tag}", [(0.0, "#241D13", 1), (0.40, "#120F0A", 1), (1.0, "#07080A", 1)], ) + sky_defs(tag, 1, 1, 0.705) + sun_defs(tag) + arc_defs() + A.grain_filter() + A.vignette_def() ) def icon_svg(S: int = 1024) -> str: return A.svg_doc( S, S, glyph(S, "") + finish(S, S, grain=0.05, vig=0.42), glyph_defs(""), ) def foreground_svg(S: int = 432) -> str: """Adaptive icon foreground: transparent, content inside the 72/108 safe zone.""" return A.svg_doc(S, S, glyph(S, "f", with_sky=False, k=0.58, dy=-0.02), glyph_defs("f")) def background_svg(S: int = 432) -> str: return A.svg_doc( S, S, sky(S, S, 0.705 * S, "b") + finish(S, S, grain=0.05, vig=0.45), sky_defs("b", S, S, 0.705 * S) + A.grain_filter() + A.vignette_def(), ) def monochrome_svg(S: int = 432) -> str: """Android 13 themed icons: one ink, tinted by the launcher.""" shot = A.ballistic_arc( 0.340 * S, 0.623 * S, 1.080 * S, -0.180 * S, apex_y=0.155 * S, steps=40 ) body = ( f'' f'' f'' ) t = S * 0.13 return A.svg_doc(S, S, f'{body}') def splash_icon_svg(S: int = 512) -> str: """Android 12+ splash icon: badge only, inside the mask-safe 60 % of the canvas.""" r = S * 0.32 cx = cy = S / 2 body = clip_def("s", cx, cy, r) + badge(cx, cy, r, "s", zoom=1.28, focus=(0.56, 0.615)) return A.svg_doc(S, S, body, glyph_defs("s")) # --------------------------------------------------------------------------- # # circular badge + wordmark lockup # --------------------------------------------------------------------------- # def clip_def(tag: str, cx: float, cy: float, r: float) -> str: return ( f'' f'' ) def badge( cx: float, cy: float, r: float, tag: str, *, zoom: float = 1.30, focus: tuple[float, float] = (0.55, 0.60), ) -> str: """The glyph art zoomed onto its subject and clipped to a circle. A circular badge cannot show the square scene - the corners are masked away - so the art is scaled up and centred on sun, arc and tank.""" inner = 2048 s = (2 * r * zoom) / inner tx = cx - focus[0] * inner * s ty = cy - focus[1] * inner * s return ( f'' f'' f"{glyph(inner, tag, rim_alpha=0.18)}" f'' ) def lockup_svg(w: int = 640, h: int = 780, *, badge_only: bool = False) -> str: """Circular badge above the wordmark - used for splash and store listing.""" r = 138.0 cx, cy = w / 2, 176.0 body = ( clip_def("k", cx, cy, r) + badge(cx, cy, r, "k") + f'' ) if badge_only: return A.svg_doc(w, h, body, glyph_defs("k") + A.blur_filter("softk", 12)) title_y = cy + r + 126 body += ( f'' f'IRON' f'ARC' f'TAKTISCHES PANZERDUELL' ) return A.svg_doc(w, h, body, glyph_defs("k") + A.blur_filter("softk", 12)) # --------------------------------------------------------------------------- # # Play feature graphic 1024x500 # --------------------------------------------------------------------------- # def feature_svg(w: int = 1024, h: int = 500) -> str: """Title block left, self-contained dusk scene in the right half. The shot stays inside its half of the canvas - a line crossing the wordmark is exactly the kind of detail that makes store art look amateurish. """ horizon = 0.66 * h shot = A.ballistic_arc( 0.585 * w, 0.615 * h, 1.045 * w, -0.070 * h, apex_y=0.165 * h, steps=56 ) body = ( sky(w, h, horizon, "f") + stars(w, 6, seed=5, size=min(w, h), x0=0.62) + sun(0.755 * w, 0.440 * h, 0.105 * w, "f") + ridge( A.hill_ridge(w, 0.660 * h, 0.038 * h, seed=7, steps=7, foot=h), "#0F1B2E", A.rgba(RIM, 0.22), 2.0, "f", ) + shot_trail(shot, 3.2) + ridge( A.hill_ridge(w, 0.870 * h, 0.048 * h, seed=11, steps=5, phase=0.42, foot=h), "url(#groundf)", A.rgba(SOLAR_L, 0.34), 2.4, "f", ) + f'' + text_block(w) + finish(w, h, grain=0.05, vig=0.36) ) defs = ( glyph_defs("f") + A.linear_gradient( "groundf", [(0.0, "#2A2318", 1), (0.40, "#14110C", 1), (1.0, "#07080A", 1)], ) + A.linear_gradient( "scrim", [(0.0, INK0, 0.97), (0.62, INK0, 0.88), (1.0, INK0, 0.0)], x1=0, y1=0, x2=1, y2=0, ) ) return A.svg_doc(w, h, body, defs) def text_block(w: float) -> str: """Type lockup: one accent word, wide-tracked caps for the rest.""" return ( f'' f'IRON' f'ARC' f'' f'TAKTISCHES PANZERDUELL' f'' f'' f'1 GEGEN 1 ยท OFFLINE UND ONLINE' ) ADAPTIVE_XML = """ """ DENSITIES = { "mdpi": 1.0, "hdpi": 1.5, "xhdpi": 2.0, "xxhdpi": 3.0, "xxxhdpi": 4.0, } def write_all() -> list[Path]: """Render every brand asset into the app and the store folder.""" written: list[Path] = [] written.append(A.render(icon_svg(1024), STORE / "icon_512.png", width=512)) written.append(A.render(feature_svg(), STORE / "feature_1024x500.png")) lockup = A.render(lockup_svg(), STORE / "logo_mark.png", width=640) written.append(lockup) written.append(A.render(lockup_svg(), APP_ASSETS / "logo_mark.png", width=640)) written.append(A.render(lockup_svg(), ANDROID / "drawable-xxxhdpi" / "launch_logo.png", width=512)) written.append( A.render(splash_icon_svg(512), ANDROID / "drawable-xxxhdpi" / "launch_logo_splash.png") ) for density, factor in DENSITIES.items(): folder = ANDROID / f"mipmap-{density}" legacy = int(48 * factor) adaptive = int(108 * factor) written.append(A.render(icon_svg(1024), folder / "ic_launcher.png", width=legacy)) written.append( A.render(foreground_svg(adaptive), folder / "ic_launcher_foreground.png") ) written.append( A.render(background_svg(adaptive), folder / "ic_launcher_background.png") ) written.append( A.render(monochrome_svg(adaptive), folder / "ic_launcher_monochrome.png") ) anydpi = ANDROID / "mipmap-anydpi-v26" anydpi.mkdir(parents=True, exist_ok=True) for name in ("ic_launcher.xml", "ic_launcher_round.xml"): path = anydpi / name path.write_text(ADAPTIVE_XML, encoding="utf-8") written.append(path) return written def preview() -> Path: items = [ STORE / "icon_512.png", STORE / "feature_1024x500.png", STORE / "logo_mark.png", ANDROID / "drawable-xxxhdpi" / "launch_logo_splash.png", ANDROID / "mipmap-xxxhdpi" / "ic_launcher.png", ANDROID / "mipmap-mdpi" / "ic_launcher.png", ANDROID / "mipmap-xxxhdpi" / "ic_launcher_foreground.png", ANDROID / "mipmap-xxxhdpi" / "ic_launcher_monochrome.png", ] return A.contact_sheet(items, PREVIEW / "brand.png", cols=3, cell=340) if __name__ == "__main__": for f in write_all(): print(f.relative_to(A.ROOT), f.stat().st_size, "bytes") print("preview:", preview())