Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -544,6 +544,17 @@ LEAF_HERO_HEAD = r"""
|
|
| 544 |
const haze = ctx.createRadialGradient(cx, cy, 0, cx, cy, baseR * 4);
|
| 545 |
haze.addColorStop(0, `rgba(${r},${g},${b},${0.12 * k})`); haze.addColorStop(0.4, `rgba(${r},${g},${b},${0.04 * k})`); haze.addColorStop(1, `rgba(${r},${g},${b},0)`);
|
| 546 |
ctx.fillStyle = haze; ctx.beginPath(); ctx.arc(cx, cy, baseR * 4, 0, TAU); ctx.fill();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 547 |
const badgeR = baseR * 0.95, badge = ctx.createRadialGradient(cx, cy - badgeR * 0.15, badgeR * 0.2, cx, cy, badgeR);
|
| 548 |
badge.addColorStop(0, "#8fcb5e"); badge.addColorStop(1, "#3c8b22");
|
| 549 |
ctx.fillStyle = badge; ctx.beginPath(); ctx.arc(cx, cy, badgeR, 0, TAU); ctx.fill();
|
|
@@ -576,20 +587,38 @@ LEAF_HERO_HEAD = r"""
|
|
| 576 |
const bg = ctx.createRadialGradient(cx, cy, 0, cx, cy, Math.max(width, height) * 0.85);
|
| 577 |
bg.addColorStop(0, "#f0fae0"); bg.addColorStop(0.4, "#e4f4cc"); bg.addColorStop(1, "#d2eaab");
|
| 578 |
ctx.fillStyle = bg; ctx.fillRect(0, 0, width, height);
|
| 579 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
const dRef = D_NEAR * 3.3, left = -width * 0.12, right = width * 1.12, top = -height * 0.12, bottom = height * 1.12;
|
| 581 |
-
|
| 582 |
project(sx[s] - DIR.x * dist, sy[s] - DIR.y * dist, sz[s] - DIR.z * dist);
|
| 583 |
if (!P.ok || P.depth > D_FAR * 1.25) { seedStar(s); continue; }
|
| 584 |
if (P.x < left || P.x > right || P.y < top || P.y > bottom) { seedStar(s, undefined, P.x < left ? 1 : P.x > right ? 0 : P.y < top ? 3 : 2); continue; }
|
| 585 |
if (P.depth < D_NEAR * 0.75) continue;
|
| 586 |
-
const near = Math.min(1, (P.depth - D_NEAR * 0.75) / (D_NEAR * 0.6))
|
| 587 |
-
|
|
|
|
| 588 |
if (a <= 0.01) continue;
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 593 |
ctx.globalAlpha = 1;
|
| 594 |
}
|
| 595 |
|
|
|
|
| 544 |
const haze = ctx.createRadialGradient(cx, cy, 0, cx, cy, baseR * 4);
|
| 545 |
haze.addColorStop(0, `rgba(${r},${g},${b},${0.12 * k})`); haze.addColorStop(0.4, `rgba(${r},${g},${b},${0.04 * k})`); haze.addColorStop(1, `rgba(${r},${g},${b},0)`);
|
| 546 |
ctx.fillStyle = haze; ctx.beginPath(); ctx.arc(cx, cy, baseR * 4, 0, TAU); ctx.fill();
|
| 547 |
+
// Mid glow — quầng sáng lớp giữa
|
| 548 |
+
const mid = ctx.createRadialGradient(cx, cy, 0, cx, cy, baseR * 2);
|
| 549 |
+
mid.addColorStop(0, `rgba(${r},${g},${b},${0.26 * k})`);
|
| 550 |
+
mid.addColorStop(0.5, `rgba(${r},${g},${b},${0.08 * k})`);
|
| 551 |
+
mid.addColorStop(1, `rgba(${r},${g},${b},0)`);
|
| 552 |
+
ctx.fillStyle = mid;
|
| 553 |
+
ctx.beginPath(); ctx.arc(cx, cy, baseR * 2, 0, TAU); ctx.fill();
|
| 554 |
+
// Ring sáng viền badge
|
| 555 |
+
ctx.strokeStyle = `rgba(255,255,255,0.22)`;
|
| 556 |
+
ctx.lineWidth = 2;
|
| 557 |
+
ctx.beginPath(); ctx.arc(cx, cy, baseR * 0.95 + 3, 0, TAU); ctx.stroke();
|
| 558 |
const badgeR = baseR * 0.95, badge = ctx.createRadialGradient(cx, cy - badgeR * 0.15, badgeR * 0.2, cx, cy, badgeR);
|
| 559 |
badge.addColorStop(0, "#8fcb5e"); badge.addColorStop(1, "#3c8b22");
|
| 560 |
ctx.fillStyle = badge; ctx.beginPath(); ctx.arc(cx, cy, badgeR, 0, TAU); ctx.fill();
|
|
|
|
| 587 |
const bg = ctx.createRadialGradient(cx, cy, 0, cx, cy, Math.max(width, height) * 0.85);
|
| 588 |
bg.addColorStop(0, "#f0fae0"); bg.addColorStop(0.4, "#e4f4cc"); bg.addColorStop(1, "#d2eaab");
|
| 589 |
ctx.fillStyle = bg; ctx.fillRect(0, 0, width, height);
|
| 590 |
+
// Vòng orbit nét đứt trang trí
|
| 591 |
+
ctx.setLineDash([3, 14]);
|
| 592 |
+
ctx.strokeStyle = "rgba(120,160,80,0.20)";
|
| 593 |
+
ctx.lineWidth = 1.5;
|
| 594 |
+
[160, 110].forEach(r => {
|
| 595 |
+
const R = Math.min(width, height) * r / 417;
|
| 596 |
+
ctx.beginPath(); ctx.arc(cx, cy, R, 0, TAU); ctx.stroke();
|
| 597 |
+
});
|
| 598 |
+
ctx.setLineDash([]);
|
| 599 |
const dRef = D_NEAR * 3.3, left = -width * 0.12, right = width * 1.12, top = -height * 0.12, bottom = height * 1.12;
|
| 600 |
+
for (let s = 0; s < starN; s++) {
|
| 601 |
project(sx[s] - DIR.x * dist, sy[s] - DIR.y * dist, sz[s] - DIR.z * dist);
|
| 602 |
if (!P.ok || P.depth > D_FAR * 1.25) { seedStar(s); continue; }
|
| 603 |
if (P.x < left || P.x > right || P.y < top || P.y > bottom) { seedStar(s, undefined, P.x < left ? 1 : P.x > right ? 0 : P.y < top ? 3 : 2); continue; }
|
| 604 |
if (P.depth < D_NEAR * 0.75) continue;
|
| 605 |
+
const near = Math.min(1, (P.depth - D_NEAR * 0.75) / (D_NEAR * 0.6));
|
| 606 |
+
const far = 1 - Math.max(0, (P.depth - D_FAR * 0.78) / (D_FAR * 0.32));
|
| 607 |
+
let a = (0.28 + sMag[s] * 1.05) * Math.pow(dRef / P.depth, 0.8) * near * far;
|
| 608 |
if (a <= 0.01) continue;
|
| 609 |
+
// Twinkle mạnh — biên độ 0.55, tạo cảm giác chớp sáng như sao
|
| 610 |
+
a *= 0.45 + 0.55 * Math.pow(0.5 + 0.5 * Math.sin(t * 6.5 + sPhase[s]), 2);
|
| 611 |
+
const col = sTint[s] === 1 ? "170,205,110" : sTint[s] === 2 ? "60,130,50" : "95,170,85";
|
| 612 |
+
const size = Math.min(4.2, 1.1 + sMag[s] * 3.2 * Math.pow(dRef / P.depth, 0.5));
|
| 613 |
+
ctx.globalAlpha = Math.min(0.88, a);
|
| 614 |
+
// Halo lấp lánh cho hạt lớn
|
| 615 |
+
if (size >= 1.6) {
|
| 616 |
+
ctx.fillStyle = `rgba(${col},${(a * 0.35).toFixed(3)})`;
|
| 617 |
+
ctx.beginPath(); ctx.arc(P.x, P.y, size * 1.6, 0, TAU); ctx.fill();
|
| 618 |
+
}
|
| 619 |
+
ctx.fillStyle = `rgb(${col})`;
|
| 620 |
+
if (size < 1.2) ctx.fillRect(P.x, P.y, size, size);
|
| 621 |
+
else { ctx.beginPath(); ctx.arc(P.x, P.y, size * 0.5, 0, TAU); ctx.fill(); }
|
| 622 |
ctx.globalAlpha = 1;
|
| 623 |
}
|
| 624 |
|