a2a-source-edit: write agent.py
This commit is contained in:
29
agent.py
29
agent.py
@@ -383,43 +383,40 @@ def _asset_body(asset_type: str, style: str, primary: str, accent: str, dark: st
|
|||||||
fill = "none" if style == "outline" else primary
|
fill = "none" if style == "outline" else primary
|
||||||
common = f'stroke="{dark}" stroke-width="{stroke}" stroke-linejoin="round" stroke-linecap="round"'
|
common = f'stroke="{dark}" stroke-width="{stroke}" stroke-linejoin="round" stroke-linecap="round"'
|
||||||
|
|
||||||
def p(amount: float) -> str:
|
|
||||||
return _scale(unit, amount)
|
|
||||||
|
|
||||||
if asset_type == "character":
|
if asset_type == "character":
|
||||||
return (
|
return (
|
||||||
f'<circle cx="{p(8)}" cy="{p(4.2)}" r="{p(2.1)}" fill="{fill}" {common}/>'
|
f'<circle cx="{_scale(unit, 8)}" cy="{_scale(unit, 4.2)}" r="{_scale(unit, 2.1)}" fill="{fill}" {common}/>'
|
||||||
f'<path d="M {p(5)} {p(7)} H {p(11)} L {p(12)} {p(13)} H {p(4)} Z" fill="{fill}" {common}/>'
|
f'<path d="M {_scale(unit, 5)} {_scale(unit, 7)} H {_scale(unit, 11)} L {_scale(unit, 12)} {_scale(unit, 13)} H {_scale(unit, 4)} Z" fill="{fill}" {common}/>'
|
||||||
f'<circle cx="{p(7.25)}" cy="{p(4)}" r="{p(.35)}" fill="{accent}"/><circle cx="{p(8.75)}" cy="{p(4)}" r="{p(.35)}" fill="{accent}"/>'
|
f'<circle cx="{_scale(unit, 7.25)}" cy="{_scale(unit, 4)}" r="{_scale(unit, .35)}" fill="{accent}"/><circle cx="{_scale(unit, 8.75)}" cy="{_scale(unit, 4)}" r="{_scale(unit, .35)}" fill="{accent}"/>'
|
||||||
)
|
)
|
||||||
if asset_type == "enemy":
|
if asset_type == "enemy":
|
||||||
spike_points: list[str] = []
|
spike_points: list[str] = []
|
||||||
for i in range(7):
|
for i in range(7):
|
||||||
spike_points.append(f'{p(2 + i * 2)},{p(7 + ((pattern + i) % 3))}')
|
spike_points.append(f'{_scale(unit, 2 + i * 2)},{_scale(unit, 7 + ((pattern + i) % 3))}')
|
||||||
spike_points_text = " ".join(spike_points)
|
spike_points_text = " ".join(spike_points)
|
||||||
return (
|
return (
|
||||||
f'<polygon points="{p(8)},{p(2)} {p(14)},{p(8)} {p(11)},{p(14)} {p(5)},{p(14)} {p(2)},{p(8)}" fill="{fill}" {common}/>'
|
f'<polygon points="{_scale(unit, 8)},{_scale(unit, 2)} {_scale(unit, 14)},{_scale(unit, 8)} {_scale(unit, 11)},{_scale(unit, 14)} {_scale(unit, 5)},{_scale(unit, 14)} {_scale(unit, 2)},{_scale(unit, 8)}" fill="{fill}" {common}/>'
|
||||||
f'<polyline points="{spike_points_text}" fill="none" stroke="{accent}" stroke-width="{stroke}"/>'
|
f'<polyline points="{spike_points_text}" fill="none" stroke="{accent}" stroke-width="{stroke}"/>'
|
||||||
f'<circle cx="{p(6)}" cy="{p(8)}" r="{p(.55)}" fill="{dark}"/><circle cx="{p(10)}" cy="{p(8)}" r="{p(.55)}" fill="{dark}"/>'
|
f'<circle cx="{_scale(unit, 6)}" cy="{_scale(unit, 8)}" r="{_scale(unit, .55)}" fill="{dark}"/><circle cx="{_scale(unit, 10)}" cy="{_scale(unit, 8)}" r="{_scale(unit, .55)}" fill="{dark}"/>'
|
||||||
)
|
)
|
||||||
if asset_type == "item":
|
if asset_type == "item":
|
||||||
return (
|
return (
|
||||||
f'<path d="M {p(8)} {p(2)} L {p(13)} {p(7)} L {p(8)} {p(14)} L {p(3)} {p(7)} Z" fill="{fill}" {common}/>'
|
f'<path d="M {_scale(unit, 8)} {_scale(unit, 2)} L {_scale(unit, 13)} {_scale(unit, 7)} L {_scale(unit, 8)} {_scale(unit, 14)} L {_scale(unit, 3)} {_scale(unit, 7)} Z" fill="{fill}" {common}/>'
|
||||||
f'<path d="M {p(8)} {p(3.7)} L {p(10.8)} {p(7)} L {p(8)} {p(12)} L {p(5.2)} {p(7)} Z" fill="{accent}" opacity="0.85"/>'
|
f'<path d="M {_scale(unit, 8)} {_scale(unit, 3.7)} L {_scale(unit, 10.8)} {_scale(unit, 7)} L {_scale(unit, 8)} {_scale(unit, 12)} L {_scale(unit, 5.2)} {_scale(unit, 7)} Z" fill="{accent}" opacity="0.85"/>'
|
||||||
)
|
)
|
||||||
if asset_type == "tile":
|
if asset_type == "tile":
|
||||||
tiles: list[str] = []
|
tiles: list[str] = []
|
||||||
for x in (2, 5, 8, 11):
|
for x in (2, 5, 8, 11):
|
||||||
for y in (2, 5, 8, 11):
|
for y in (2, 5, 8, 11):
|
||||||
color = primary if (x + y + pattern) % 2 else accent
|
color = primary if (x + y + pattern) % 2 else accent
|
||||||
tiles.append(f'<rect x="{p(x)}" y="{p(y)}" width="{p(3)}" height="{p(3)}" fill="{color}" {common} opacity="0.9"/>')
|
tiles.append(f'<rect x="{_scale(unit, x)}" y="{_scale(unit, y)}" width="{_scale(unit, 3)}" height="{_scale(unit, 3)}" fill="{color}" {common} opacity="0.9"/>')
|
||||||
return "".join(tiles)
|
return "".join(tiles)
|
||||||
if asset_type == "projectile":
|
if asset_type == "projectile":
|
||||||
return (
|
return (
|
||||||
f'<path d="M {p(2)} {p(9)} C {p(6)} {p(3)}, {p(10)} {p(3)}, {p(14)} {p(7)} C {p(10)} {p(8)}, {p(7)} {p(10)}, {p(2)} {p(9)} Z" fill="{fill}" {common}/>'
|
f'<path d="M {_scale(unit, 2)} {_scale(unit, 9)} C {_scale(unit, 6)} {_scale(unit, 3)}, {_scale(unit, 10)} {_scale(unit, 3)}, {_scale(unit, 14)} {_scale(unit, 7)} C {_scale(unit, 10)} {_scale(unit, 8)}, {_scale(unit, 7)} {_scale(unit, 10)}, {_scale(unit, 2)} {_scale(unit, 9)} Z" fill="{fill}" {common}/>'
|
||||||
f'<path d="M {p(3)} {p(9)} L {p(1)} {p(6)} M {p(3.4)} {p(9.5)} L {p(1)} {p(12)}" stroke="{accent}" stroke-width="{stroke}"/>'
|
f'<path d="M {_scale(unit, 3)} {_scale(unit, 9)} L {_scale(unit, 1)} {_scale(unit, 6)} M {_scale(unit, 3.4)} {_scale(unit, 9.5)} L {_scale(unit, 1)} {_scale(unit, 12)}" stroke="{accent}" stroke-width="{stroke}"/>'
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
f'<rect x="{p(4)}" y="{p(4)}" width="{p(8)}" height="{p(8)}" rx="{p(1.4)}" fill="{fill}" {common}/>'
|
f'<rect x="{_scale(unit, 4)}" y="{_scale(unit, 4)}" width="{_scale(unit, 8)}" height="{_scale(unit, 8)}" rx="{_scale(unit, 1.4)}" fill="{fill}" {common}/>'
|
||||||
f'<path d="M {p(8)} {p(3)} V {p(13)} M {p(3)} {p(8)} H {p(13)}" stroke="{accent}" stroke-width="{stroke}"/>'
|
f'<path d="M {_scale(unit, 8)} {_scale(unit, 3)} V {_scale(unit, 13)} M {_scale(unit, 3)} {_scale(unit, 8)} H {_scale(unit, 13)}" stroke="{accent}" stroke-width="{stroke}"/>'
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user