A 3D model pipeline, pushed by GPT-6.2-Astra
agent (cont.)
+6:07view_image~/work/lowmarch/review/out/high-water/detail.png
input
image((await tools.view_image({path:"~/work/lowmarch/review/out/high-water/detail.png"})).image_url)result, 4 lines
Script completed Wall time 0.0 seconds Output:
exec_commandrg -n 'def mantle|def pin|def collar' tools/outfit.py && sed -n '328,355p;865,935p' tools/outfit.py
command
rg -n 'def mantle|def pin|def collar' tools/outfit.py && sed -n '328,355p;865,935p' tools/outfit.py rg -n 'face_uv|Fcl_EYE_Halfclose' art/cast/expressions.txt && cat art/cast/expressions.txt || true sed -n '40,75p' tools/vroid_portrait.py sed -n '31,60p;966,1000p' tools/outfit.py
result, 206 lines
Script completed Wall time 0.1 seconds Output: 328:def collar(fit, name, role, height_back=0.044, height_front=0.028, gap_deg=50, clear=(0.009, 0.015), 716:def mantle(fit, name, role, over, seg=64, rows=16, gap_deg=12, clear=(0.010, 0.016)): def collar(fit, name, role, height_back=0.044, height_front=0.028, gap_deg=50, clear=(0.009, 0.015), thickness=0.0035, seg=40, rows=6): """A standing collar fitted to the neck: radius from ray casts to the neck skin plus clearance (flaring toward the top), taller at the back, base lower at the front (the jugular notch).""" nk = fit.bone["J_Bip_C_Neck"] half = math.radians(180 - gap_deg / 2) ang = np.linspace(-half, half, seg) # 0 = back (+z), +-pi = front (-z) neck = Surface(fit.pos, fit.tris_for(("Neck", "UpperChest", "Head", "Shoulder"), min_w=0.3)) P = np.zeros((seg, rows, 3)) for i, a in enumerate(ang): d = np.array([math.sin(a), 0, math.cos(a)]) front = (1 - math.cos(a)) / 2 # 0 back .. 1 front base_y = nk[1] - 0.010 - 0.012 * front h = height_back + (height_front - height_back) * front for j, t in enumerate(np.linspace(0, 1, rows)): o = np.array([nk[0], base_y + h * t, nk[2]]) r = neck.cast(o, d, rmax=0.2, far=False) r = 0.05 if np.isnan(r) else r P[i, j] = o + d * (r + clear[0] + (clear[1] - clear[0]) * t) pos, tri, outer = thick_grid(P, thickness, outward_from=nk, axis=[0, 1, 0]) pc = piece(name, role, pos, tri) t = np.clip((pos[:, 1] - (nk[1] - 0.022)) / height_back, 0, 1) fit.bind(pc, blend={"J_Bip_C_UpperChest": 0.5, "J_Bip_C_Neck": 0.5}) pc["W"][:, 0], pc["W"][:, 1] = 1 - 0.7 * t, 0.7 * t # base on the chest, top mostly on the neck return pc, outer[:, -1], (outer[0], outer[-1]) def pauldron(fit, name, role, over, side="L", lames=((0, 62, 0.012, 0.016), (55, 78, 0.010, 0.013), out = [] c = at(0.0, 0.118, 0.142) out.append(ball("bun", hair_role, c, 0.046 * hs, seg=20, rows=12, squash=(1.0, 0.86, 0.72))) # the braid wound around the bun: two strands twisting around a ring ring_r, n = 0.050 * hs, 96 th = np.linspace(0, 2 * math.pi, n, endpoint=False) for k, ph in enumerate((0.0, math.pi)): tw = th * 7 + ph rr = ring_r + 0.008 * hs * np.cos(tw) zz = 0.008 * hs * np.sin(tw) pts = c + np.stack([rr * np.cos(th), rr * np.sin(th) * 0.86, -0.012 * hs + zz], 1) out.append(pipe(f"braid{k}", hair_role, pts, r=0.0085 * hs, seg=7, closed=True)) # ribbon: two loops and a knot on top of the bun knot = c + hs * np.array([0.0, 0.040, -0.004]) out.append(ball("ribbon_knot", ribbon_role, knot, 0.011 * hs, seg=10, rows=7)) for sx in (-1, 1): out.append(ball(f"ribbon_loop{(sx + 1) // 2}", ribbon_role, knot + hs * np.array([sx * 0.030, 0.006, 0.004]), 0.022 * hs, seg=12, rows=8, squash=(1.0, 0.55, 0.32))) # the cowlick: a tapered strand rising from the crown and curling forward t = np.linspace(0, 1, 20) pts = np.stack([0.003 * np.sin(t * 3), 0.236 + 0.062 * np.sin(t * 2.2), -0.004 - 0.050 * t - 0.012 * np.sin(t * 5)], 1) pts = h + hs * pts st = pipe("cowlick", hair_role, pts, r=0.013 * hs, seg=10) sp = st["pos"].reshape(len(t), 11, 3) off = sp - pts[:, None] off[..., 0] *= 0.35 # a flat lock, not a round stalk sp[:] = pts[:, None] + off * (1 - 0.9 * t ** 0.8)[:, None, None] st["pos"] = sp.reshape(-1, 3) out.append(st) for pc in out: fit.bind(pc, rigid="J_Bip_C_Head") pc["group"] = "hair" return out def sabaton(fit, name, side, role="metal", pad=0.010, ridges=3, seg=26, rows=14): """A steel shoe over the whole foot (hides the base model's toes), built as a shoe last from the foot's measurements: sole outline rounded at heel and toe and widest at the ball, top rising from a rounded toe over the instep to the ankle at the heel. Lame ridges follow its cross-section over the instep. Rides the foot bone. (A squashed ellipsoid read as a triangular hoof; a shell projected onto the foot's convex hull creased on the hull's facets.)""" w = fit.weight((f"{side}_Foot", f"{side}_ToeBase")) P = fit.pos[w > 0.5] P = P[(P[:, 0] < 0.01) if side == "L" else (P[:, 0] > -0.01)] lo, hi = P.min(0), P.max(0) sole = lo[1] - 0.003 ankle = fit.bone[f"J_Bip_{side}_Foot"][1] z_heel, z_toe = hi[2] + pad, lo[2] - pad # the foot points -z width = (hi[0] - lo[0]) + 2 * pad S = np.linspace(0, 1, seg) # centreline: the foot's middle at each station, smoothed cx = np.array([np.median(P[np.abs(P[:, 2] - (z_heel + t * (z_toe - z_heel))) < 0.02, 0]) if (np.abs(P[:, 2] - (z_heel + t * (z_toe - z_heel))) < 0.02).any() else (lo[0] + hi[0]) / 2 for t in S]) cx = np.convolve(np.pad(cx, 3, mode="edge"), np.ones(7) / 7, "valid") ends = np.sin(np.pi * np.clip(S, 0, 1)) ** 0.42 # rounds the heel and the toe half_w = width / 2 * ends * (0.80 + 0.20 * np.sin(np.pi * np.clip(S * 1.2, 0, 1))) # widest at the ball tall = (ankle + 0.02 - sole) * (1 - 0.62 * np.clip((S - 0.25) / 0.6, 0, 1) ** 0.8) # ankle at the heel, low toe tall = np.maximum(tall * np.sin(np.pi * np.clip(S, 0, 1)) ** 0.22, 0.004) phi = np.linspace(0, np.pi, rows) G = np.zeros((seg, rows, 3)) for i, t in enumerate(S): z = z_heel + t * (z_toe - z_heel) G[i] = np.stack([cx[i] + half_w[i] * np.cos(phi), sole + tall[i] * np.sin(phi), np.full(rows, z)], 1) pos, tri = grid_mesh(G) c = np.array([(lo[0] + hi[0]) / 2, sole, (z_heel + z_toe) / 2]) pc = piece(name, role, pos, tri, outward_from=c - [0, 0.05, 0]) out = [pc] for k, t in enumerate(np.linspace(0.50, 0.74, ridges)): # lames over the instep i = int(round(t * (seg - 1))) ring = G[i, 1:-1] + np.stack([np.cos(phi[1:-1]), np.sin(phi[1:-1]) * 1.0, np.zeros(rows - 2)], 1) * 0.0018 ("Face_00_SKIN", "face"), ("Body_00_SKIN", "body"), ("HairBack", "hair"), ("_HAIR", "hair"), ("CLOTH", "cloth")] PRIORITY = {"o": 8, "r": 5, "s": 5, "t": 4, "w": 3, "A": 3, "1": 8} # features win the 4x4 vote FACE_MARK = 0.70 # face-texture texels darker than this are painted lines (lip line, nose mark) MARK_GROW = 4 # texels of dilation so a 1.5 mm painted line survives the 4x4 vote LIP_DROP = 0.014 # UV distance below the lip line that gets the lower-lip shade # VRoid face textures share one layout: marks only count inside the nose-and-mouth window MARK_WINDOW = dict(u=(0.32, 0.68), v=(0.58, 0.86), nose_below=0.70) # High-resolution pixel rendering (2026-10-08): a 640x360 base screen (scales cleanly to 1080p/4K). BUST_SIZE, BUST_EYE_CHIN, BUST_EYE_AT = (192, 160), 38.0, (92, 60) # portrait: canvas, eye-to-chin px, eye line BATTLE_SIZE, BATTLE_PX_PER_M, BATTLE_GROUND_AT = (640, 360), 90.0, (420, 318) # battle: canvas, scale, feet SUN = np.array([-0.30, 0.85, 0.45]) / np.linalg.norm([-0.30, 0.85, 0.45]) # scenery light (camera space) LID_CORE = 70 # eyeline texels darker than this are the lash line LIGHT = np.array([0.08, 0.06, 1.0]) / np.linalg.norm([0.08, 0.06, 1.0]) SKIN_BANDS = [(0.80, "5"), (0.62, "4"), (0.38, "3"), (-9, "2")] HAIR_BANDS = [(0.86, "E"), (0.66, "D"), (0.42, "C"), (-9, "B")] CLOTH_BANDS = [(0.85, "P"), (0.6, "M"), (0.35, "L"), (-9, "K")] # costume materials: role -> bands (metal has a narrow bright streak and hard darks) MATERIALS = {"coat": CLOTH_BANDS, "signature": CLOTH_BANDS, # the character's one colour (tabard, mantle, shield) "doublet": [(0.85, "T"), (0.6, "S"), (0.35, "R"), (-9, "Q")], "heraldry": [(0.85, "O"), (0.6, "N"), (0.35, "J"), (-9, "F")], "cape": [(0.85, "X"), (0.6, "W"), (0.35, "V"), (-9, "U")], "metal": [(0.975, "9"), (0.86, "8"), (0.55, "7"), (-9, "6")], "gold": [(0.80, "I"), (0.45, "H"), (-9, "G")], "leather": [(0.75, "x"), (0.4, "v"), (-9, "u")], "boot": [(0.80, "x"), (0.45, "v"), (-9, "u")], "glove": [(0.75, "x"), (0.4, "v"), (-9, "u")], "steel": [(0.90, "9"), (0.70, "8"), (0.40, "7"), (-9, "6")], "grass": [(0.90, "d"), (0.70, "c"), (0.40, "b"), (-9, "a")], "dirt": [(0.70, "i"), (0.35, "f"), (-9, "e")], "stone": [(0.80, "m"), (0.45, "l"), (-9, "k")]} WORLD_ROLES = ("grass", "dirt", "stone") DARKER = {c: tbl[min(i + 1, len(tbl) - 1)][1] for tbl in MATERIALS.values() for i, (_, c) in enumerate(tbl)} FLIP = np.array([-1.0, 1.0, -1.0]) # VRoid faces -z; we want the face toward +z (the viewer) # ---- mesh helpers -------------------------------------------------------------- def grid_mesh(P): """P: (U, V, 3) grid of points -> (pos, tri).""" U, V = P.shape[:2] idx = np.arange(U * V).reshape(U, V) a, b, c, d = idx[:-1, :-1], idx[1:, :-1], idx[1:, 1:], idx[:-1, 1:] tri = np.concatenate([np.stack([a, b, c], -1).reshape(-1, 3), np.stack([a, c, d], -1).reshape(-1, 3)]) return P.reshape(-1, 3), tri def piece(name, role, pos, tri, nrm=None, outward_from=None, axis=None): """outward_from: a point (or, with axis, a line) the normals should face away from, so the renderer knows which side is the outside of a one-sided sheet.""" pos = np.asarray(pos, float) tri = np.asarray(tri) nrm = vertex_normals(pos, tri) if nrm is None else nrm if outward_from is not None: d = pos - np.asarray(outward_from, float) if axis is not None: a = np.asarray(axis, float) / np.linalg.norm(axis) d -= np.outer(d @ a, a) if (np.einsum("ij,ij->i", nrm, d) < 0).mean() > 0.5: nrm = -nrm tri = tri[:, ::-1] return dict(mesh="outfit", material=f"OUTFIT_{name}", mi=-1, role=role, pos=pos, nrm=nrm, uv=np.zeros((len(pos), 2)), tri=tri) def thick_grid(P, thickness, outward_from, axis=None): """A grid sheet given real thickness: outer face, inner face, and the four edges closed, so bodice = wrap(fit, "bodice", "signature", torso, offset=0.006, exclude=("UpperLeg",), y_min=hips[1] + 0.02, y_max=nk[1] + 0.012, hems=[cuff_plane("L"), cuff_plane("R")]) tights = wrap(fit, "tights", "doublet", ("Hips", "UpperLeg", "LowerLeg"), offset=0.004, y_max=hips[1] + 0.03, subdiv=1) boots = wrap(fit, "boots", "metal", ("LowerLeg", "Foot"), offset=0.014, y_max=knee - 0.06, exclude=("ToeBase",), subdiv=1, hems=[((0, 1, 0), knee - 0.065)]) gloves = wrap(fit, "gloves", "metal", ("Hand", "Thumb", "Index", "Middle", "Ring", "Little"), offset=0.0035, min_w=0.3, smooth=4) out += grouped([bodice], "dress") + grouped([tights], "trousers") + grouped([boots], "boots") + grouped([gloves], "gloves") out += grouped(sabaton(fit, "sabaton_L", "L") + sabaton(fit, "sabaton_R", "R"), "boots") col, rim, _ = collar(fit, "collar", "signature", height_back=0.034, height_front=0.022) out += grouped([col, inherit(pipe("collar_trim", "gold", rim, r=0.0022), col)], "dress") # steel breastplate, fitted, ending at the natural waist; gold line along the neckline cuirass = wrap(fit, "breastplate", "steel", ("Spine", "Chest", "UpperChest", "Bust"), offset=0.010, # the female # base weights the chest to its own Bust bones: leave them out and the plate has two holes exclude=("Shoulder", "UpperArm", "Neck"), y_min=hips[1] + 0.085, y_max=nk[1] - 0.065, base=Surface(bodice["pos"], bodice["tri"]), smooth=70, # a rigid shell, not a moulded bust hems=[((0, 1, 0), hips[1] + 0.095), ((0, 1, 0), nk[1] - 0.075)]) loops = sorted([cuirass["pos"][L] for L in cuirass["loops"] if len(L) > 12], key=lambda Lp: -Lp[:, 1].mean()) out += grouped([cuirass] + [inherit(pipe(f"breastplate_roll{k}", "gold" if k == 0 else "metal", Lp, r=0.003, closed=True), cuirass) for k, Lp in enumerate(loops)], "plate") # the skirt from the waist to the ankle, white petticoat edge (the viewer's border band) legs = merge_surfaces((tights["pos"], tights["tri"]), (boots["pos"], boots["tri"])) # the waist ring is cast onto the bodice without its sleeves: with them, the hanging arms beside # the hips held the ring out at the sides, a shelf the user saw once the arms moved waist = merge_surfaces(without(bodice, ("Shoulder", "UpperArm", "LowerArm", "Hand")), (tights["pos"], tights["tri"])) ytop = hips[1] + 0.08 sk, grid = skirt(fit, "skirt", "signature", waist, legs, ytop, ytop - 0.24, flare=0.17) # hem above the ankle sk["group"] = "dress" out.append(sk) out += grouped([inherit(ribbon("skirt_hem", "heraldry", np.concatenate([grid[:, -1], grid[:1, -1]]), width=0.03, lift=0.0015, normals=near_normals(sk, np.concatenate([grid[:, -1], grid[:1, -1]]))), sk)], "dress") out += grouped([inherit(pipe("waist_trim", "gold", grid[:, 0], r=0.0035, closed=True), sk)], "dress")exec_commandsed -n '716,763p' tools/outfit.py
command
sed -n '716,763p' tools/outfit.py cat art/cast/expressions.txt | head -20 rg 'J_Bip_C_Head|J_Bip_C_Neck' review/out/high-water/camera.json -o | head
result, 73 lines
Script completed Wall time 0.0 seconds Output: def mantle(fit, name, role, over, seg=64, rows=16, gap_deg=12, clear=(0.010, 0.016)): """A hooded scarf (the study's lord wears one in his signature colour): a ring at the base of the neck, open at the front where it is clasped, falling over the breastplate in front and lower at the back, short at the sides so the spaulders stand over its edges. The hood lies bunched behind the neck. `over` should not include the spaulders: they overhang the arm, and a ray out of the neck that passes under one would pull the cloth into that gap.""" nk = fit.bone["J_Bip_C_Neck"] half = math.radians(180 - gap_deg / 2) ang = np.linspace(-half, half, seg) # 0 = back (+z), +-pi = front rad = np.stack([np.sin(ang), np.zeros_like(ang), np.cos(ang)], 1) neck = Surface(fit.pos, fit.tris_for(("Neck", "UpperChest"), min_w=0.3)) top = [] for a, d in zip(ang, rad): front = (1 - math.cos(a)) / 2 o = np.array([nk[0], nk[1] - 0.008 - 0.030 * front, nk[2]]) r = neck.cast(o, d, rmax=0.2, far=False) top.append(o + d * ((0.055 if np.isnan(r) else r) + 0.024)) top = np.array(top) back = np.clip(np.cos(ang), 0, 1) ** 2 frnt = np.clip(-np.cos(ang), 0, 1) ** 2 L = 0.035 + 0.105 * frnt + 0.135 * back # short at the sides: the spaulders sit over its edges P = np.zeros((seg, rows, 3)) for j, t in enumerate(np.linspace(0, 1, rows)): P[:, j] = top + rad * (0.05 * min(1.0, t * 2.5)) + np.outer(L * t, [0, -1, 0]) # start outside everything it covers (plate included): the cloth solve only pushes outward along # the nearest face, so a mantle that starts inside the breastplate stays there clr = clear[0] + (clear[1] - clear[0]) * np.linspace(0, 1, rows) def push_out(P): """Move each vertex outside the outermost surface on a level ray from the neck axis.""" for i in range(seg): for j in range(rows): o = np.array([nk[0], P[i, j, 1], nk[2]]) d = P[i, j] - o d[1] = 0 dist = np.linalg.norm(d) d /= max(dist, 1e-9) r = over.cast(o, d, rmax=0.30, far=True) if not np.isnan(r) and dist < r + clr[j]: P[i, j] = o + d * (r + clr[j]) + np.array([0, P[i, j, 1] - o[1], 0]) return P P = push_out(P) pinned = np.zeros((seg, rows), bool) pinned[:, 0] = True P = drape(P, over, clr, pinned, steps=110, bend=0.4) for j, t in enumerate(np.linspace(0, 1, rows)): # soft folds toward the hem P[:, j] += rad * (0.006 * t * np.sin(ang * 9 + 0.7))[:, None] # expression recipes: name|VRoid shapes baked at build (Fcl_* names, weight; ';' between; 'none' = neutral) # the 14 the sheets show; keep these names (front_sheet.py reads them). Edit the recipes freely. # a key ending @L or @R applies to that side of the face only (tools/vrm.py), for one-sided looks neutral|none joy|Fcl_BRW_Joy:1;Fcl_EYE_Joy:1;Fcl_MTH_Joy:1 smile|Fcl_BRW_Fun:1;Fcl_EYE_Fun:0.75;Fcl_MTH_Fun:1 angry|Fcl_BRW_Angry:1.4;Fcl_EYE_Angry:1;Fcl_MTH_Angry:1 sad|Fcl_BRW_Sorrow:1.4;Fcl_EYE_Sorrow:1.3;Fcl_MTH_Sorrow:1;Fcl_MTH_Angry:0.6 surprised|Fcl_BRW_Surprised:1.3;Fcl_EYE_Surprised:1.5;Fcl_MTH_O:1.1;Fcl_MTH_A:0.15 shout|Fcl_BRW_Angry:1.6;Fcl_EYE_Angry:0.9;Fcl_MTH_A:1.5;Fcl_MTH_Large:0.5 wink|Fcl_EYE_Close_R:1;Fcl_BRW_Fun:0.6;Fcl_MTH_Fun:1 smug|Fcl_EYE_Close@L:0.45;Fcl_EYE_Close@R:0.35;Fcl_BRW_Angry@L:0.5;Fcl_BRW_Surprised@R:0.5;Fcl_MTH_Fun:0.4;Fcl_MTH_Fun@R:1.2;Fcl_MTH_Up@R:0.6 lip_A|Fcl_MTH_A:1 lip_I|Fcl_MTH_I:1 lip_U|Fcl_MTH_U:0.6;Fcl_MTH_O:0.8 lip_E|Fcl_MTH_E:1;Fcl_MTH_I:0.35 lip_O|Fcl_MTH_O:1.1 J_Bip_C_Neck J_Bip_C_Neck J_Bip_C_Head J_Bip_C_Headexec_commandpython3 - <<'PY'
command
python3 - <<'PY' p='review/high-water/figure.py' s=open(p).read().replace('from fitting import vertex_normals','from fitting import merge_surfaces, vertex_normals') s=s.replace(' # Marks on the part', ''' body = next(p for p in pieces if p["material"] == "OUTFIT_robe") over = merge_surfaces((fit.pos, fit.tri), (body["pos"], body["tri"])) mantle, grid, hood = outfit.mantle(fit, "wrap", "scarf", over) pieces.extend([mantle, hood]) # A long and a short end of the same scarf lift together in the crosswind. anchor = grid[len(grid)//2, 0].copy() for j, length in enumerate((.66, .43)): t = np.linspace(0, 1, 55) c = anchor + np.column_stack([.10*t + .045*np.sin(2*np.pi*t + j)*t, -.12*t + .09*np.sin(2*np.pi*t+.6*j)*t - .065*j*t, length*t]) breadth = .052*(1 - .36*t) * (1 - .75*t**9) axis = np.column_stack([.55*np.cos(3*np.pi*t), np.ones_like(t), .12*np.sin(4*t)]) sheet = np.stack([c + u*breadth[:,None]*axis for u in (-1, -.5, 0, .5, 1)], axis=1) sheet[:,2,0] += .009*np.sin(np.pi*t) pos, tri = outfit.grid_mesh(sheet) flag = outfit.piece(f"scarf_end_{j}", "scarf", pos, tri) pieces.append(fit.bind(flag, rigid="J_Bip_C_UpperChest")) edge = fit.bind(outfit.pipe(f"woven_edge_{j}", "gold", sheet[:,0], r=.0023), rigid="J_Bip_C_UpperChest") pieces.append(edge) # Marks on the part''') s=s.replace('for i in range(9):','''# Lengthen the lower end so it reaches past the forward foot. extension = outfit.tube("staff_lower", "wood", grip - axis*1.19, axis, .45, .012, .014) pieces.append(fit.bind(extension, rigid="J_Bip_R_Hand")) for i in range(12):''').replace('(-.72 + .065*i)','(-1.17 + .078*i)') s=s.replace('rot((0, 1, 0), 9) @ poses.rot((1, 0, 0), -5)','rot((0, 1, 0), -22) @ poses.rot((1, 0, 0), 7)').replace('[.085, -.27, -.39]','[.015, -.24, -.47]').replace('[-.045, 1, .38]','[-.38, 1, .23]').replace('tidecoat="#34575b"','tidecoat="#34575b", scarf="#a23e2f"').replace('morphs={"Fcl_EYE_Halfclose": .14}','morphs={"Fcl_EYE_Angry": .15, "Fcl_MTH_Fun": .12}') open(p,'w').write(s) PY sed -i 's/degToRad(57)/degToRad(47)/' review/high-water/shot.js OPENBLAS_NUM_THREADS=1 python3 review/high-water/figure.py && node review/high-water/shoot.cjsresult, 4 lines
Script completed Wall time 0.4 seconds Output: {"chunk_id":"890bfe","wall_time_seconds":0.250845972,"session_id":82419,"original_token_count":0,"output":""}write_stdinpoll session 82419
input
text(await tools.write_stdin({session_id:82419,chars:"",yield_time_ms:1000,max_output_tokens:750}))result, 4 lines
Script completed Wall time 3.0 seconds Output: {"chunk_id":"ba783d","wall_time_seconds":2.998985919,"exit_code":0,"original_token_count":0,"output":""}exec_commandpython3 - <<'PY'
command
python3 - <<'PY' from PIL import Image from pathlib import Path d=Path('review/out/high-water') im=Image.open(d/'figure.png'); print(im.getbbox()) bg=Image.new('RGB',im.size,'#e3cead'); bg.paste(im,mask=im.getchannel('A')); bg.thumbnail((820,820)); bg.save(d/'check.jpg') PYresult, 4 lines
Script completed Wall time 0.2 seconds Output: {"chunk_id":"69d6e1","wall_time_seconds":0.000003801,"exit_code":0,"original_token_count":6,"output":"(349, 43, 937, 1345)\n"}view_image~/work/lowmarch/review/out/high-water/check.jpg
input
image((await tools.view_image({path:"~/work/lowmarch/review/out/high-water/check.jpg"})).image_url)result, 4 lines
Script completed Wall time 0.0 seconds Output:
exec_commandsed -n '762,807p' tools/outfit.py
command
sed -n '762,807p' tools/outfit.py sed -n '938,959p' tools/outfit.py sed -n '190,229p' tools/gear.py ls -la ~/.local/share/fonts /usr/share/fonts/truetype 2>/dev/null ls -la review/out/high-water/browser
result, 4 lines
Script completed Wall time 0.3 seconds Output: {"chunk_id":"022237","wall_time_seconds":0.00000558,"exit_code":0,"original_token_count":1703,"output":" for j, t in enumerate(np.linspace(0, 1, rows)): # soft folds toward the hem\n P[:, j] += rad * (0.006 * t * np.sin(ang * 9 + 0.7))[:, None]\n P = push_out(P) # and nothing pokes through after settling\n pos, tri = grid_mesh(P)\n pc = piece(name, role, pos, tri, outward_from=nk + [0, -0.25, 0], axis=[0, 1, 0])\n fit.bind(pc, allow=(\"Neck\", \"UpperChest\", \"Shoulder\", \"Chest\"), fallback=\"J_Bip_C_UpperChest\")\n # the hood, folded down: a thick roll around the back half of the ring\n k = np.where(np.abs(ang) < math.radians(105))[0]\n lift = top[k] + rad[k] * 0.012 + np.array([0, 0.016, 0])\n hood = pipe(f\"{name}_hood\", role, lift, r=0.024, seg=10)\n w = np.abs(ang[k]) / math.radians(105) # the roll thins toward the shoulders\n hp = hood[\"pos\"].reshape(len(k), 11, 3)\n hp[:] = lift[:, None] + (hp - lift[:, None]) * (1 - 0.55 * w ** 2)[:, None, None]\n hood[\"pos\"] = hp.reshape(-1, 3)\n inherit(hood, pc)\n return pc, P, hood\n\n\ndef shield(fit, name, side=\"L\", radius=0.20, boss=0.045):\n \"\"\"A round wooden shield, painted with the house's arms, strapped to the forearm's outer side:\n a shallow dome in the signature colour, a cream chevron, a steel rim and boss.\"\"\"\n E, H = fit.bone[f\"J_Bip_{side}_LowerArm\"], fit.bone[f\"J_Bip_{side}_Hand\"]\n ax = (H - E) / np.linalg.norm(H - E)\n lat = np.array([-1.0 if side == \"L\" else 1.0, 0, 0.0])\n lat -= ax * (lat @ ax)\n lat /= np.linalg.norm(lat)\n centre = E + ax * np.linalg.norm(H - E) * 0.48 + lat * 0.075\n up = -ax # the shield's top points up the arm (toward the elbow)\n fw = np.cross(lat, up)\n rows, seg, depth = 9, 48, 0.035\n ph = np.linspace(0, 2 * math.pi, seg + 1)\n P = np.zeros((seg + 1, rows, 3))\n for j, t in enumerate(np.linspace(0, 1, rows)):\n P[:, j] = centre + lat * depth * (1 - t * t) + np.outer(radius * t * np.cos(ph), up) + np.outer(radius * t * np.sin(ph), fw)\n pos, tri, outer = thick_grid(P, 0.010, outward_from=centre - lat * 0.2)\n face = piece(name, \"signature\", pos, tri)\n surf = lambda u, v: centre + lat * (depth * (1 - (u * u + v * v)) + 0.0012) + up * u * radius + fw * v * radius\n nrm_at = lambda u, v: lat + (up * u + fw * v) * 2 * depth / radius\n chev = [(-0.48, -0.62), (0.10, -0.02), (-0.48, 0.58)] if side == \"L\" else [(-0.48, 0.62), (0.10, 0.02), (-0.48, -0.58)]\n line = []\n for (u0, v0), (u1, v1) in zip(chev[:-1], chev[1:]):\n for t in np.linspace(0, 1, 12, endpoint=False):\n line.append((u0 + (u1 - u0) * t, v0 + (v1 - v0) * t))\n line.append(chev[-1])\n pts = np.array([surf(u, v) for u, v in line])\n nr = np.array([nrm_at(u, v) for u, v in line])\n fit.bind(q_, rigid=f\"J_Bip_{side}_Foot\")\n return out\n\n\ndef knight_dress(fit):\n \"\"\"A blonde knight-princess: a long blue dress with a white petticoat edge, a fitted steel\n breastplate, small spaulders, steel gauntlets and armoured boots, a two-handed sword with a\n gold hilt, and her hair up in a braided bun with a ribbon.\"\"\"\n B = fit.bone\n nk, hips = B[\"J_Bip_C_Neck\"], B[\"J_Bip_C_Hips\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n out = []\n\n def grouped(pcs, g):\n for pc in pcs:\n if pc is not None:\n pc[\"group\"] = g\n return [pc for pc in pcs if pc is not None]\n\n def rolled(name, pc, rims, r=0.0024, role=\"metal\"):\n return [inherit(pipe(f\"{name}_roll{k}\", role, rim, r=r), pc) for k, rim in enumerate(rims)]\n\n cone = ConeChart(lambda u, v: np.vectorize(r0)(u) + flare * np.clip((y_waist - v) / (y_waist - y_hem), 0, 1.2) ** 1.2,\n cz=cz)\n sk_seams = [[(u, y_hem), (u, y_waist)] for u in us if abs(u) > split + 4]\n skirt, _ = outline_plate(f\"{name}_skirt\", role, cone, split, 360 - split, lambda u: y_hem, lambda u: y_waist + 0.012,\n offset=0.002, thickness=0.006, nu=110, nv=18, roll=0.004, roll_edges=(\"bottom\", \"left\", \"right\"),\n seams=[[((u % 360), a), ((u % 360), b)] for (u, a), (_, b) in sk_seams],\n groove=(0.004, 0.004), panel_crown=0.006, decal_px=600)\n fit.bind(skirt, allow=(\"Hips\", \"UpperLeg\"), fallback=\"J_Bip_C_Hips\")\n stiffen(skirt, fit, share=0.55)\n out.append(skirt)\n if sleeves:\n for side in (\"L\", \"R\"):\n for seg, (a, b, v0, v1) in enumerate(((f\"J_Bip_{side}_UpperArm\", f\"J_Bip_{side}_LowerArm\", -0.05, 1.02),\n (f\"J_Bip_{side}_LowerArm\", f\"J_Bip_{side}_Hand\", -0.02, sleeve_end))):\n arm = O.limb_surface(fit, (a.replace(\"J_Bip_\", \"\"), b.replace(\"J_Bip_\", \"\")), side)\n lc = LimbChart(arm, B[a], B[b], front=(0, 0, -1))\n sl_seams = [[(u, v0), (u, v1)] for u in range(-150, 180, 30)]\n sl, _ = outline_plate(f\"{name}_sleeve_{side}{seg}\", role, lc, -180, 180, lambda u, v1=v1: v1,\n lambda u, v0=v0: v0, offset=0.010, thickness=0.005, nu=48, nv=14, roll=0,\n seams=sl_seams, groove=(0.005, 0.003), panel_crown=0.004, decal_px=700)\n fit.bind(sl, allow=(a.replace(\"J_Bip_\", \"\"), b.replace(\"J_Bip_\", \"\")), fallback=a)\n out.append(sl)\n return _group(out, \"padding\")\n\n\ndef mail_shirt(fit, under, name=\"hauberk\", role=\"mail\", y_top=None, y_hem=None, sleeve=0.55, flare=0.05):\n \"\"\"A mail shirt over the coat: body to `y_hem`, short sleeves, rings painted as a decal, the hem\n scalloped into a ragged edge.\"\"\"\n B = fit.bone\n nk, hips = B[\"J_Bip_C_Neck\"], B[\"J_Bip_C_Hips\"]\n y_top = nk[1] - 0.05 if y_top is None else y_top\n y_hem = hips[1] - 0.12 if y_hem is None else y_hem\n cz = float(hips[2])\n y_waist = hips[1] + 0.06\n tc = TorsoChart(under, y_waist - 0.04, y_top + 0.03, cz=cz, du=3.0, dv=0.008)\n rings = (mail_pattern(256, 128), 0.12) # one tile of rings covers 12 cm\n body, _ = outline_plate(name, role, tc, -178, 178, lambda u: y_waist, lambda u: y_top - 0.02 * max(0, 1 - abs(u) / 60),\n offset=0.006, thickness=0.004, nu=96, nv=20, roll=0, pattern=rings)\n out = [body]\n r0 = lambda u: float(tc.radius(u, y_waist)) + 0.010\n/usr/share/fonts/truetype:\ntotal 28\ndrwxr-xr-x 6 nobody nogroup 4096 May 8 2023 .\ndrwxr-xr-x 8 nobody nogroup 4096 Oct 22 04:01 ..\n-rw-r--r-- 1 nobody nogroup 36 Apr 25 2023 .uuid\ndrwxr-xr-x 2 nobody nogroup 4096 Apr 25 2023 dejavu\ndrwxr-xr-x 2 nobody nogroup 4096 May 8 2023 droid\ndrwxr-xr-x 2 nobody nogroup 4096 May 8 2023 noto\ndrwxr-xr-x 2 nobody nogroup 4096 Apr 18 2023 ubuntu\ntotal 8\ndrwx------ 2 runner runner 4096 Nov 17 22:51 .\ndrwx------ 3 runner runner 4096 Nov 17 22:50 ..\n"}exec_commandpython3 - <<'PY'
command
python3 - <<'PY' p='review/high-water/figure.py' s=open(p).read().replace('[-.38, 1, .23]', '[.035, 1, .16]').replace('[-.045, 1, .38]', '[.035, 1, .16]').replace('poses.rot((0, 1, 0), -22)', 'poses.rot((0, 1, 0), -32)').replace(' -9),',' -12),') s=s.replace(' hand = rig.grip_points', ''' # Catch the brim with the far hand. The elbow opens to the side so the # glove and the bent sleeve separate from her face in three-quarter view. head = skeleton.pos(pose, "J_Bip_C_Head") pose = skeleton.arm_ik(pose, "L", head + [-.193, .073, -.048], [-.95, -.35, .15]) pose = skeleton.aim(pose, "J_Bip_L_Hand", [-1, 0, 0], [.26, .84, -.18]) hand = rig.grip_points''') s=s.replace(' # A long and a short', ''' for side in "LR": shoe = outfit.sabaton(fit, f"shoe_{side}", side, role="boot", pad=.017, ridges=0)[0] pieces.append(shoe) clasp = outfit.ball("mantle_pin", "gold", grid[0, 5] + [0, 0, -.007], .016, squash=(1, 1.15, .45)) pieces.append(fit.bind(clasp, rigid="J_Bip_C_UpperChest")) # A long and a short''') open(p,'w').write(s) PY sed -i 's/degToRad(47)/degToRad(62)/' review/high-water/shot.js OPENBLAS_NUM_THREADS=1 python3 review/high-water/figure.py && node review/high-water/shoot.cjsresult, 4 lines
Script completed Wall time 0.4 seconds Output: {"chunk_id":"499c58","wall_time_seconds":0.250985508,"session_id":34865,"original_token_count":0,"output":""}exec_commandls -l review/out/high-water/figure* && sed -n '932,945p' tools/outfit.py
command
ls -l review/out/high-water/figure* && sed -n '932,945p' tools/outfit.py python3 - <<'PY' import PIL.Image as I im=I.open('review/out/high-water/figure.png'); im.thumbnail((820,820)); bg=I.new('RGB',im.size,'#d1c7b5');bg.paste(im,mask=im.getchannel('A')); bg.save('review/out/high-water/check.jpg') PYresult, 4 lines
Script completed Wall time 0.3 seconds Output: {"chunk_id":"706b98","wall_time_seconds":0.11678047,"exit_code":0,"original_token_count":215,"output":"-rw------- 1 runner runner 4733496 Nov 17 22:51 review/out/high-water/figure.glb\n-rw------- 1 runner runner 544414 Nov 17 22:51 review/out/high-water/figure.png\n out = [pc]\n for k, t in enumerate(np.linspace(0.50, 0.74, ridges)): # lames over the instep\n i = int(round(t * (seg - 1)))\n ring = G[i, 1:-1] + np.stack([np.cos(phi[1:-1]), np.sin(phi[1:-1]) * 1.0, np.zeros(rows - 2)], 1) * 0.0018\n out.append(pipe(f\"{name}_ridge{k}\", role, ring, r=0.0024))\n for q_ in out:\n fit.bind(q_, rigid=f\"J_Bip_{side}_Foot\")\n return out\n\n\ndef knight_dress(fit):\n \"\"\"A blonde knight-princess: a long blue dress with a white petticoat edge, a fitted steel\n breastplate, small spaulders, steel gauntlets and armoured boots, a two-handed sword with a\n gold hilt, and her hair up in a braided bun with a ribbon.\"\"\"\n"}exec_commandcat > review/high-water/marsh.py <<'PY'
command
cat > review/high-water/marsh.py <<'PY' """Set the painted figure into an original tidal crossing. All coordinates are in the final frame.""" import argparse import math import random from pathlib import Path import numpy as np from PIL import Image, ImageColor, ImageDraw, ImageFilter, ImageOps HERE = Path(__file__).resolve().parent CACHE = HERE.parents[1] / "review/out/high-water" W, H = 1600, 900 HORIZON = 440 rng = random.Random(48) rand = np.random.default_rng(48) def rgb(c): return np.array(ImageColor.getrgb(c), float) def mix(a, b, t): return tuple((np.array(a) * (1-t) + np.array(b) * t).astype(int)) def fine_noise(w, h, cell): grid = rand.integers(0, 256, (max(2, h//cell), max(2, w//cell)), dtype=np.uint8) return np.asarray(Image.fromarray(grid).resize((w,h), Image.Resampling.BICUBIC)).astype(float) / 255 - .5 def sky(): y, x = np.mgrid[:H, :W] f = np.clip((y+35) / (HORIZON+35), 0, 1)**.92 base = rgb("#94adb2") + f[..., None] * (rgb("#f2d3a7") - rgb("#94adb2")) sun = np.exp(-((x-1195)/435)**2-((y-286)/235)**2) base += sun[..., None] * [22, 17, 9] return Image.fromarray(np.uint8(np.clip(base, 0, 255))).convert("RGBA") def cloud(layer, x, y, length, height, colour, seed): """Stretched banks of cloud. A shared upper contour gives each bank a few torn veils.""" r = random.Random(seed) u = np.linspace(0, 1, 176) shape = np.sin(np.pi*u)**.71 knots = np.linspace(0, 1, 22) bank = np.interp(u, knots, [r.uniform(.10, .68) for _ in knots]) for _ in range(7): c, width, high = r.uniform(.09,.9), r.uniform(.045,.125), r.uniform(.23,.65) bank += high*np.exp(-((u-c)/width)**2) curl = np.interp(u, np.linspace(0, 1, 50), [r.uniform(-.11, .11) for _ in range(50)]) top = y - height*shape*(bank+curl) - 12*u low = y + height*shape*(.12+.1*np.sin(16*u)) - 12*u pts = np.column_stack([x + u*length, top]).tolist() + np.column_stack([x + u[::-1]*length, low[::-1]]).tolist() draw = ImageDraw.Draw(layer) draw.polygon([tuple(p) for p in pts], fill=colour) for _ in range(9): k = r.uniform(.05,.84) xx, yy = x + k*length, y + r.uniform(.13,.50)*height - k*12 w = length*r.uniform(.06,.19) draw.polygon([(xx, yy), (xx+w*.29, yy-2), (xx+w, yy-3), (xx+w*.5, yy+1)], fill=colour) def ridge(im, points, colour, rough, seed): r = random.Random(seed) px, py = zip(*points) x = np.arange(-4, W+5, 3) y = np.interp(x, px, py) for size, amp in [(95, rough), (22, rough*.42), (6, rough*.22)]: knots = np.arange(-100, W+110, size) y += np.interp(x, knots, [r.uniform(-amp,amp) for _ in knots]) contour = [(int(xx), round(yy)) for xx,yy in zip(x,y)] ImageDraw.Draw(im).polygon(contour+[(W,H),(0,H)],fill=colour) return contour def gate(im): """A drowned gatehouse and its approach. Cut the openings right through both walls.""" stone = Image.new("RGBA",im.size) d = ImageDraw.Draw(stone) near, side, cap, hollow = "#899993", "#7e918f", "#a3a89b", (0,0,0,0) # A squat stone bridge, with wedge-shaped stone cutwaters on its piers. d.polygon([(958,425),(1278,399),(1278,447),(950,448)], fill=near) for i in range(8): x = 966+i*38 y = 425-i*3.2 d.ellipse((x,y+6,x+29,y+48),fill=hollow) d.polygon([(x+28,y+21),(x+34,y+14),(x+39,y+19),(x+41,443),(x+32,444)],fill=side) d.polygon([(948,425),(1278,398),(1278,402),(945,430)],fill=cap) for x in range(966,1256,19): y = 425-(x-958)*.08 d.line([(x,y-2),(x,y+2)], fill=near) # Low gatehouse, an open belfry with a broken outer stair. d.polygon([(1191,435),(1191,365),(1226,363),(1228,431)],fill=near) d.polygon([(1226,363),(1240,368),(1240,427),(1228,431)], fill=side) d.polygon([(1187,367),(1189,362),(1225,359),(1243,365),(1240,369),(1226,365)],fill=cap) d.polygon([(1192,362),(1195,338),(1208,337),(1210,321),(1214,337),(1226,336),(1226,360)], fill=near) d.polygon([(1226,336),(1236,342),(1239,364),(1226,360)],fill=side) d.polygon([(1189,340),(1193,334),(1215,316),(1239,340),(1238,344),(1225,339),(1214,326),(1200,339)],fill=cap) for xx,yy,rw,rh in [(1198,343,7,15),(1211,341,8,16),(1201,382,9,18),(1229,346,4,11)]: d.polygon([(xx,yy+rh),(xx,yy+4),(xx+rw/2,yy),(xx+rw,yy+4),(xx+rw,yy+rh)],fill=hollow) d.line([(1215,321),(1215,303)],fill=side,width=2) d.polygon([(1215,304),(1206,305),(1198,303),(1186,308),(1202,310),(1215,308)], fill="#b49174") for x in [1178,1181,1185,1248,1253]: y = 394 - (x%3)*3 d.polygon([(x,428),(x,y),(x+3,y+1),(x+4,426)],fill=side) for x,y in [(1195,355),(1202,370),(1217,378),(1191,388),(1233,377),(1195,404)]: d.line([(x,y),(x+4,y)],fill=cap) im.alpha_composite(stone) def bird(d, x, y, s, lift): d.polygon([(x-12*s,y-4*s),(x-8*s,y-5*s),(x-2*s,y-2*s),(x,y), (x+4*s,y-lift*s),(x+10*s,y-(lift-2)*s),(x+4*s,y-(lift-2.9)*s), (x+s,y+2*s),(x-2*s,y+s),(x-7*s,y-3*s)],fill="#778a8e") def water(im): y, x = np.mgrid[:H-HORIZON,:W] f = (y / (H-HORIZON))**.62 field = rgb("#bcc4af") + f[...,None]*(rgb("#729598")-rgb("#bcc4af")) glint = np.exp(-((x-1130)/(165+y*.19))**2) field += glint[...,None]*[23,17,9] d = ImageDraw.Draw(im) top = np.asarray(im.convert("RGB")) sy = np.clip((HORIZON-1-y*.83+3.6*np.sin(.063*y+.007*x)).astype(int), 0, HORIZON-1) sx = np.clip((x+(2+y*.016)*np.sin(y*.32+np.sin(x*.025)*.8)).astype(int),0,W-1) reflection = top[sy,sx] reflectivity = (.30*(1-.5*f))[...,None] field = field*(1-reflectivity)+reflection*reflectivity field += (2.7*np.sin(.16*y+.50*np.sin(.013*x)+x*.003) + fine_noise(W,H-HORIZON,58)*4)[...,None] im.paste(Image.fromarray(np.uint8(np.clip(field,0,255))), (0,HORIZON)) # Ripples are short in the distance and grow broad as they approach the bank. for _ in range(1750): yy = HORIZON + (H-HORIZON)*rng.random()**1.5 xx = rng.uniform(-60,W) f = (yy-HORIZON)/(H-HORIZON) base = np.array(im.getpixel((int(np.clip(xx,0,W-1)),min(int(yy),H-1)))[:3]) light = rng.random() < .52+.18*math.exp(-((xx-1130)/250)**2) ink = rgb("#ffdf9f" if light and abs(xx-1130)<200 else "#e2d8b8" if light else "#537f81") c = mix(base,ink,rng.uniform(.18,.54)) w = rng.uniform(5,37)*(f*1.5+.28) dy = rng.uniform(-1.5,1.5)*f d.polygon([(xx,yy),(xx+w*.35, yy-1.4*f),(xx+w, yy+dy),(xx+w*.55,yy+1.7*f+dy)],fill=c) for yy in [446,451,462]: d.line([(7,yy),(330,yy-1),(533,yy)],fill="#bac0aa") def island(im, pts, top, side, depth, seed): """A broken flagstone, flat at the waterline, with a sunlit lip and a shaded face.""" r = random.Random(seed) d = ImageDraw.Draw(im) d.polygon([(x+2,y+depth+2) for x,y in pts],fill="#77928b") d.polygon([(x,y+depth) for x,y in pts],fill=side) d.polygon(pts,fill=top) left = min(x for x,y in pts) right = max(x for x,y in pts) for i,(x,y) in enumerate(pts): xx,yy = pts[(i+1)%len(pts)] if abs(xx-x)>12 and yy>min(y for _,y in pts)+3: d.line([(x,y),(xx,yy)],fill=mix(rgb(top),rgb("#e8d7af"),.4),width=1) ymid = sum(y for x,y in pts)//len(pts) for _ in range(int((right-left)/19)): x = r.uniform(left+.15*(right-left), right-.15*(right-left)) d.line([(x,ymid),(x+r.uniform(2,10),ymid-1)],fill=mix(rgb(top),rgb(side),.32)) def shore(im): d = ImageDraw.Draw(im) # Low bars interrupt the mirrored sky. Their taper points toward the old crossing. for j in range(19): x = rng.choice([rng.uniform(-180,410),rng.uniform(1240,1630)]) y = 446 + j*2.5 + rng.uniform(-3,3) w = rng.uniform(25,145) d.polygon([(x-w,y+2),(x-w*.5,y),(x,y-2-j*.09),(x+w*.62,y-1),(x+w,y+1)], fill=mix(rgb("#9fae97"),rgb("#839b88"),j/22)) path = [(764,759,96),(862,707,70),(942,661,55),(1003,629,47), (1061,600,32),(1110,579,26),(1147,560,21),(1176,546,17),(1200,535,12)] for i,(x,y,w) in reversed(list(enumerate(path))): pts = [(x-w,y+1),(x-w*.66,y-w*.11),(x+.18*w,y-.15*w),(x+w,y-.04*w), (x+w*.78,y+.065*w),(x-w*.48,y+.08*w)] island(im,pts,"#a4a99b","#819591", max(1,round(w*.035)), 4+i) # The ledge beneath her boots: weathered paving disappearing under water. shorepts = [(-20,686),(35,683),(134,698),(208,689),(280,702),(323,714),(393,707),(460,721), (548,719),(589,731),(653,730),(686,741),(669,753),(608,760),(566,770),(479,770), (423,789),(355,795),(289,827),(181,844),(91,885),(-20,887)] d.polygon([(x,y+15) for x,y in shorepts],fill="#4e6769") d.polygon(shorepts,fill="#7c8171") for pts,c in [ ([(-2,695),(216,702),(285,719),(213,730),(48,727)],"#9b9d83"), ([(220,702),(278,701),(380,718),(399,743),(251,738),(215,729)],"#9a9a82"), ([(399,722),(455,721),(495,731),(478,747),(411,743)],"#b0ad8e"), ([(504,729),(557,725),(584,736),(552,746),(486,747)],"#bcb497"), ([(588,736),(646,733),(680,742),(670,749),(599,755),(560,749)],"#c1b99b"), ([(389,749),(479,752),(544,753),(510,766),(428,780),(342,777)],"#a19f85"), ([(215,735),(312,739),(381,748),(338,777),(264,786),(174,771)],"#92947e"), ([(79,733),(171,736),(196,750),(155,767),(41,761)],"#888e78"), ([(25,773),(105,771),(154,781),(113,813),(8,850)],"#7f8977") ]: d.polygon(pts, fill=c) for x,y in [(444,736),(505,759),(605,737),(285,758),(132,741),(632,747)]: d.line([(x-9,y-2),(x,y),(x+5,y+3),(x+14,y+4)], fill="#82877a",width=1) d.line([(265,832),(300,824),(357,801),(424,794),(484,776),(550,777)],fill="#c4c2a5",width=2) d.line([(488,781),(556,780),(603,767),(638,762),(686,749)],fill="#bac2af",width=2) def reeds(im, x, y, scale, count, palette, seed): r = random.Random(seed) d = ImageDraw.Draw(im) for k in range(count): base = x + r.gauss(0,scale*.46) h = scale*r.uniform(.22,1.04) yy = y + r.gauss(0,scale*.032) bend, width = h*r.uniform(-.55,.16), max(1,h*r.uniform(.020,.036)) col = r.choice(palette) ts = np.linspace(0,1,13) xx = base + bend*ts**1.45 - .10*h*ts heights = yy-h*ts blade = list(zip(xx - width*(1-ts), heights)) + list(zip((xx+width*(1-ts))[::-1], heights[::-1])) d.polygon(blade,fill=col) if k%5 == 0 and h>28: xx0,yy0=xx[-1],heights[-1] tilt = (xx[-1]-xx[-4])/(heights[-1]-heights[-4]) for j in range(7): t = j/7 h0 = h*.18*t half = math.sin((.12+.8*t)*math.pi)*h*.032 d.polygon([(xx0-tilt*h0,yy0-h0),(xx0-tilt*h0-half,yy0-h0-h*.040), (xx0-tilt*h0,yy0-h0-h*.018),(xx0-tilt*h0+half*.8,yy0-h0-h*.052)], fill=col) def surface_rings(im,x,y,rx,colour): d = ImageDraw.Draw(im) for factor, spans in [(1,[(9,85),(107,188),(225,279),(301,355)]),(.64,[(16,160),(200,276)]),(.33,[(0,207)])]: a=rx*factor rect=(x-a,y-a*.105,x+a,y+a*.105) for start,end in spans: d.arc(rect,start,end,fill=colour,width=2 if rx>35 else 1) def compose(output): im = sky() air = Image.new("RGBA",im.size) cloud(air,-300,169,1180,61,"#c2c4bc",15) cloud(air,-230,155,958,50,"#d6cfc0",15) cloud(air,-135,122,844,28,"#e4d8c2",12) cloud(air,500,156,602,27,"#cecfc1",68) cloud(air,922,205,735,52,"#dbd5bf",20) cloud(air,1110,198,581,47,"#ece0c6",34) cloud(air,81,265,686,20,"#e4d9bf",32) cloud(air,-73,325,1044,16,"#e5d5b8",65) im.alpha_composite(air) d = ImageDraw.Draw(im) d.ellipse((1114,197,1242,325),fill="#fae8bf") cloud(im,946,299,545,5,"#ebdab9",42) ridge(im,[(-5,341),(144,354),(277,382),(425,368),(600,394),(787,371),(939,355),(1130,382),(1340,327),(1475,320),(1604,289)],"#bac0b2",6,12) ridge(im,[(-5,365),(106,374),(287,386),(442,403),(633,392),(805,414),(967,393),(1146,405),(1312,371),(1490,357),(1604,341)],"#a9b5a9",4,17) ridge(im,[(-5,388),(152,383),(312,408),(467,424),(636,418),(800,434),(963,414),(1132,418),(1269,398),(1460,386),(1603,367)],"#98a9a0",4,19) gate(im) for x,y,s,lift in [(941,265,1.05,6),(1005,249,.75,9),(1057,265,.56,5),(991,275,.57,7),(1098,257,.45,8)]: bird(d,x,y,s,lift) ridge(im,[(0,419),(95,412),(223,421),(386,430),(572,439),(796,443),(958,435),(1089,438),(1246,426),(1421,417),(1600,408)],"#899e91",2.8,23) water(im) shore(im) for i in range(30): x = rng.uniform(-35,370); y = 705 + x*.03 + rng.uniform(-2,32) reeds(im,x,y,rng.uniform(8,36),rng.randint(4,20),["#727e69","#899176","#a8a180"],i+40) # Figure reflection is laid in before the figure. Broken horizontal bands carry the coat colour into the water. actor = Image.open(CACHE/"figure.png").convert("RGBA") actor = actor.resize((round(actor.width*.56),round(actor.height*.56)),Image.Resampling.LANCZOS) anchor_x, anchor_y = 190, -2 waterline = 744 refl = ImageOps.flip(actor).resize((actor.width, round(actor.height*.69)),Image.Resampling.BILINEAR) reflected = np.array(refl) reflected[..., :3] = reflected[..., :3]*.53 + rgb("#89a39e")*.47 reflected[..., 3] = (reflected[...,3]*.28).astype(np.uint8) reflected = Image.fromarray(reflected) for i in range(0,165,3): dx = int(3*math.sin(i*.18) + 3*math.sin(i*.64) + i*.022) strip = reflected.crop((0,i+28,actor.width,i+30)) if i%15 != 0: im.alpha_composite(strip,(anchor_x+dx,waterline+i)) im.alpha_composite(actor,(anchor_x,anchor_y)) for x,y,scale,count,i in [(22,865,149,74,12),(115,811,69,28,28),(160,790,33,11,31), (1550,907,92,30,14),(1604,884,140,37,25),(1460,884,53,15,57)]: reeds(im,x,y,scale,count,["#435b59","#576d63","#687865","#8c9073"],i) # A fine common paper tooth puts the sky, shaded mesh and water on the same surface. base = np.array(im.convert("RGB"),dtype=float) y,x = np.ogrid[:H,:W] tooth = rand.normal(0,1.7,(H,W)) + 2.3*fine_noise(W,H,9) + 3*fine_noise(W,H,60) vignette = 2.2*((x-W*.5)/(W*.5))**2+1.7*((y-H*.5)/(H*.5))**2 out = np.uint8(np.clip(base+(tooth-vignette)[...,None],0,255)) Image.fromarray(out).save(output,quality=94,subsampling=0,optimize=True) if __name__ == "__main__": parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("output",type=Path) compose(parser.parse_args().output) PY python3 review/high-water/marsh.py review/out/high-water/crossing.jpg python3 - <<'PY' from PIL import Image im=Image.open('review/out/high-water/crossing.jpg'); im.thumbnail((1040,600)); im.save('review/out/high-water/marsh-check.jpg') PYresult, 4 lines
Script completed Wall time 0.4 seconds Output: {"chunk_id":"cf4c38","wall_time_seconds":0.251006434,"session_id":68741,"original_token_count":0,"output":""}write_stdinpoll session 34865 (+1 more)
input
await Promise.allSettled([tools.write_stdin({session_id:34865,chars:"",yield_time_ms:250,max_output_tokens:200}),tools.write_stdin({session_id:68741,chars:"",yield_time_ms:250,max_output_tokens:250})]).then(text)result, 4 lines
Script completed Wall time 0.0 seconds Output: [{"status":"fulfilled","value":{"chunk_id":"c37db4","wall_time_seconds":0.0000032,"exit_code":0,"original_token_count":0,"output":""}},{"status":"fulfilled","value":{"chunk_id":"38c797","wall_time_seconds":6e-7,"exit_code":0,"original_token_count":0,"output":""}}]view_image~/work/lowmarch/review/out/high-water/marsh-check.jpg
input
image((await tools.view_image({path:"~/work/lowmarch/review/out/high-water/marsh-check.jpg"})).image_url)result, 4 lines
Script completed Wall time 0.0 seconds Output:
view_image~/work/lowmarch/review/out/high-water/crossing.jpg
input
image((await tools.view_image({path:"~/work/lowmarch/review/out/high-water/crossing.jpg"})).image_url)result, 4 lines
Script completed Wall time 0.0 seconds Output:
agent
+11:45The first painted frame showed two problems the turntable hid. The staff crossed the face, and the forward boot looked suspended over the water. I’ve opened up the pose and am fitting the stones and ripples to the actual points of contact.



