Spaces:
Running on Zero
Running on Zero
Make projectiles vary with theme
Browse files
app.py
CHANGED
|
@@ -392,17 +392,29 @@ def draw_sprite(spec: AssetSpec, rng: random.Random) -> bytes:
|
|
| 392 |
|
| 393 |
if role in ("bullet", "projectile", "laser", "shot") or any(word in role_prompt for word in ("bullet", "projectile", "laser", "energy")):
|
| 394 |
glow = colors[1] + (85,)
|
| 395 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
draw.rounded_rectangle(
|
| 397 |
-
(cx -
|
| 398 |
radius=int(9 * scale),
|
| 399 |
fill=outline,
|
| 400 |
)
|
| 401 |
draw.rounded_rectangle(
|
| 402 |
-
(cx -
|
| 403 |
radius=int(5 * scale),
|
| 404 |
fill=accent,
|
| 405 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
out = io.BytesIO()
|
| 407 |
image.save(out, format="PNG")
|
| 408 |
return out.getvalue()
|
|
|
|
| 392 |
|
| 393 |
if role in ("bullet", "projectile", "laser", "shot") or any(word in role_prompt for word in ("bullet", "projectile", "laser", "energy")):
|
| 394 |
glow = colors[1] + (85,)
|
| 395 |
+
core_width = rng.randint(7, 13) * scale
|
| 396 |
+
core_height = rng.randint(30, 44) * scale
|
| 397 |
+
glow_width = core_width + rng.randint(18, 30) * scale
|
| 398 |
+
glow_height = core_height + rng.randint(12, 25) * scale
|
| 399 |
+
draw.ellipse((cx - glow_width, cy - glow_height, cx + glow_width, cy + glow_height), fill=glow)
|
| 400 |
draw.rounded_rectangle(
|
| 401 |
+
(cx - core_width, cy - core_height, cx + core_width, cy + core_height),
|
| 402 |
radius=int(9 * scale),
|
| 403 |
fill=outline,
|
| 404 |
)
|
| 405 |
draw.rounded_rectangle(
|
| 406 |
+
(cx - max(2, core_width - 4 * scale), cy - max(8, core_height - 6 * scale), cx + max(2, core_width - 4 * scale), cy + max(8, core_height - 6 * scale)),
|
| 407 |
radius=int(5 * scale),
|
| 408 |
fill=accent,
|
| 409 |
)
|
| 410 |
+
for _ in range(5):
|
| 411 |
+
px = cx + rng.randint(-24, 24) * scale
|
| 412 |
+
py = cy + rng.randint(-38, 38) * scale
|
| 413 |
+
draw.line(
|
| 414 |
+
(px, py, px + rng.randint(-10, 10) * scale, py + rng.randint(-8, 8) * scale),
|
| 415 |
+
fill=trim,
|
| 416 |
+
width=max(1, int(2 * scale)),
|
| 417 |
+
)
|
| 418 |
out = io.BytesIO()
|
| 419 |
image.save(out, format="PNG")
|
| 420 |
return out.getvalue()
|