a2a-source-edit: write agent.py
This commit is contained in:
12
agent.py
12
agent.py
@@ -330,8 +330,8 @@ def _slugify(value: str) -> str:
|
||||
return slug or "game-asset"
|
||||
|
||||
|
||||
def _scale(unit: float, n: float) -> str:
|
||||
return f"{n * unit:.2f}"
|
||||
def _scale(unit: float, amount: float) -> str:
|
||||
return f"{amount * unit:.2f}"
|
||||
|
||||
|
||||
def _render_svg(
|
||||
@@ -382,7 +382,10 @@ def _render_svg(
|
||||
def _asset_body(asset_type: str, style: str, primary: str, accent: str, dark: str, stroke: int, unit: float, pattern: int) -> str:
|
||||
fill = "none" if style == "outline" else primary
|
||||
common = f'stroke="{dark}" stroke-width="{stroke}" stroke-linejoin="round" stroke-linecap="round"'
|
||||
p = lambda n: _scale(unit, n)
|
||||
|
||||
def p(amount: float) -> str:
|
||||
return _scale(unit, amount)
|
||||
|
||||
if asset_type == "character":
|
||||
return (
|
||||
f'<circle cx="{p(8)}" cy="{p(4.2)}" r="{p(2.1)}" fill="{fill}" {common}/>'
|
||||
@@ -393,9 +396,10 @@ def _asset_body(asset_type: str, style: str, primary: str, accent: str, dark: st
|
||||
spike_points: list[str] = []
|
||||
for i in range(7):
|
||||
spike_points.append(f'{p(2 + i * 2)},{p(7 + ((pattern + i) % 3))}')
|
||||
spike_points_text = " ".join(spike_points)
|
||||
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'<polyline points="{" ".join(spike_points)}" 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}"/>'
|
||||
)
|
||||
if asset_type == "item":
|
||||
|
||||
Reference in New Issue
Block a user