One commited on
Commit
6db340c
·
verified ·
1 Parent(s): 8cbb622

Upload index.html

Browse files
Files changed (1) hide show
  1. index.html +27 -13
index.html CHANGED
@@ -1673,12 +1673,22 @@ function drawRays(t, light) {
1673
  }
1674
  }
1675
 
1676
- // v29: Fish occlude godrays - cast long blurred shadows down to the tank floor
1677
  function drawFishShadows(t) {
1678
  ctx.save();
1679
  ctx.globalCompositeOperation = 'multiply';
 
 
 
 
 
 
 
 
 
 
1680
  for (const f of fishes) {
1681
- // Fish blocks light, casting a shadow that extends down to the sand
1682
  const shadowTop = f.y - f.size * 0.3;
1683
  const shadowBottom = sandAt(f.x) - 5;
1684
  const shadowHeight = shadowBottom - shadowTop;
@@ -1688,22 +1698,26 @@ function drawFishShadows(t) {
1688
  const topWidth = f.size * 1.2;
1689
  const bottomWidth = f.size * 2.5;
1690
 
 
 
 
 
1691
  // Create gradient for shadow (darker near fish, fading downward)
1692
- const g = ctx.createLinearGradient(f.x, shadowTop, f.x, shadowBottom);
1693
- g.addColorStop(0, 'rgba(0,0,0,0.22)');
1694
- g.addColorStop(0.3, 'rgba(0,0,0,0.12)');
1695
- g.addColorStop(1, 'rgba(0,0,0,0.03)');
1696
 
1697
  ctx.fillStyle = g;
1698
  ctx.beginPath();
1699
  // Draw tapered shadow shape with soft edges using quadratic curves
1700
- const blur = f.size * 0.4;
1701
- ctx.moveTo(f.x - topWidth/2, shadowTop + blur);
1702
- ctx.quadraticCurveTo(f.x - topWidth/2, shadowTop, f.x, shadowTop);
1703
- ctx.quadraticCurveTo(f.x + topWidth/2, shadowTop, f.x + topWidth/2, shadowTop + blur);
1704
- ctx.lineTo(f.x + bottomWidth/2, shadowBottom - blur);
1705
- ctx.quadraticCurveTo(f.x + bottomWidth/2, shadowBottom, f.x, shadowBottom);
1706
- ctx.quadraticCurveTo(f.x - bottomWidth/2, shadowBottom, f.x - bottomWidth/2, shadowBottom - blur);
1707
  ctx.closePath();
1708
  ctx.fill();
1709
  }
 
1673
  }
1674
  }
1675
 
1676
+ // v29: Fish occlude godrays - cast angled, blurred shadows that move with the sun
1677
  function drawFishShadows(t) {
1678
  ctx.save();
1679
  ctx.globalCompositeOperation = 'multiply';
1680
+
1681
+ // Calculate sun position based on raw day phase (linear progression)
1682
+ const p = ((t / CYCLE) % 1 + 1) % 1; // 0 to 1, linear throughout the day
1683
+ // Sun moves from left to right across the sky during the day
1684
+ // p=0 (dawn): sun on left, shadows point right
1685
+ // p=0.5 (noon): sun overhead, shadows are short and straight down
1686
+ // p=1 (dusk): sun on right, shadows point left
1687
+ const sunAngle = (p - 0.5) * Math.PI * 0.8; // -1.25 to +1.25 radians
1688
+ const shadowAngle = Math.atan2(1, Math.tan(sunAngle + Math.PI/2)); // convert to shadow angle
1689
+
1690
  for (const f of fishes) {
1691
+ // Fish blocks light, casting a shadow that extends down to the sand at an angle
1692
  const shadowTop = f.y - f.size * 0.3;
1693
  const shadowBottom = sandAt(f.x) - 5;
1694
  const shadowHeight = shadowBottom - shadowTop;
 
1698
  const topWidth = f.size * 1.2;
1699
  const bottomWidth = f.size * 2.5;
1700
 
1701
+ // Shadow descends at an angle based on sun position
1702
+ const topX = f.x;
1703
+ const bottomX = f.x + shadowHeight * Math.tan(shadowAngle);
1704
+
1705
  // Create gradient for shadow (darker near fish, fading downward)
1706
+ const g = ctx.createLinearGradient(topX, shadowTop, bottomX, shadowBottom);
1707
+ g.addColorStop(0, 'rgba(0,0,0,0.11)');
1708
+ g.addColorStop(0.3, 'rgba(0,0,0,0.06)');
1709
+ g.addColorStop(1, 'rgba(0,0,0,0.015)');
1710
 
1711
  ctx.fillStyle = g;
1712
  ctx.beginPath();
1713
  // Draw tapered shadow shape with soft edges using quadratic curves
1714
+ const blur = f.size * 0.8;
1715
+ ctx.moveTo(topX - topWidth/2, shadowTop + blur);
1716
+ ctx.quadraticCurveTo(topX - topWidth/2, shadowTop, topX, shadowTop);
1717
+ ctx.quadraticCurveTo(topX + topWidth/2, shadowTop, topX + topWidth/2, shadowTop + blur);
1718
+ ctx.lineTo(bottomX + bottomWidth/2, shadowBottom - blur);
1719
+ ctx.quadraticCurveTo(bottomX + bottomWidth/2, shadowBottom, bottomX, shadowBottom);
1720
+ ctx.quadraticCurveTo(bottomX - bottomWidth/2, shadowBottom, bottomX - bottomWidth/2, shadowBottom - blur);
1721
  ctx.closePath();
1722
  ctx.fill();
1723
  }