@mumulinya167/ccm-pet-assets 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/assets/calico/calico-idle-follow.svg +324 -324
  2. package/assets/calico.svg +324 -324
  3. package/assets/clawd/LICENSE +22 -22
  4. package/assets/clawd/clawd-about-hero.svg +202 -202
  5. package/assets/clawd/clawd-collapse-sleep.svg +247 -247
  6. package/assets/clawd/clawd-error.svg +94 -94
  7. package/assets/clawd/clawd-happy.svg +160 -160
  8. package/assets/clawd/clawd-headphones-groove.svg +194 -194
  9. package/assets/clawd/clawd-idle-bubble.svg +180 -180
  10. package/assets/clawd/clawd-idle-collapse.svg +101 -101
  11. package/assets/clawd/clawd-idle-doze.svg +72 -72
  12. package/assets/clawd/clawd-idle-follow.svg +64 -64
  13. package/assets/clawd/clawd-idle-living.svg +195 -195
  14. package/assets/clawd/clawd-idle-look.svg +115 -115
  15. package/assets/clawd/clawd-idle-reading.svg +252 -252
  16. package/assets/clawd/clawd-idle-yawn.svg +158 -158
  17. package/assets/clawd/clawd-mini-alert.svg +129 -129
  18. package/assets/clawd/clawd-mini-crabwalk.svg +76 -76
  19. package/assets/clawd/clawd-mini-enter-sleep.svg +64 -64
  20. package/assets/clawd/clawd-mini-enter.svg +114 -114
  21. package/assets/clawd/clawd-mini-happy.svg +124 -124
  22. package/assets/clawd/clawd-mini-idle.svg +83 -83
  23. package/assets/clawd/clawd-mini-peek.svg +82 -82
  24. package/assets/clawd/clawd-mini-sleep.svg +112 -112
  25. package/assets/clawd/clawd-mini-typing.svg +153 -153
  26. package/assets/clawd/clawd-notification.svg +438 -438
  27. package/assets/clawd/clawd-react-annoyed.svg +167 -167
  28. package/assets/clawd/clawd-react-double-jump.svg +229 -229
  29. package/assets/clawd/clawd-react-double.svg +108 -108
  30. package/assets/clawd/clawd-react-drag.svg +102 -102
  31. package/assets/clawd/clawd-react-left.svg +102 -102
  32. package/assets/clawd/clawd-react-right.svg +102 -102
  33. package/assets/clawd/clawd-sleeping.svg +117 -117
  34. package/assets/clawd/clawd-static-base.svg +20 -20
  35. package/assets/clawd/clawd-wake.svg +277 -277
  36. package/assets/clawd/clawd-working-building.svg +329 -329
  37. package/assets/clawd/clawd-working-carrying.svg +178 -178
  38. package/assets/clawd/clawd-working-debugger.svg +245 -245
  39. package/assets/clawd/clawd-working-juggling.svg +183 -183
  40. package/assets/clawd/clawd-working-sweeping.svg +248 -248
  41. package/assets/clawd/clawd-working-thinking.svg +501 -501
  42. package/assets/clawd/clawd-working-typing-boss.svg +307 -307
  43. package/assets/clawd/clawd-working-typing.svg +273 -273
  44. package/assets/clawd/clawd-working-ultrathink.svg +166 -166
  45. package/assets/clawd/clawd-working-wizard.svg +356 -356
  46. package/assets/clawd.svg +64 -64
  47. package/assets/cloudling/cloudling/cloudling-attention.svg +379 -379
  48. package/assets/cloudling/cloudling/cloudling-building.svg +667 -667
  49. package/assets/cloudling/cloudling/cloudling-carrying.svg +604 -604
  50. package/assets/cloudling/cloudling/cloudling-conducting.svg +616 -616
  51. package/assets/cloudling/cloudling/cloudling-dozing-to-sleeping.svg +578 -578
  52. package/assets/cloudling/cloudling/cloudling-dozing.svg +358 -358
  53. package/assets/cloudling/cloudling/cloudling-error.svg +428 -428
  54. package/assets/cloudling/cloudling/cloudling-idle-reading.svg +658 -658
  55. package/assets/cloudling/cloudling/cloudling-idle-to-dozing.svg +568 -568
  56. package/assets/cloudling/cloudling/cloudling-idle-to-sleeping.svg +811 -811
  57. package/assets/cloudling/cloudling/cloudling-idle.svg +255 -255
  58. package/assets/cloudling/cloudling/cloudling-juggling.svg +648 -648
  59. package/assets/cloudling/cloudling/cloudling-mini-alert.svg +389 -389
  60. package/assets/cloudling/cloudling/cloudling-mini-crabwalk.svg +335 -335
  61. package/assets/cloudling/cloudling/cloudling-mini-enter-roll-in.svg +225 -225
  62. package/assets/cloudling/cloudling/cloudling-mini-enter-sleep.svg +231 -231
  63. package/assets/cloudling/cloudling/cloudling-mini-happy.svg +370 -370
  64. package/assets/cloudling/cloudling/cloudling-mini-idle.svg +279 -279
  65. package/assets/cloudling/cloudling/cloudling-mini-peek.svg +327 -327
  66. package/assets/cloudling/cloudling/cloudling-mini-sleep.svg +260 -260
  67. package/assets/cloudling/cloudling/cloudling-mini-typing.svg +691 -691
  68. package/assets/cloudling/cloudling/cloudling-notification.svg +493 -493
  69. package/assets/cloudling/cloudling/cloudling-react-drag.svg +83 -83
  70. package/assets/cloudling/cloudling/cloudling-sleeping-to-idle.svg +555 -555
  71. package/assets/cloudling/cloudling/cloudling-sleeping.svg +500 -500
  72. package/assets/cloudling/cloudling/cloudling-sweeping.svg +292 -292
  73. package/assets/cloudling/cloudling/cloudling-thinking.svg +719 -719
  74. package/assets/cloudling/cloudling/cloudling-typing.svg +354 -354
  75. package/assets/cloudling/cloudling-attention.svg +379 -379
  76. package/assets/cloudling/cloudling-building.svg +667 -667
  77. package/assets/cloudling/cloudling-carrying.svg +604 -604
  78. package/assets/cloudling/cloudling-conducting.svg +616 -616
  79. package/assets/cloudling/cloudling-dozing-to-sleeping.svg +578 -578
  80. package/assets/cloudling/cloudling-dozing.svg +358 -358
  81. package/assets/cloudling/cloudling-error.svg +428 -428
  82. package/assets/cloudling/cloudling-idle-reading.svg +658 -658
  83. package/assets/cloudling/cloudling-idle-to-dozing.svg +568 -568
  84. package/assets/cloudling/cloudling-idle-to-sleeping.svg +811 -811
  85. package/assets/cloudling/cloudling-idle.svg +255 -255
  86. package/assets/cloudling/cloudling-juggling.svg +648 -648
  87. package/assets/cloudling/cloudling-mini-alert.svg +389 -389
  88. package/assets/cloudling/cloudling-mini-crabwalk.svg +335 -335
  89. package/assets/cloudling/cloudling-mini-enter-roll-in.svg +225 -225
  90. package/assets/cloudling/cloudling-mini-enter-sleep.svg +231 -231
  91. package/assets/cloudling/cloudling-mini-happy.svg +370 -370
  92. package/assets/cloudling/cloudling-mini-idle.svg +279 -279
  93. package/assets/cloudling/cloudling-mini-peek.svg +327 -327
  94. package/assets/cloudling/cloudling-mini-sleep.svg +260 -260
  95. package/assets/cloudling/cloudling-mini-typing.svg +691 -691
  96. package/assets/cloudling/cloudling-notification.svg +493 -493
  97. package/assets/cloudling/cloudling-react-drag.svg +83 -83
  98. package/assets/cloudling/cloudling-sleeping-to-idle.svg +555 -555
  99. package/assets/cloudling/cloudling-sleeping.svg +500 -500
  100. package/assets/cloudling/cloudling-sweeping.svg +292 -292
  101. package/assets/cloudling/cloudling-thinking.svg +719 -719
  102. package/assets/cloudling/cloudling-typing.svg +354 -354
  103. package/assets/cloudling.svg +255 -255
  104. package/assets/ghost-attention.svg +19 -19
  105. package/assets/ghost-carrying.svg +19 -19
  106. package/assets/ghost-collapsing.svg +19 -19
  107. package/assets/ghost-dozing.svg +23 -23
  108. package/assets/ghost-error.svg +19 -19
  109. package/assets/ghost-happy.svg +23 -23
  110. package/assets/ghost-idle.svg +11 -11
  111. package/assets/ghost-juggling.svg +19 -19
  112. package/assets/ghost-notification.svg +19 -19
  113. package/assets/ghost-react-double.svg +23 -23
  114. package/assets/ghost-react-drag.svg +23 -23
  115. package/assets/ghost-react-left.svg +19 -19
  116. package/assets/ghost-react-right.svg +19 -19
  117. package/assets/ghost-sleeping.svg +19 -19
  118. package/assets/ghost-sweeping.svg +19 -19
  119. package/assets/ghost-waking.svg +19 -19
  120. package/assets/ghost-yawning.svg +23 -23
  121. package/assets/ghost.svg +11 -11
  122. package/assets/robot-attention.svg +19 -19
  123. package/assets/robot-carrying.svg +19 -19
  124. package/assets/robot-collapsing.svg +19 -19
  125. package/assets/robot-dozing.svg +23 -23
  126. package/assets/robot-error.svg +19 -19
  127. package/assets/robot-happy.svg +23 -23
  128. package/assets/robot-idle.svg +11 -11
  129. package/assets/robot-juggling.svg +19 -19
  130. package/assets/robot-notification.svg +19 -19
  131. package/assets/robot-react-double.svg +23 -23
  132. package/assets/robot-react-drag.svg +23 -23
  133. package/assets/robot-react-left.svg +19 -19
  134. package/assets/robot-react-right.svg +19 -19
  135. package/assets/robot-sleeping.svg +19 -19
  136. package/assets/robot-sweeping.svg +19 -19
  137. package/assets/robot-waking.svg +19 -19
  138. package/assets/robot-yawning.svg +23 -23
  139. package/assets/robot.svg +11 -11
  140. package/manifest.json +280 -280
  141. package/package.json +1 -1
@@ -1,555 +1,555 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg id="stage" xmlns="http://www.w3.org/2000/svg" viewBox="-6 -6 36 36" preserveAspectRatio="xMidYMid meet">
3
- <g id="__cloudling-export-shims" opacity="0" pointer-events="none" style="display:none">
4
- <g id="btn-play"></g>
5
- <g id="phase"></g>
6
- <g id="scrubber"></g>
7
- <g id="time"></g>
8
- </g>
9
- <script type="application/ecmascript"><![CDATA[
10
- const CLOUD_D = "M9.064 3.344a4.578 4.578 0 012.285-.312c1 .115 1.891.54 2.673 1.275.01.01.024.017.037.021a.09.09 0 00.043 0 4.55 4.55 0 013.046.275l.047.022.116.057a4.581 4.581 0 012.188 2.399c.209.51.313 1.041.315 1.595a4.24 4.24 0 01-.134 1.223.123.123 0 00.03.115c.594.607.988 1.33 1.183 2.17.289 1.425-.007 2.71-.887 3.854l-.136.166a4.548 4.548 0 01-2.201 1.388.123.123 0 00-.081.076c-.191.551-.383 1.023-.740 1.494-.9 1.187-2.222 1.846-3.711 1.838-1.187-.006-2.239-.44-3.157-1.302a.107.107 0 00-.105-.024c-.388.125-.78.143-1.204.138a4.441 4.441 0 01-1.945-.466 4.544 4.544 0 01-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81 5.81 0 01-.37-.961 4.582 4.582 0 01-.014-2.298.124.124 0 00.006-.056.085.085 0 00-.027-.048 4.467 4.467 0 01-1.034-1.651 3.896 3.896 0 01-.251-1.192 5.189 5.189 0 01.141-1.6c.337-1.112.982-1.985 1.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098 0 00.065-.066 4.51 4.51 0 01.829-1.615 4.535 4.535 0 011.837-1.388z";
11
-
12
- const SLEEP = {
13
- bodyTilt: -6,
14
- breathScale: 1.02,
15
- hatTx: -2,
16
- hatTy: -0.4,
17
- hatRot: -10,
18
- hatScale: 0.98,
19
- maskTx: 0,
20
- maskTy: -0.6,
21
- maskRot: -9,
22
- maskScale: 1,
23
- };
24
-
25
- const IDLE_EYE = {
26
- leftX: 7.7,
27
- rightX: 13.7,
28
- y: 9.5,
29
- w: 2.6,
30
- h: 5,
31
- rx: 1.3,
32
- };
33
-
34
- const TIMING = {
35
- hold: 0.35,
36
- lampStart: 0.22,
37
- lampInEnd: 0.84,
38
- switchStart: 0.92,
39
- switchEnd: 1.36,
40
- maskStart: 1.28,
41
- maskEnd: 2.18,
42
- hatStart: 1.48,
43
- hatEnd: 2.42,
44
- eyeStart: 2.12,
45
- eyeEnd: 3.12,
46
- lampOutStart: 2.82,
47
- lampOutEnd: 3.42,
48
- settleEnd: 3.65,
49
- };
50
-
51
- const SLEEP_MASK_PATH = {
52
- d: "M488.728,341.587l-7.846-2.599c-0.405-16.992-7.605-47.34-48.625-70.941c-38.301-22.036-96.652-33.215-173.431-33.224c-76.822,0-135.146-11.165-173.438,33.183c-42.335,24.344-48.659,55.883-48.661,72.516c0,2.608,0.135,5.183,0.352,7.735h-2.649c-0.001,0-0.001,0-0.002,0c-9.635,0-17.446,7.811-17.448,17.445c-0.001,9.636,7.81,17.449,17.445,17.45l13,0.001c15.257,28.43,45.267,47.814,79.728,47.818c20.016-0.001,36.647-11.511,54.256-23.695c20.65-14.29,44.048-30.481,77.388-30.481c33.359,0.003,56.757,16.204,77.402,30.497c17.61,12.192,34.24,23.707,54.251,23.709h0.012c24.153,0,46.861-9.404,63.941-26.481c8.937-8.936,15.751-19.422,20.239-30.839l3.111,1.031c1.82,0.604,3.67,0.89,5.489,0.89c7.318,0,14.133-4.64,16.56-11.966C502.835,354.489,497.876,344.617,488.728,341.587Z",
53
- bboxX: 15, bboxY: 232, bboxW: 487, bboxH: 200
54
- };
55
-
56
- const STAR_LOCKED = {
57
- cx: 8.55, cy: 0.35, size: 1.00, rotation: 30,
58
- cornerRound: 0.27, chubbiness: 0, innerRatio: 0.56
59
- };
60
-
61
- const WAKE_SWITCH = {
62
- cx: 15.6,
63
- cy: -5.2,
64
- dayKnobOffsetX: -3,
65
- nightKnobOffsetX: -0.2,
66
- };
67
-
68
- const stage = document.getElementById('stage');
69
- const scrubber = document.getElementById('scrubber');
70
- const timeOut = document.getElementById('time');
71
- const phaseEl = document.getElementById('phase');
72
- let playing = true;
73
- let peekEyes = false;
74
- let start = performance.now();
75
- let manualT = 0;
76
-
77
- function clamp01(v) { return Math.max(0, Math.min(1, v)); }
78
- function lerp(a, b, t) { return a + (b - a) * t; }
79
- function progress(t, a, b) { return clamp01((t - a) / Math.max(0.0001, b - a)); }
80
- function smoothstep(a, b, t) {
81
- const x = progress(t, a, b);
82
- return x * x * (3 - 2 * x);
83
- }
84
- function easeInOut(t) {
85
- return t < .5 ? 4*t*t*t : 1 - Math.pow(-2*t + 2, 3) / 2;
86
- }
87
- function easeOutCubic(t) { return 1 - Math.pow(1 - t, 3); }
88
-
89
- function commonDefs(p) {
90
- return `
91
- <linearGradient id="${p}-body" x1="12" y1="2" x2="12" y2="22" gradientUnits="userSpaceOnUse">
92
- <stop offset="0" stop-color="#93c5fd"/>
93
- <stop offset="0.5" stop-color="#60a5fa"/>
94
- <stop offset="1" stop-color="#3b82f6"/>
95
- </linearGradient>
96
- <linearGradient id="${p}-eye" x1="0" y1="3" x2="0" y2="21" gradientUnits="userSpaceOnUse">
97
- <stop offset="0" stop-color="#B1A7FF"/>
98
- <stop offset="0.55" stop-color="#7A9DFF"/>
99
- <stop offset="1" stop-color="#3941FF"/>
100
- </linearGradient>
101
- <radialGradient id="${p}-hi" cx="0.45" cy="0.25" r="0.55">
102
- <stop offset="0" stop-color="#93c5fd" stop-opacity="0.9"/>
103
- <stop offset="1" stop-color="#93c5fd" stop-opacity="0"/>
104
- </radialGradient>
105
- <linearGradient id="${p}-hat" x1="11" y1="-3" x2="14" y2="6" gradientUnits="userSpaceOnUse">
106
- <stop offset="0" stop-color="#7AA0FF"/>
107
- <stop offset="0.45" stop-color="#3941FF"/>
108
- <stop offset="1" stop-color="#1F2BC2"/>
109
- </linearGradient>
110
- <linearGradient id="${p}-cuff" x1="12" y1="3.0" x2="12" y2="8.0" gradientUnits="userSpaceOnUse">
111
- <stop offset="0" stop-color="#93c5fd"/>
112
- <stop offset="0.5" stop-color="#fafbff"/>
113
- <stop offset="1" stop-color="#e8ecf6"/>
114
- </linearGradient>
115
- <linearGradient id="${p}-star-yellow" x1="0" y1="-2" x2="0" y2="2" gradientUnits="userSpaceOnUse">
116
- <stop offset="0" stop-color="#FFE9A8"/>
117
- <stop offset="0.5" stop-color="#FFD360"/>
118
- <stop offset="1" stop-color="#F5A623"/>
119
- </linearGradient>
120
- <filter id="${p}-star-glow" x="-80%" y="-80%" width="260%" height="260%">
121
- <feDropShadow dx="0" dy="0.4" stdDeviation="0.5" flood-color="#F5A623" flood-opacity="0.32"/>
122
- </filter>
123
- <filter id="${p}-shadow" x="-50%" y="-50%" width="200%" height="200%">
124
- <feDropShadow class="cloud-drop-shadow" dx="0" dy="0.6" stdDeviation="0.8" flood-color="#3941FF" flood-opacity="0.35"/>
125
- </filter>
126
- <filter id="${p}-edge-blur" x="-40%" y="-40%" width="180%" height="180%">
127
- <feGaussianBlur stdDeviation="0.16"/>
128
- </filter>
129
- <filter id="${p}-soft" x="-30%" y="-30%" width="160%" height="160%">
130
- <feGaussianBlur stdDeviation="0.18"/>
131
- </filter>
132
- <linearGradient id="${p}-toggle-day" x1="0" y1="0" x2="0" y2="1">
133
- <stop offset="0" stop-color="#E5EDFF"/><stop offset="1" stop-color="#BFD6FF"/>
134
- </linearGradient>
135
- <linearGradient id="${p}-toggle-night" x1="0" y1="0" x2="0" y2="1">
136
- <stop offset="0" stop-color="#2A3554"/><stop offset="1" stop-color="#0F1428"/>
137
- </linearGradient>
138
- <clipPath id="${p}-clip"><path d="${CLOUD_D}"/></clipPath>
139
- `;
140
- }
141
-
142
- function makeFluffyCuff(p, cx, cy, rx, ry, asym, bumps) {
143
- let parts = [];
144
- const circles = [];
145
- for (let i = 0; i < bumps; i++) {
146
- const ang = (i * 2 * Math.PI) / bumps - Math.PI / 2;
147
- const x = cx + Math.cos(ang) * rx;
148
- const y = cy + Math.sin(ang) * ry;
149
- const sizeY = -Math.sin(ang);
150
- const sizeBoost = 0.18 * (sizeY + 1) / 2 + 0.10;
151
- const jitter = ((i * 13) % 7) / 35;
152
- let r = 0.62 + sizeBoost + jitter;
153
- if (asym !== 0) r *= 1 + asym * Math.cos(ang) * 0.28;
154
- circles.push({ x, y, r });
155
- }
156
- const innerRy = ry + 0.40;
157
- parts.push(`<g filter="url(#${p}-soft)">`);
158
- parts.push(`<ellipse cx="${cx}" cy="${cy}" rx="${(rx + 0.30).toFixed(2)}" ry="${(innerRy + 0.30).toFixed(2)}" fill="#7A9DFF" opacity="0.50"/>`);
159
- circles.forEach(c => parts.push(`<circle cx="${c.x.toFixed(2)}" cy="${c.y.toFixed(2)}" r="${(c.r + 0.30).toFixed(2)}" fill="#7A9DFF" opacity="0.50"/>`));
160
- parts.push(`</g>`);
161
- parts.push(`<ellipse cx="${cx}" cy="${cy}" rx="${(rx + 0.15).toFixed(2)}" ry="${(innerRy + 0.15).toFixed(2)}" fill="#aab3c6" opacity="0.65"/>`);
162
- circles.forEach(c => parts.push(`<circle cx="${c.x.toFixed(2)}" cy="${c.y.toFixed(2)}" r="${(c.r + 0.15).toFixed(2)}" fill="#aab3c6" opacity="0.65"/>`));
163
- parts.push(`<ellipse cx="${cx}" cy="${cy}" rx="${rx.toFixed(2)}" ry="${innerRy.toFixed(2)}" fill="url(#${p}-cuff)"/>`);
164
- circles.forEach(c => parts.push(`<circle cx="${c.x.toFixed(2)}" cy="${c.y.toFixed(2)}" r="${c.r.toFixed(2)}" fill="url(#${p}-cuff)"/>`));
165
- parts.push(`<ellipse cx="${cx}" cy="${(cy - ry * 0.45).toFixed(2)}" rx="${(rx * 0.78).toFixed(2)}" ry="${(ry * 0.32).toFixed(2)}" fill="none" stroke="#ffffff" stroke-opacity="0.55" stroke-width="0.14"/>`);
166
- return parts.join('');
167
- }
168
-
169
- function makeBentHat(bend) {
170
- const baseLeft = { x: 8.5, y: 5.0 };
171
- const baseRight = { x: 15.5, y: 5.0 };
172
- const elbowX = 12 + bend * 2.2;
173
- const elbowY = -0.5 + bend * 2.3;
174
- const tipX = 11 - bend * 5.5;
175
- const tipY = 0.0 + bend * 0.5;
176
- const tipBottomX = tipX + 1.2 + bend * 0.4;
177
- const tipBottomY = tipY + 1.4 + bend * 0.3;
178
- const c1 = { x: baseRight.x + 0.5, y: baseRight.y - 1.5 };
179
- const c2 = { x: elbowX + 0.8, y: elbowY + 1.0 };
180
- const c3 = { x: elbowX - 0.5, y: elbowY - 0.8 };
181
- const c4 = { x: tipX + 1.5, y: tipY - 0.5 };
182
- const c5 = { x: tipX - 0.3, y: tipY + 0.6 };
183
- const c6 = { x: tipBottomX - 1.0, y: tipBottomY };
184
- const c7 = { x: 8.5, y: 4.0 };
185
- return {
186
- path: `M ${baseLeft.x} ${baseLeft.y} Q 12 5.55 ${baseRight.x} ${baseRight.y} C ${c1.x.toFixed(2)} ${c1.y.toFixed(2)} ${c2.x.toFixed(2)} ${c2.y.toFixed(2)} ${elbowX.toFixed(2)} ${elbowY.toFixed(2)} C ${c3.x.toFixed(2)} ${c3.y.toFixed(2)} ${c4.x.toFixed(2)} ${c4.y.toFixed(2)} ${tipX.toFixed(2)} ${tipY.toFixed(2)} C ${c5.x.toFixed(2)} ${c5.y.toFixed(2)} ${c6.x.toFixed(2)} ${c6.y.toFixed(2)} ${tipBottomX.toFixed(2)} ${tipBottomY.toFixed(2)} C ${c7.x.toFixed(2)} ${c7.y.toFixed(2)} 8.0 4.5 ${baseLeft.x} ${baseLeft.y} Z`
187
- };
188
- }
189
-
190
- function makeStar(cx, cy, r, rotationDeg, cornerRound, chubbiness, innerRatio) {
191
- const innerR = r * innerRatio;
192
- const rotRad = (rotationDeg * Math.PI) / 180;
193
- const verts = [];
194
- for (let i = 0; i < 10; i++) {
195
- const ang = (i * Math.PI / 5) + rotRad - Math.PI / 2;
196
- const radius = i % 2 === 0 ? r : innerR;
197
- verts.push({ x: cx + Math.cos(ang) * radius, y: cy + Math.sin(ang) * radius });
198
- }
199
- const inP = [], outP = [];
200
- for (let i = 0; i < 10; i++) {
201
- const prev = verts[(i - 1 + 10) % 10];
202
- const cur = verts[i];
203
- const next = verts[(i + 1) % 10];
204
- const v1x = prev.x - cur.x, v1y = prev.y - cur.y;
205
- const v2x = next.x - cur.x, v2y = next.y - cur.y;
206
- const v1Len = Math.hypot(v1x, v1y);
207
- const v2Len = Math.hypot(v2x, v2y);
208
- const cr = Math.min(cornerRound, v1Len * 0.48, v2Len * 0.48);
209
- inP[i] = { x: cur.x + (v1x / v1Len) * cr, y: cur.y + (v1y / v1Len) * cr };
210
- outP[i] = { x: cur.x + (v2x / v2Len) * cr, y: cur.y + (v2y / v2Len) * cr };
211
- }
212
- let path = `M ${inP[0].x.toFixed(2)} ${inP[0].y.toFixed(2)} `;
213
- for (let i = 0; i < 10; i++) {
214
- path += `Q ${verts[i].x.toFixed(2)} ${verts[i].y.toFixed(2)} ${outP[i].x.toFixed(2)} ${outP[i].y.toFixed(2)} `;
215
- const nextI = (i + 1) % 10;
216
- const startP = outP[i], endP = inP[nextI];
217
- if (chubbiness > 0) {
218
- const midX = (startP.x + endP.x) / 2, midY = (startP.y + endP.y) / 2;
219
- const dx = midX - cx, dy = midY - cy;
220
- const len = Math.hypot(dx, dy) || 1;
221
- const offset = chubbiness * r * 0.32;
222
- path += `Q ${(midX + (dx / len) * offset).toFixed(2)} ${(midY + (dy / len) * offset).toFixed(2)} ${endP.x.toFixed(2)} ${endP.y.toFixed(2)} `;
223
- } else {
224
- path += `L ${endP.x.toFixed(2)} ${endP.y.toFixed(2)} `;
225
- }
226
- }
227
- return `${path}Z`;
228
- }
229
-
230
- function makeSleepMask(p, tx, ty, rot, scale) {
231
- const cx = 12 + tx;
232
- const cy = 12 + ty;
233
- const W = 16.61 * scale;
234
- const H = 7.55 * scale;
235
- const eyeScale = 1.18;
236
- const eyeRot = 5;
237
- const eyeOffsetY = -0.25;
238
- const lashW = 2.45;
239
- const lashH = 0.70;
240
- const lashStroke = 0.45;
241
- const lashGap = 6.00 * scale;
242
- const lashHairLen = 0.66;
243
- const lashHairCount = 3;
244
-
245
- const sx = W / SLEEP_MASK_PATH.bboxW;
246
- const sy = H / SLEEP_MASK_PATH.bboxH;
247
- const cxOrig = SLEEP_MASK_PATH.bboxX + SLEEP_MASK_PATH.bboxW / 2;
248
- const cyOrig = SLEEP_MASK_PATH.bboxY + SLEEP_MASK_PATH.bboxH / 2;
249
- const body = `<g transform="translate(${cx} ${cy}) scale(${sx.toFixed(5)} ${sy.toFixed(5)}) translate(${(-cxOrig).toFixed(2)} ${(-cyOrig).toFixed(2)})">
250
- <path d="${SLEEP_MASK_PATH.d}" fill="#22305A" stroke="#000000" stroke-width="0.22" stroke-linejoin="round" stroke-linecap="round" vector-effect="non-scaling-stroke"/>
251
- </g>`;
252
-
253
- const arcLocal = `<path d="M ${(-lashW/2).toFixed(2)} 0 Q 0 ${(lashH * 2).toFixed(2)} ${(lashW/2).toFixed(2)} 0" fill="none" stroke="#FFFFFF" stroke-width="${lashStroke}" stroke-linecap="round"/>`;
254
- const hairs = [];
255
- const tPad = 0.18;
256
- for (let i = 0; i < lashHairCount; i++) {
257
- const t = tPad + (i / (lashHairCount - 1)) * (1 - 2 * tPad);
258
- const sxh = (1-t)*(1-t)*(-lashW/2) + t*t*(lashW/2);
259
- const syh = 2*(1-t)*t*(2*lashH);
260
- const tangX = 2*(1-t)*(lashW/2) + 2*t*(lashW/2);
261
- const tangY = 2*(1-t)*(2*lashH) + 2*t*(-2*lashH);
262
- const tLen = Math.hypot(tangX, tangY);
263
- const normX1 = -tangY / tLen, normY1 = tangX / tLen;
264
- const normX2 = tangY / tLen, normY2 = -tangX / tLen;
265
- const useFirst = normY1 > 0;
266
- const dirX = useFirst ? normX1 : normX2;
267
- const dirY = useFirst ? normY1 : normY2;
268
- hairs.push(`<line x1="${sxh.toFixed(2)}" y1="${syh.toFixed(2)}" x2="${(sxh + dirX * lashHairLen).toFixed(2)}" y2="${(syh + dirY * lashHairLen).toFixed(2)}" stroke="#FFFFFF" stroke-width="${(lashStroke * 0.85).toFixed(2)}" stroke-linecap="round" opacity="0.92"/>`);
269
- }
270
-
271
- const eyeL = cx - lashGap / 2;
272
- const eyeR = cx + lashGap / 2;
273
- const wrapEye = (ecx, sign) => `<g transform="translate(${ecx.toFixed(2)} ${(cy + eyeOffsetY).toFixed(2)}) rotate(${(sign * eyeRot).toFixed(2)}) scale(${eyeScale.toFixed(3)})">${arcLocal}${hairs.join('')}</g>`;
274
- return `<g class="sleep-mask" transform="rotate(${rot} ${cx} ${cy})" filter="url(#${p}-shadow)">${body}${wrapEye(eyeL, -1)}${wrapEye(eyeR, 1)}</g>`;
275
- }
276
-
277
- function makeCloudling(p) {
278
- return `
279
- <g class="cloudling-base">
280
- <g class="edge-system">
281
- <use class="edge-contact" href="#${p}-cloud-shape" fill="none" stroke="#7d8aa7" stroke-width="1.4" stroke-linejoin="round" transform="translate(0 0.18)" filter="url(#${p}-edge-blur)"/>
282
- <use class="edge-rim-soft" href="#${p}-cloud-shape" fill="none" stroke="#7A9DFF" stroke-width="1.2" stroke-linejoin="round" filter="url(#${p}-edge-blur)"/>
283
- <use class="edge-rim-tight" href="#${p}-cloud-shape" fill="none" stroke="#aab3c6" stroke-width="0.8" stroke-linejoin="round"/>
284
- </g>
285
- <g filter="url(#${p}-shadow)">
286
- <use href="#${p}-cloud-shape" fill="url(#${p}-body)"/>
287
- <rect x="1" y="2" width="22" height="11" fill="url(#${p}-hi)" clip-path="url(#${p}-clip)"/>
288
- </g>
289
- </g>
290
- `;
291
- }
292
-
293
- function sleepyEyePath(cx, cy, w, h, tiltDeg, flip) {
294
- const x1 = cx - w / 2;
295
- const x2 = cx + w / 2;
296
- const mid = cy + h * 0.56;
297
- const c1x = cx - w * 0.18;
298
- const c2x = cx + w * 0.18;
299
- const tilt = flip * tiltDeg * 0.018;
300
- return `M ${x1.toFixed(2)} ${(cy - tilt).toFixed(2)} C ${c1x.toFixed(2)} ${mid.toFixed(2)} ${c2x.toFixed(2)} ${mid.toFixed(2)} ${x2.toFixed(2)} ${(cy + tilt).toFixed(2)}`;
301
- }
302
-
303
- function makeBodyEyes(p, openU) {
304
- const u = clamp01(openU);
305
- const closedOpacity = 1 - smoothstep(0.36, 0.74, u);
306
- const capsuleOpacity = smoothstep(0.22, 1, u);
307
- const eyeCenterY = IDLE_EYE.y + IDLE_EYE.h / 2;
308
- const h = lerp(0.20, IDLE_EYE.h, easeInOut(u));
309
- const y = eyeCenterY - h / 2;
310
- const rx = Math.min(IDLE_EYE.rx, h / 2);
311
- const closedStroke = lerp(0.82, 0.40, u);
312
- return `
313
- <g class="body-eyes">
314
- <g fill="none" stroke="url(#${p}-eye)" stroke-width="${closedStroke.toFixed(2)}" stroke-linecap="round" stroke-linejoin="round" opacity="${closedOpacity.toFixed(3)}">
315
- <path d="${sleepyEyePath(9.00, 12.12, 2.72, 1.16, 7.7, -1)}"/>
316
- <path d="${sleepyEyePath(15.00, 12.12, 2.72, 1.16, 7.7, 1)}"/>
317
- </g>
318
- <g opacity="${capsuleOpacity.toFixed(3)}">
319
- <rect x="${IDLE_EYE.leftX}" y="${y.toFixed(3)}" width="${IDLE_EYE.w}" height="${h.toFixed(3)}" rx="${rx.toFixed(3)}" ry="${rx.toFixed(3)}" fill="url(#${p}-eye)" stroke="#ffffff" stroke-width="0.08" stroke-opacity="0.7"/>
320
- <rect x="${IDLE_EYE.rightX}" y="${y.toFixed(3)}" width="${IDLE_EYE.w}" height="${h.toFixed(3)}" rx="${rx.toFixed(3)}" ry="${rx.toFixed(3)}" fill="url(#${p}-eye)" stroke="#ffffff" stroke-width="0.08" stroke-opacity="0.7"/>
321
- </g>
322
- </g>
323
- `;
324
- }
325
-
326
- function makeHat(p, tx, ty, rot, scale, opacity) {
327
- const hatData = makeBentHat(0.4);
328
- const cuff = makeFluffyCuff(p, 12, 5.4, 3.7, 0.85, 0, 18);
329
- const s = STAR_LOCKED;
330
- const star = makeStar(s.cx, s.cy, s.size, s.rotation, s.cornerRound, s.chubbiness, s.innerRatio);
331
- return `
332
- <g opacity="${opacity.toFixed(3)}" transform="translate(${tx.toFixed(3)} ${ty.toFixed(3)}) rotate(${rot.toFixed(3)} 12 5.4) scale(${scale.toFixed(4)})">
333
- <g filter="url(#${p}-shadow)"><path d="${hatData.path}" fill="url(#${p}-hat)"/></g>
334
- <g>${cuff}</g>
335
- <g filter="url(#${p}-star-glow)">
336
- <path d="${star}" fill="url(#${p}-star-yellow)" stroke="#ffffff" stroke-width="0.06" stroke-opacity="0.7" stroke-linejoin="round"/>
337
- </g>
338
- </g>
339
- `;
340
- }
341
-
342
- function makeWakeSwitch(p, cx, cy, toggleMix, opacity, scale, rot, glow) {
343
- const mix = clamp01(toggleMix);
344
- const dayOpacity = 1 - mix;
345
- const nightOpacity = mix;
346
- const dayKnobOpacity = clamp01(1 - mix * 2.2);
347
- const nightKnobOpacity = clamp01((mix - 0.18) / 0.82);
348
- const knobX = cx + lerp(WAKE_SWITCH.dayKnobOffsetX, WAKE_SWITCH.nightKnobOffsetX, mix);
349
- const knobY = cy;
350
-
351
- const dayKnob = `
352
- <g opacity="${dayKnobOpacity.toFixed(2)}">
353
- <circle cx="${knobX.toFixed(2)}" cy="${knobY.toFixed(2)}" r="2.4" fill="#fff" filter="url(#${p}-shadow)"/>
354
- <circle cx="${(knobX+0.85).toFixed(2)}" cy="${(knobY-0.95).toFixed(2)}" r="0.50" fill="#D4DFFF" opacity="0.78"/>
355
- <circle cx="${(knobX+1.15).toFixed(2)}" cy="${(knobY+0.55).toFixed(2)}" r="0.28" fill="#D4DFFF" opacity="0.72"/>
356
- </g>
357
- `;
358
-
359
- const outerR = 2.35, innerR = 1.70, innerDx = 0.80;
360
- const ix = (outerR*outerR - innerR*innerR + innerDx*innerDx) / (2*innerDx);
361
- const iy = Math.sqrt(outerR*outerR - ix*ix);
362
- const nightKnob = `
363
- <g filter="url(#${p}-shadow)" opacity="${nightKnobOpacity.toFixed(2)}">
364
- <path d="
365
- M ${(knobX+ix).toFixed(3)} ${(knobY-iy).toFixed(3)}
366
- A ${outerR} ${outerR} 0 1 1 ${(knobX+ix).toFixed(3)} ${(knobY+iy).toFixed(3)}
367
- A ${innerR} ${innerR} 0 1 0 ${(knobX+ix).toFixed(3)} ${(knobY-iy).toFixed(3)}
368
- Z
369
- " fill="#fff"/>
370
- </g>
371
- `;
372
-
373
- const stars = `
374
- <g opacity="${nightOpacity.toFixed(2)}">
375
- <circle cx="${(cx-1.5).toFixed(2)}" cy="${(cy-0.9).toFixed(2)}" r="0.18" fill="#fff" opacity="0.95"/>
376
- <circle cx="${(cx-0.5).toFixed(2)}" cy="${(cy+1.3).toFixed(2)}" r="0.14" fill="#fff" opacity="0.85"/>
377
- <circle cx="${(cx+0.6).toFixed(2)}" cy="${(cy-0.4).toFixed(2)}" r="0.10" fill="#fff" opacity="0.75"/>
378
- <circle cx="${(cx-1.2).toFixed(2)}" cy="${(cy+1.6).toFixed(2)}" r="0.10" fill="#fff" opacity="0.78"/>
379
- <circle cx="${cx.toFixed(2)}" cy="${(cy-1.3).toFixed(2)}" r="0.13" fill="#fff" opacity="0.88"/>
380
- </g>
381
- `;
382
-
383
- const rayOpacity = glow * 0.34;
384
- const fineOpacity = glow * 0.22;
385
- const rays = `
386
- <g fill="none" stroke="#FFE9A8" stroke-linecap="round" filter="url(#${p}-soft)">
387
- <path d="M ${(cx-7.8).toFixed(2)} ${(cy-4.2).toFixed(2)} L ${(cx-9.5-glow*0.45).toFixed(2)} ${(cy-5.2-glow*0.25).toFixed(2)}" stroke-width="0.34" opacity="${rayOpacity.toFixed(3)}"/>
388
- <path d="M ${(cx-2.0).toFixed(2)} ${(cy-4.6).toFixed(2)} L ${(cx-2.5).toFixed(2)} ${(cy-6.2-glow*0.45).toFixed(2)}" stroke-width="0.28" opacity="${fineOpacity.toFixed(3)}"/>
389
- <path d="M ${(cx+5.9).toFixed(2)} ${(cy-4.0).toFixed(2)} L ${(cx+7.4+glow*0.40).toFixed(2)} ${(cy-5.0-glow*0.20).toFixed(2)}" stroke-width="0.34" opacity="${rayOpacity.toFixed(3)}"/>
390
- <path d="M ${(cx+7.8).toFixed(2)} ${(cy-0.2).toFixed(2)} L ${(cx+9.5+glow*0.50).toFixed(2)} ${(cy-0.2).toFixed(2)}" stroke-width="0.30" opacity="${fineOpacity.toFixed(3)}"/>
391
- <path d="M ${(cx+4.8).toFixed(2)} ${(cy+4.0).toFixed(2)} L ${(cx+6.0+glow*0.32).toFixed(2)} ${(cy+5.0+glow*0.24).toFixed(2)}" stroke-width="0.28" opacity="${fineOpacity.toFixed(3)}"/>
392
- <path d="M ${(cx-6.7).toFixed(2)} ${(cy+3.6).toFixed(2)} L ${(cx-8.1-glow*0.38).toFixed(2)} ${(cy+4.6+glow*0.22).toFixed(2)}" stroke-width="0.30" opacity="${rayOpacity.toFixed(3)}"/>
393
- <path d="M ${(cx-8.2).toFixed(2)} ${(cy-0.2).toFixed(2)} L ${(cx-9.7-glow*0.42).toFixed(2)} ${(cy-0.2).toFixed(2)}" stroke-width="0.26" opacity="${fineOpacity.toFixed(3)}"/>
394
- </g>
395
- `;
396
-
397
- return `
398
- <g opacity="${opacity.toFixed(3)}" transform="translate(${cx} ${cy}) rotate(${rot.toFixed(3)}) scale(${scale.toFixed(3)}) translate(${-cx} ${-cy})">
399
- ${rays}
400
- <g filter="url(#${p}-shadow)">
401
- <rect x="${(cx-7).toFixed(2)}" y="${(cy-3).toFixed(2)}" width="14" height="6" rx="3" ry="3" fill="url(#${p}-toggle-day)" opacity="${dayOpacity.toFixed(2)}"/>
402
- <rect x="${(cx-7).toFixed(2)}" y="${(cy-3).toFixed(2)}" width="14" height="6" rx="3" ry="3" fill="url(#${p}-toggle-night)" opacity="${nightOpacity.toFixed(2)}"/>
403
- <rect x="${(cx-7).toFixed(2)}" y="${(cy-3).toFixed(2)}" width="14" height="6" rx="3" ry="3" fill="none" stroke="#fff" stroke-opacity="0.18" stroke-width="0.12"/>
404
- </g>
405
- ${stars}
406
- ${dayKnob}
407
- ${nightKnob}
408
- </g>
409
- `;
410
- }
411
-
412
- function phaseName(t) {
413
- if (t < TIMING.lampInEnd) return 'switch appears';
414
- if (t < TIMING.switchEnd) return 'night to day';
415
- if (t < TIMING.maskEnd) return 'mask sliding';
416
- if (t < TIMING.eyeEnd) return 'body eyes waking';
417
- return 'idle handoff';
418
- }
419
-
420
- function computeFrame(t) {
421
- const lampIn = easeOutCubic(progress(t, TIMING.lampStart, TIMING.lampInEnd));
422
- const switchU = easeInOut(progress(t, TIMING.switchStart, TIMING.switchEnd));
423
- const lampOut = smoothstep(TIMING.lampOutStart, TIMING.lampOutEnd, t);
424
- const maskU = easeOutCubic(progress(t, TIMING.maskStart, TIMING.maskEnd));
425
- const hatU = easeOutCubic(progress(t, TIMING.hatStart, TIMING.hatEnd));
426
- const eyeU = easeInOut(progress(t, TIMING.eyeStart, TIMING.eyeEnd));
427
- const settleU = easeInOut(progress(t, 1.54, TIMING.settleEnd));
428
- const maskClear = peekEyes ? 1 : maskU;
429
- return {
430
- phase: phaseName(t),
431
- sceneRot: lerp(SLEEP.bodyTilt, 0, settleU),
432
- scale: lerp(SLEEP.breathScale, 1.0, settleU),
433
- eyeU,
434
- wakeGlow: Math.sin(switchU * Math.PI) * 0.18,
435
- lamp: {
436
- opacity: lampIn * (1 - lampOut),
437
- toggleMix: lerp(1, 0, switchU),
438
- scale: lerp(0.88, 1, lampIn) + Math.sin(switchU * Math.PI) * 0.035,
439
- rot: Math.sin(switchU * Math.PI * 2) * 1.15 * (1 - switchU),
440
- glow: Math.sin(switchU * Math.PI),
441
- },
442
- mask: {
443
- tx: lerp(SLEEP.maskTx, 7.6, maskClear),
444
- ty: lerp(SLEEP.maskTy, -5.1, maskClear) - Math.sin(maskClear * Math.PI) * 0.08,
445
- rot: lerp(SLEEP.maskRot, 14, maskClear),
446
- opacity: peekEyes ? 0.08 : (1 - smoothstep(0.68, 1, maskU)),
447
- },
448
- hat: {
449
- tx: lerp(SLEEP.hatTx, -7.0, hatU),
450
- ty: lerp(SLEEP.hatTy, -6.4, hatU) - Math.sin(hatU * Math.PI) * 0.10,
451
- rot: lerp(SLEEP.hatRot, -26, hatU),
452
- scale: lerp(SLEEP.hatScale, 0.86, hatU),
453
- opacity: 1 - smoothstep(0.62, 1, hatU),
454
- },
455
- };
456
- }
457
-
458
- function renderFrame(t) {
459
- const f = computeFrame(t);
460
- const p = 'si';
461
- const mask = makeSleepMask(p, f.mask.tx, f.mask.ty, f.mask.rot, SLEEP.maskScale);
462
- const wakeSwitch = makeWakeSwitch(p, WAKE_SWITCH.cx, WAKE_SWITCH.cy, f.lamp.toggleMix, f.lamp.opacity, f.lamp.scale, f.lamp.rot, f.lamp.glow);
463
- stage.innerHTML = `
464
- <style>
465
- .edge-rim-tight { stroke-opacity: .9; }
466
- .edge-rim-soft { stroke-opacity: .75; }
467
- .edge-contact { stroke-opacity: .9; }
468
- .wrap {
469
- width: min(960px, 100%);
470
- display: grid;
471
- gap: 18px;
472
- }
473
- .header {
474
- display: flex;
475
- justify-content: space-between;
476
- gap: 14px;
477
- align-items: end;
478
- }
479
- #stage {
480
- width: min(520px, 82vw);
481
- aspect-ratio: 1;
482
- display: grid;
483
- place-items: center;
484
- }
485
- output {
486
- min-width: 76px;
487
- color: rgba(255,255,255,.70);
488
- font-size: 12px;
489
- text-align: right;
490
- }
491
- .phase {
492
- display: flex;
493
- flex-wrap: wrap;
494
- gap: 9px 16px;
495
- color: rgba(255,255,255,.62);
496
- font-size: 12px;
497
- }
498
- .phase b { color: rgba(255,255,255,.88); font-weight: 650; }
499
- @media (prefers-color-scheme: light) {
500
- .edge-rim-tight { stroke-opacity: .95; }
501
- .edge-rim-soft { stroke-opacity: .85; }
502
- .edge-contact { stroke-opacity: .95; }
503
- .cloud-drop-shadow { flood-opacity: .13; }
504
- .phase, output { color: rgba(21,33,63,.62); }
505
- .phase b { color: rgba(21,33,63,.86); }
506
- .cloud-drop-shadow { flood-opacity: .13; }
507
- .food-cloud-shadow { flood-opacity: .28; flood-color: #5060FF; }
508
- .food-cloud > path {
509
- stroke: #5870E8 !important;
510
- stroke-width: 1.2 !important;
511
- stroke-opacity: .9 !important;
512
- vector-effect: non-scaling-stroke !important;
513
- }
514
- }
515
- </style>
516
- <defs>
517
- ${commonDefs(p)}
518
- <path id="${p}-cloud-shape" d="${CLOUD_D}"/>
519
- </defs>
520
- <g class="scene" transform="rotate(${f.sceneRot.toFixed(3)} 12 12)">
521
- <g transform="translate(12 12) scale(${f.scale.toFixed(4)}) translate(-12 -12)">
522
- <use href="#${p}-cloud-shape" fill="none" stroke="#FFE9A8" stroke-width="0.92" stroke-linejoin="round" opacity="${f.wakeGlow.toFixed(3)}" filter="url(#${p}-soft)"/>
523
- ${makeCloudling(p)}
524
- ${makeBodyEyes(p, f.eyeU)}
525
- ${makeHat(p, f.hat.tx, f.hat.ty, f.hat.rot, f.hat.scale, f.hat.opacity)}
526
- <g opacity="${f.mask.opacity.toFixed(3)}">${mask}</g>
527
- </g>
528
- </g>
529
- ${wakeSwitch}
530
- `;
531
- scrubber.value = t.toFixed(2);
532
- timeOut.value = `${t.toFixed(2)} s`;
533
- phaseEl.innerHTML = `<span>phase: <b>${f.phase}</b></span><span>switch ${((1 - f.lamp.toggleMix) * 100).toFixed(0)}%</span><span>mask ${(progress(t, TIMING.maskStart, TIMING.maskEnd) * 100).toFixed(0)}%</span><span>body eyes ${(f.eyeU * 100).toFixed(0)}%</span><span>tilt ${f.sceneRot.toFixed(1)}deg</span><span>scale ${f.scale.toFixed(3)}</span>`;
534
- }
535
-
536
- function currentTime(now) {
537
- if (!playing) return manualT;
538
- return Math.min((now - start) / 1000, TIMING.settleEnd);
539
- }
540
-
541
- function loop(now) {
542
- const t = currentTime(now);
543
- renderFrame(t);
544
- if (playing && t >= TIMING.settleEnd) {
545
- playing = false;
546
- manualT = TIMING.settleEnd;
547
- { const __btn = document.getElementById('btn-play'); if (__btn) __btn.textContent = 'Play'; }
548
- }
549
- requestAnimationFrame(loop);
550
- }
551
-
552
- renderFrame(0);
553
- requestAnimationFrame(loop);
554
- ]]></script>
555
- </svg>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg id="stage" xmlns="http://www.w3.org/2000/svg" viewBox="-6 -6 36 36" preserveAspectRatio="xMidYMid meet">
3
+ <g id="__cloudling-export-shims" opacity="0" pointer-events="none" style="display:none">
4
+ <g id="btn-play"></g>
5
+ <g id="phase"></g>
6
+ <g id="scrubber"></g>
7
+ <g id="time"></g>
8
+ </g>
9
+ <script type="application/ecmascript"><![CDATA[
10
+ const CLOUD_D = "M9.064 3.344a4.578 4.578 0 012.285-.312c1 .115 1.891.54 2.673 1.275.01.01.024.017.037.021a.09.09 0 00.043 0 4.55 4.55 0 013.046.275l.047.022.116.057a4.581 4.581 0 012.188 2.399c.209.51.313 1.041.315 1.595a4.24 4.24 0 01-.134 1.223.123.123 0 00.03.115c.594.607.988 1.33 1.183 2.17.289 1.425-.007 2.71-.887 3.854l-.136.166a4.548 4.548 0 01-2.201 1.388.123.123 0 00-.081.076c-.191.551-.383 1.023-.740 1.494-.9 1.187-2.222 1.846-3.711 1.838-1.187-.006-2.239-.44-3.157-1.302a.107.107 0 00-.105-.024c-.388.125-.78.143-1.204.138a4.441 4.441 0 01-1.945-.466 4.544 4.544 0 01-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81 5.81 0 01-.37-.961 4.582 4.582 0 01-.014-2.298.124.124 0 00.006-.056.085.085 0 00-.027-.048 4.467 4.467 0 01-1.034-1.651 3.896 3.896 0 01-.251-1.192 5.189 5.189 0 01.141-1.6c.337-1.112.982-1.985 1.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098 0 00.065-.066 4.51 4.51 0 01.829-1.615 4.535 4.535 0 011.837-1.388z";
11
+
12
+ const SLEEP = {
13
+ bodyTilt: -6,
14
+ breathScale: 1.02,
15
+ hatTx: -2,
16
+ hatTy: -0.4,
17
+ hatRot: -10,
18
+ hatScale: 0.98,
19
+ maskTx: 0,
20
+ maskTy: -0.6,
21
+ maskRot: -9,
22
+ maskScale: 1,
23
+ };
24
+
25
+ const IDLE_EYE = {
26
+ leftX: 7.7,
27
+ rightX: 13.7,
28
+ y: 9.5,
29
+ w: 2.6,
30
+ h: 5,
31
+ rx: 1.3,
32
+ };
33
+
34
+ const TIMING = {
35
+ hold: 0.35,
36
+ lampStart: 0.22,
37
+ lampInEnd: 0.84,
38
+ switchStart: 0.92,
39
+ switchEnd: 1.36,
40
+ maskStart: 1.28,
41
+ maskEnd: 2.18,
42
+ hatStart: 1.48,
43
+ hatEnd: 2.42,
44
+ eyeStart: 2.12,
45
+ eyeEnd: 3.12,
46
+ lampOutStart: 2.82,
47
+ lampOutEnd: 3.42,
48
+ settleEnd: 3.65,
49
+ };
50
+
51
+ const SLEEP_MASK_PATH = {
52
+ d: "M488.728,341.587l-7.846-2.599c-0.405-16.992-7.605-47.34-48.625-70.941c-38.301-22.036-96.652-33.215-173.431-33.224c-76.822,0-135.146-11.165-173.438,33.183c-42.335,24.344-48.659,55.883-48.661,72.516c0,2.608,0.135,5.183,0.352,7.735h-2.649c-0.001,0-0.001,0-0.002,0c-9.635,0-17.446,7.811-17.448,17.445c-0.001,9.636,7.81,17.449,17.445,17.45l13,0.001c15.257,28.43,45.267,47.814,79.728,47.818c20.016-0.001,36.647-11.511,54.256-23.695c20.65-14.29,44.048-30.481,77.388-30.481c33.359,0.003,56.757,16.204,77.402,30.497c17.61,12.192,34.24,23.707,54.251,23.709h0.012c24.153,0,46.861-9.404,63.941-26.481c8.937-8.936,15.751-19.422,20.239-30.839l3.111,1.031c1.82,0.604,3.67,0.89,5.489,0.89c7.318,0,14.133-4.64,16.56-11.966C502.835,354.489,497.876,344.617,488.728,341.587Z",
53
+ bboxX: 15, bboxY: 232, bboxW: 487, bboxH: 200
54
+ };
55
+
56
+ const STAR_LOCKED = {
57
+ cx: 8.55, cy: 0.35, size: 1.00, rotation: 30,
58
+ cornerRound: 0.27, chubbiness: 0, innerRatio: 0.56
59
+ };
60
+
61
+ const WAKE_SWITCH = {
62
+ cx: 15.6,
63
+ cy: -5.2,
64
+ dayKnobOffsetX: -3,
65
+ nightKnobOffsetX: -0.2,
66
+ };
67
+
68
+ const stage = document.getElementById('stage');
69
+ const scrubber = document.getElementById('scrubber');
70
+ const timeOut = document.getElementById('time');
71
+ const phaseEl = document.getElementById('phase');
72
+ let playing = true;
73
+ let peekEyes = false;
74
+ let start = performance.now();
75
+ let manualT = 0;
76
+
77
+ function clamp01(v) { return Math.max(0, Math.min(1, v)); }
78
+ function lerp(a, b, t) { return a + (b - a) * t; }
79
+ function progress(t, a, b) { return clamp01((t - a) / Math.max(0.0001, b - a)); }
80
+ function smoothstep(a, b, t) {
81
+ const x = progress(t, a, b);
82
+ return x * x * (3 - 2 * x);
83
+ }
84
+ function easeInOut(t) {
85
+ return t < .5 ? 4*t*t*t : 1 - Math.pow(-2*t + 2, 3) / 2;
86
+ }
87
+ function easeOutCubic(t) { return 1 - Math.pow(1 - t, 3); }
88
+
89
+ function commonDefs(p) {
90
+ return `
91
+ <linearGradient id="${p}-body" x1="12" y1="2" x2="12" y2="22" gradientUnits="userSpaceOnUse">
92
+ <stop offset="0" stop-color="#93c5fd"/>
93
+ <stop offset="0.5" stop-color="#60a5fa"/>
94
+ <stop offset="1" stop-color="#3b82f6"/>
95
+ </linearGradient>
96
+ <linearGradient id="${p}-eye" x1="0" y1="3" x2="0" y2="21" gradientUnits="userSpaceOnUse">
97
+ <stop offset="0" stop-color="#B1A7FF"/>
98
+ <stop offset="0.55" stop-color="#7A9DFF"/>
99
+ <stop offset="1" stop-color="#3941FF"/>
100
+ </linearGradient>
101
+ <radialGradient id="${p}-hi" cx="0.45" cy="0.25" r="0.55">
102
+ <stop offset="0" stop-color="#93c5fd" stop-opacity="0.9"/>
103
+ <stop offset="1" stop-color="#93c5fd" stop-opacity="0"/>
104
+ </radialGradient>
105
+ <linearGradient id="${p}-hat" x1="11" y1="-3" x2="14" y2="6" gradientUnits="userSpaceOnUse">
106
+ <stop offset="0" stop-color="#7AA0FF"/>
107
+ <stop offset="0.45" stop-color="#3941FF"/>
108
+ <stop offset="1" stop-color="#1F2BC2"/>
109
+ </linearGradient>
110
+ <linearGradient id="${p}-cuff" x1="12" y1="3.0" x2="12" y2="8.0" gradientUnits="userSpaceOnUse">
111
+ <stop offset="0" stop-color="#93c5fd"/>
112
+ <stop offset="0.5" stop-color="#fafbff"/>
113
+ <stop offset="1" stop-color="#e8ecf6"/>
114
+ </linearGradient>
115
+ <linearGradient id="${p}-star-yellow" x1="0" y1="-2" x2="0" y2="2" gradientUnits="userSpaceOnUse">
116
+ <stop offset="0" stop-color="#FFE9A8"/>
117
+ <stop offset="0.5" stop-color="#FFD360"/>
118
+ <stop offset="1" stop-color="#F5A623"/>
119
+ </linearGradient>
120
+ <filter id="${p}-star-glow" x="-80%" y="-80%" width="260%" height="260%">
121
+ <feDropShadow dx="0" dy="0.4" stdDeviation="0.5" flood-color="#F5A623" flood-opacity="0.32"/>
122
+ </filter>
123
+ <filter id="${p}-shadow" x="-50%" y="-50%" width="200%" height="200%">
124
+ <feDropShadow class="cloud-drop-shadow" dx="0" dy="0.6" stdDeviation="0.8" flood-color="#3941FF" flood-opacity="0.35"/>
125
+ </filter>
126
+ <filter id="${p}-edge-blur" x="-40%" y="-40%" width="180%" height="180%">
127
+ <feGaussianBlur stdDeviation="0.16"/>
128
+ </filter>
129
+ <filter id="${p}-soft" x="-30%" y="-30%" width="160%" height="160%">
130
+ <feGaussianBlur stdDeviation="0.18"/>
131
+ </filter>
132
+ <linearGradient id="${p}-toggle-day" x1="0" y1="0" x2="0" y2="1">
133
+ <stop offset="0" stop-color="#E5EDFF"/><stop offset="1" stop-color="#BFD6FF"/>
134
+ </linearGradient>
135
+ <linearGradient id="${p}-toggle-night" x1="0" y1="0" x2="0" y2="1">
136
+ <stop offset="0" stop-color="#2A3554"/><stop offset="1" stop-color="#0F1428"/>
137
+ </linearGradient>
138
+ <clipPath id="${p}-clip"><path d="${CLOUD_D}"/></clipPath>
139
+ `;
140
+ }
141
+
142
+ function makeFluffyCuff(p, cx, cy, rx, ry, asym, bumps) {
143
+ let parts = [];
144
+ const circles = [];
145
+ for (let i = 0; i < bumps; i++) {
146
+ const ang = (i * 2 * Math.PI) / bumps - Math.PI / 2;
147
+ const x = cx + Math.cos(ang) * rx;
148
+ const y = cy + Math.sin(ang) * ry;
149
+ const sizeY = -Math.sin(ang);
150
+ const sizeBoost = 0.18 * (sizeY + 1) / 2 + 0.10;
151
+ const jitter = ((i * 13) % 7) / 35;
152
+ let r = 0.62 + sizeBoost + jitter;
153
+ if (asym !== 0) r *= 1 + asym * Math.cos(ang) * 0.28;
154
+ circles.push({ x, y, r });
155
+ }
156
+ const innerRy = ry + 0.40;
157
+ parts.push(`<g filter="url(#${p}-soft)">`);
158
+ parts.push(`<ellipse cx="${cx}" cy="${cy}" rx="${(rx + 0.30).toFixed(2)}" ry="${(innerRy + 0.30).toFixed(2)}" fill="#7A9DFF" opacity="0.50"/>`);
159
+ circles.forEach(c => parts.push(`<circle cx="${c.x.toFixed(2)}" cy="${c.y.toFixed(2)}" r="${(c.r + 0.30).toFixed(2)}" fill="#7A9DFF" opacity="0.50"/>`));
160
+ parts.push(`</g>`);
161
+ parts.push(`<ellipse cx="${cx}" cy="${cy}" rx="${(rx + 0.15).toFixed(2)}" ry="${(innerRy + 0.15).toFixed(2)}" fill="#aab3c6" opacity="0.65"/>`);
162
+ circles.forEach(c => parts.push(`<circle cx="${c.x.toFixed(2)}" cy="${c.y.toFixed(2)}" r="${(c.r + 0.15).toFixed(2)}" fill="#aab3c6" opacity="0.65"/>`));
163
+ parts.push(`<ellipse cx="${cx}" cy="${cy}" rx="${rx.toFixed(2)}" ry="${innerRy.toFixed(2)}" fill="url(#${p}-cuff)"/>`);
164
+ circles.forEach(c => parts.push(`<circle cx="${c.x.toFixed(2)}" cy="${c.y.toFixed(2)}" r="${c.r.toFixed(2)}" fill="url(#${p}-cuff)"/>`));
165
+ parts.push(`<ellipse cx="${cx}" cy="${(cy - ry * 0.45).toFixed(2)}" rx="${(rx * 0.78).toFixed(2)}" ry="${(ry * 0.32).toFixed(2)}" fill="none" stroke="#ffffff" stroke-opacity="0.55" stroke-width="0.14"/>`);
166
+ return parts.join('');
167
+ }
168
+
169
+ function makeBentHat(bend) {
170
+ const baseLeft = { x: 8.5, y: 5.0 };
171
+ const baseRight = { x: 15.5, y: 5.0 };
172
+ const elbowX = 12 + bend * 2.2;
173
+ const elbowY = -0.5 + bend * 2.3;
174
+ const tipX = 11 - bend * 5.5;
175
+ const tipY = 0.0 + bend * 0.5;
176
+ const tipBottomX = tipX + 1.2 + bend * 0.4;
177
+ const tipBottomY = tipY + 1.4 + bend * 0.3;
178
+ const c1 = { x: baseRight.x + 0.5, y: baseRight.y - 1.5 };
179
+ const c2 = { x: elbowX + 0.8, y: elbowY + 1.0 };
180
+ const c3 = { x: elbowX - 0.5, y: elbowY - 0.8 };
181
+ const c4 = { x: tipX + 1.5, y: tipY - 0.5 };
182
+ const c5 = { x: tipX - 0.3, y: tipY + 0.6 };
183
+ const c6 = { x: tipBottomX - 1.0, y: tipBottomY };
184
+ const c7 = { x: 8.5, y: 4.0 };
185
+ return {
186
+ path: `M ${baseLeft.x} ${baseLeft.y} Q 12 5.55 ${baseRight.x} ${baseRight.y} C ${c1.x.toFixed(2)} ${c1.y.toFixed(2)} ${c2.x.toFixed(2)} ${c2.y.toFixed(2)} ${elbowX.toFixed(2)} ${elbowY.toFixed(2)} C ${c3.x.toFixed(2)} ${c3.y.toFixed(2)} ${c4.x.toFixed(2)} ${c4.y.toFixed(2)} ${tipX.toFixed(2)} ${tipY.toFixed(2)} C ${c5.x.toFixed(2)} ${c5.y.toFixed(2)} ${c6.x.toFixed(2)} ${c6.y.toFixed(2)} ${tipBottomX.toFixed(2)} ${tipBottomY.toFixed(2)} C ${c7.x.toFixed(2)} ${c7.y.toFixed(2)} 8.0 4.5 ${baseLeft.x} ${baseLeft.y} Z`
187
+ };
188
+ }
189
+
190
+ function makeStar(cx, cy, r, rotationDeg, cornerRound, chubbiness, innerRatio) {
191
+ const innerR = r * innerRatio;
192
+ const rotRad = (rotationDeg * Math.PI) / 180;
193
+ const verts = [];
194
+ for (let i = 0; i < 10; i++) {
195
+ const ang = (i * Math.PI / 5) + rotRad - Math.PI / 2;
196
+ const radius = i % 2 === 0 ? r : innerR;
197
+ verts.push({ x: cx + Math.cos(ang) * radius, y: cy + Math.sin(ang) * radius });
198
+ }
199
+ const inP = [], outP = [];
200
+ for (let i = 0; i < 10; i++) {
201
+ const prev = verts[(i - 1 + 10) % 10];
202
+ const cur = verts[i];
203
+ const next = verts[(i + 1) % 10];
204
+ const v1x = prev.x - cur.x, v1y = prev.y - cur.y;
205
+ const v2x = next.x - cur.x, v2y = next.y - cur.y;
206
+ const v1Len = Math.hypot(v1x, v1y);
207
+ const v2Len = Math.hypot(v2x, v2y);
208
+ const cr = Math.min(cornerRound, v1Len * 0.48, v2Len * 0.48);
209
+ inP[i] = { x: cur.x + (v1x / v1Len) * cr, y: cur.y + (v1y / v1Len) * cr };
210
+ outP[i] = { x: cur.x + (v2x / v2Len) * cr, y: cur.y + (v2y / v2Len) * cr };
211
+ }
212
+ let path = `M ${inP[0].x.toFixed(2)} ${inP[0].y.toFixed(2)} `;
213
+ for (let i = 0; i < 10; i++) {
214
+ path += `Q ${verts[i].x.toFixed(2)} ${verts[i].y.toFixed(2)} ${outP[i].x.toFixed(2)} ${outP[i].y.toFixed(2)} `;
215
+ const nextI = (i + 1) % 10;
216
+ const startP = outP[i], endP = inP[nextI];
217
+ if (chubbiness > 0) {
218
+ const midX = (startP.x + endP.x) / 2, midY = (startP.y + endP.y) / 2;
219
+ const dx = midX - cx, dy = midY - cy;
220
+ const len = Math.hypot(dx, dy) || 1;
221
+ const offset = chubbiness * r * 0.32;
222
+ path += `Q ${(midX + (dx / len) * offset).toFixed(2)} ${(midY + (dy / len) * offset).toFixed(2)} ${endP.x.toFixed(2)} ${endP.y.toFixed(2)} `;
223
+ } else {
224
+ path += `L ${endP.x.toFixed(2)} ${endP.y.toFixed(2)} `;
225
+ }
226
+ }
227
+ return `${path}Z`;
228
+ }
229
+
230
+ function makeSleepMask(p, tx, ty, rot, scale) {
231
+ const cx = 12 + tx;
232
+ const cy = 12 + ty;
233
+ const W = 16.61 * scale;
234
+ const H = 7.55 * scale;
235
+ const eyeScale = 1.18;
236
+ const eyeRot = 5;
237
+ const eyeOffsetY = -0.25;
238
+ const lashW = 2.45;
239
+ const lashH = 0.70;
240
+ const lashStroke = 0.45;
241
+ const lashGap = 6.00 * scale;
242
+ const lashHairLen = 0.66;
243
+ const lashHairCount = 3;
244
+
245
+ const sx = W / SLEEP_MASK_PATH.bboxW;
246
+ const sy = H / SLEEP_MASK_PATH.bboxH;
247
+ const cxOrig = SLEEP_MASK_PATH.bboxX + SLEEP_MASK_PATH.bboxW / 2;
248
+ const cyOrig = SLEEP_MASK_PATH.bboxY + SLEEP_MASK_PATH.bboxH / 2;
249
+ const body = `<g transform="translate(${cx} ${cy}) scale(${sx.toFixed(5)} ${sy.toFixed(5)}) translate(${(-cxOrig).toFixed(2)} ${(-cyOrig).toFixed(2)})">
250
+ <path d="${SLEEP_MASK_PATH.d}" fill="#22305A" stroke="#000000" stroke-width="0.22" stroke-linejoin="round" stroke-linecap="round" vector-effect="non-scaling-stroke"/>
251
+ </g>`;
252
+
253
+ const arcLocal = `<path d="M ${(-lashW/2).toFixed(2)} 0 Q 0 ${(lashH * 2).toFixed(2)} ${(lashW/2).toFixed(2)} 0" fill="none" stroke="#FFFFFF" stroke-width="${lashStroke}" stroke-linecap="round"/>`;
254
+ const hairs = [];
255
+ const tPad = 0.18;
256
+ for (let i = 0; i < lashHairCount; i++) {
257
+ const t = tPad + (i / (lashHairCount - 1)) * (1 - 2 * tPad);
258
+ const sxh = (1-t)*(1-t)*(-lashW/2) + t*t*(lashW/2);
259
+ const syh = 2*(1-t)*t*(2*lashH);
260
+ const tangX = 2*(1-t)*(lashW/2) + 2*t*(lashW/2);
261
+ const tangY = 2*(1-t)*(2*lashH) + 2*t*(-2*lashH);
262
+ const tLen = Math.hypot(tangX, tangY);
263
+ const normX1 = -tangY / tLen, normY1 = tangX / tLen;
264
+ const normX2 = tangY / tLen, normY2 = -tangX / tLen;
265
+ const useFirst = normY1 > 0;
266
+ const dirX = useFirst ? normX1 : normX2;
267
+ const dirY = useFirst ? normY1 : normY2;
268
+ hairs.push(`<line x1="${sxh.toFixed(2)}" y1="${syh.toFixed(2)}" x2="${(sxh + dirX * lashHairLen).toFixed(2)}" y2="${(syh + dirY * lashHairLen).toFixed(2)}" stroke="#FFFFFF" stroke-width="${(lashStroke * 0.85).toFixed(2)}" stroke-linecap="round" opacity="0.92"/>`);
269
+ }
270
+
271
+ const eyeL = cx - lashGap / 2;
272
+ const eyeR = cx + lashGap / 2;
273
+ const wrapEye = (ecx, sign) => `<g transform="translate(${ecx.toFixed(2)} ${(cy + eyeOffsetY).toFixed(2)}) rotate(${(sign * eyeRot).toFixed(2)}) scale(${eyeScale.toFixed(3)})">${arcLocal}${hairs.join('')}</g>`;
274
+ return `<g class="sleep-mask" transform="rotate(${rot} ${cx} ${cy})" filter="url(#${p}-shadow)">${body}${wrapEye(eyeL, -1)}${wrapEye(eyeR, 1)}</g>`;
275
+ }
276
+
277
+ function makeCloudling(p) {
278
+ return `
279
+ <g class="cloudling-base">
280
+ <g class="edge-system">
281
+ <use class="edge-contact" href="#${p}-cloud-shape" fill="none" stroke="#7d8aa7" stroke-width="1.4" stroke-linejoin="round" transform="translate(0 0.18)" filter="url(#${p}-edge-blur)"/>
282
+ <use class="edge-rim-soft" href="#${p}-cloud-shape" fill="none" stroke="#7A9DFF" stroke-width="1.2" stroke-linejoin="round" filter="url(#${p}-edge-blur)"/>
283
+ <use class="edge-rim-tight" href="#${p}-cloud-shape" fill="none" stroke="#aab3c6" stroke-width="0.8" stroke-linejoin="round"/>
284
+ </g>
285
+ <g filter="url(#${p}-shadow)">
286
+ <use href="#${p}-cloud-shape" fill="url(#${p}-body)"/>
287
+ <rect x="1" y="2" width="22" height="11" fill="url(#${p}-hi)" clip-path="url(#${p}-clip)"/>
288
+ </g>
289
+ </g>
290
+ `;
291
+ }
292
+
293
+ function sleepyEyePath(cx, cy, w, h, tiltDeg, flip) {
294
+ const x1 = cx - w / 2;
295
+ const x2 = cx + w / 2;
296
+ const mid = cy + h * 0.56;
297
+ const c1x = cx - w * 0.18;
298
+ const c2x = cx + w * 0.18;
299
+ const tilt = flip * tiltDeg * 0.018;
300
+ return `M ${x1.toFixed(2)} ${(cy - tilt).toFixed(2)} C ${c1x.toFixed(2)} ${mid.toFixed(2)} ${c2x.toFixed(2)} ${mid.toFixed(2)} ${x2.toFixed(2)} ${(cy + tilt).toFixed(2)}`;
301
+ }
302
+
303
+ function makeBodyEyes(p, openU) {
304
+ const u = clamp01(openU);
305
+ const closedOpacity = 1 - smoothstep(0.36, 0.74, u);
306
+ const capsuleOpacity = smoothstep(0.22, 1, u);
307
+ const eyeCenterY = IDLE_EYE.y + IDLE_EYE.h / 2;
308
+ const h = lerp(0.20, IDLE_EYE.h, easeInOut(u));
309
+ const y = eyeCenterY - h / 2;
310
+ const rx = Math.min(IDLE_EYE.rx, h / 2);
311
+ const closedStroke = lerp(0.82, 0.40, u);
312
+ return `
313
+ <g class="body-eyes">
314
+ <g fill="none" stroke="url(#${p}-eye)" stroke-width="${closedStroke.toFixed(2)}" stroke-linecap="round" stroke-linejoin="round" opacity="${closedOpacity.toFixed(3)}">
315
+ <path d="${sleepyEyePath(9.00, 12.12, 2.72, 1.16, 7.7, -1)}"/>
316
+ <path d="${sleepyEyePath(15.00, 12.12, 2.72, 1.16, 7.7, 1)}"/>
317
+ </g>
318
+ <g opacity="${capsuleOpacity.toFixed(3)}">
319
+ <rect x="${IDLE_EYE.leftX}" y="${y.toFixed(3)}" width="${IDLE_EYE.w}" height="${h.toFixed(3)}" rx="${rx.toFixed(3)}" ry="${rx.toFixed(3)}" fill="url(#${p}-eye)" stroke="#ffffff" stroke-width="0.08" stroke-opacity="0.7"/>
320
+ <rect x="${IDLE_EYE.rightX}" y="${y.toFixed(3)}" width="${IDLE_EYE.w}" height="${h.toFixed(3)}" rx="${rx.toFixed(3)}" ry="${rx.toFixed(3)}" fill="url(#${p}-eye)" stroke="#ffffff" stroke-width="0.08" stroke-opacity="0.7"/>
321
+ </g>
322
+ </g>
323
+ `;
324
+ }
325
+
326
+ function makeHat(p, tx, ty, rot, scale, opacity) {
327
+ const hatData = makeBentHat(0.4);
328
+ const cuff = makeFluffyCuff(p, 12, 5.4, 3.7, 0.85, 0, 18);
329
+ const s = STAR_LOCKED;
330
+ const star = makeStar(s.cx, s.cy, s.size, s.rotation, s.cornerRound, s.chubbiness, s.innerRatio);
331
+ return `
332
+ <g opacity="${opacity.toFixed(3)}" transform="translate(${tx.toFixed(3)} ${ty.toFixed(3)}) rotate(${rot.toFixed(3)} 12 5.4) scale(${scale.toFixed(4)})">
333
+ <g filter="url(#${p}-shadow)"><path d="${hatData.path}" fill="url(#${p}-hat)"/></g>
334
+ <g>${cuff}</g>
335
+ <g filter="url(#${p}-star-glow)">
336
+ <path d="${star}" fill="url(#${p}-star-yellow)" stroke="#ffffff" stroke-width="0.06" stroke-opacity="0.7" stroke-linejoin="round"/>
337
+ </g>
338
+ </g>
339
+ `;
340
+ }
341
+
342
+ function makeWakeSwitch(p, cx, cy, toggleMix, opacity, scale, rot, glow) {
343
+ const mix = clamp01(toggleMix);
344
+ const dayOpacity = 1 - mix;
345
+ const nightOpacity = mix;
346
+ const dayKnobOpacity = clamp01(1 - mix * 2.2);
347
+ const nightKnobOpacity = clamp01((mix - 0.18) / 0.82);
348
+ const knobX = cx + lerp(WAKE_SWITCH.dayKnobOffsetX, WAKE_SWITCH.nightKnobOffsetX, mix);
349
+ const knobY = cy;
350
+
351
+ const dayKnob = `
352
+ <g opacity="${dayKnobOpacity.toFixed(2)}">
353
+ <circle cx="${knobX.toFixed(2)}" cy="${knobY.toFixed(2)}" r="2.4" fill="#fff" filter="url(#${p}-shadow)"/>
354
+ <circle cx="${(knobX+0.85).toFixed(2)}" cy="${(knobY-0.95).toFixed(2)}" r="0.50" fill="#D4DFFF" opacity="0.78"/>
355
+ <circle cx="${(knobX+1.15).toFixed(2)}" cy="${(knobY+0.55).toFixed(2)}" r="0.28" fill="#D4DFFF" opacity="0.72"/>
356
+ </g>
357
+ `;
358
+
359
+ const outerR = 2.35, innerR = 1.70, innerDx = 0.80;
360
+ const ix = (outerR*outerR - innerR*innerR + innerDx*innerDx) / (2*innerDx);
361
+ const iy = Math.sqrt(outerR*outerR - ix*ix);
362
+ const nightKnob = `
363
+ <g filter="url(#${p}-shadow)" opacity="${nightKnobOpacity.toFixed(2)}">
364
+ <path d="
365
+ M ${(knobX+ix).toFixed(3)} ${(knobY-iy).toFixed(3)}
366
+ A ${outerR} ${outerR} 0 1 1 ${(knobX+ix).toFixed(3)} ${(knobY+iy).toFixed(3)}
367
+ A ${innerR} ${innerR} 0 1 0 ${(knobX+ix).toFixed(3)} ${(knobY-iy).toFixed(3)}
368
+ Z
369
+ " fill="#fff"/>
370
+ </g>
371
+ `;
372
+
373
+ const stars = `
374
+ <g opacity="${nightOpacity.toFixed(2)}">
375
+ <circle cx="${(cx-1.5).toFixed(2)}" cy="${(cy-0.9).toFixed(2)}" r="0.18" fill="#fff" opacity="0.95"/>
376
+ <circle cx="${(cx-0.5).toFixed(2)}" cy="${(cy+1.3).toFixed(2)}" r="0.14" fill="#fff" opacity="0.85"/>
377
+ <circle cx="${(cx+0.6).toFixed(2)}" cy="${(cy-0.4).toFixed(2)}" r="0.10" fill="#fff" opacity="0.75"/>
378
+ <circle cx="${(cx-1.2).toFixed(2)}" cy="${(cy+1.6).toFixed(2)}" r="0.10" fill="#fff" opacity="0.78"/>
379
+ <circle cx="${cx.toFixed(2)}" cy="${(cy-1.3).toFixed(2)}" r="0.13" fill="#fff" opacity="0.88"/>
380
+ </g>
381
+ `;
382
+
383
+ const rayOpacity = glow * 0.34;
384
+ const fineOpacity = glow * 0.22;
385
+ const rays = `
386
+ <g fill="none" stroke="#FFE9A8" stroke-linecap="round" filter="url(#${p}-soft)">
387
+ <path d="M ${(cx-7.8).toFixed(2)} ${(cy-4.2).toFixed(2)} L ${(cx-9.5-glow*0.45).toFixed(2)} ${(cy-5.2-glow*0.25).toFixed(2)}" stroke-width="0.34" opacity="${rayOpacity.toFixed(3)}"/>
388
+ <path d="M ${(cx-2.0).toFixed(2)} ${(cy-4.6).toFixed(2)} L ${(cx-2.5).toFixed(2)} ${(cy-6.2-glow*0.45).toFixed(2)}" stroke-width="0.28" opacity="${fineOpacity.toFixed(3)}"/>
389
+ <path d="M ${(cx+5.9).toFixed(2)} ${(cy-4.0).toFixed(2)} L ${(cx+7.4+glow*0.40).toFixed(2)} ${(cy-5.0-glow*0.20).toFixed(2)}" stroke-width="0.34" opacity="${rayOpacity.toFixed(3)}"/>
390
+ <path d="M ${(cx+7.8).toFixed(2)} ${(cy-0.2).toFixed(2)} L ${(cx+9.5+glow*0.50).toFixed(2)} ${(cy-0.2).toFixed(2)}" stroke-width="0.30" opacity="${fineOpacity.toFixed(3)}"/>
391
+ <path d="M ${(cx+4.8).toFixed(2)} ${(cy+4.0).toFixed(2)} L ${(cx+6.0+glow*0.32).toFixed(2)} ${(cy+5.0+glow*0.24).toFixed(2)}" stroke-width="0.28" opacity="${fineOpacity.toFixed(3)}"/>
392
+ <path d="M ${(cx-6.7).toFixed(2)} ${(cy+3.6).toFixed(2)} L ${(cx-8.1-glow*0.38).toFixed(2)} ${(cy+4.6+glow*0.22).toFixed(2)}" stroke-width="0.30" opacity="${rayOpacity.toFixed(3)}"/>
393
+ <path d="M ${(cx-8.2).toFixed(2)} ${(cy-0.2).toFixed(2)} L ${(cx-9.7-glow*0.42).toFixed(2)} ${(cy-0.2).toFixed(2)}" stroke-width="0.26" opacity="${fineOpacity.toFixed(3)}"/>
394
+ </g>
395
+ `;
396
+
397
+ return `
398
+ <g opacity="${opacity.toFixed(3)}" transform="translate(${cx} ${cy}) rotate(${rot.toFixed(3)}) scale(${scale.toFixed(3)}) translate(${-cx} ${-cy})">
399
+ ${rays}
400
+ <g filter="url(#${p}-shadow)">
401
+ <rect x="${(cx-7).toFixed(2)}" y="${(cy-3).toFixed(2)}" width="14" height="6" rx="3" ry="3" fill="url(#${p}-toggle-day)" opacity="${dayOpacity.toFixed(2)}"/>
402
+ <rect x="${(cx-7).toFixed(2)}" y="${(cy-3).toFixed(2)}" width="14" height="6" rx="3" ry="3" fill="url(#${p}-toggle-night)" opacity="${nightOpacity.toFixed(2)}"/>
403
+ <rect x="${(cx-7).toFixed(2)}" y="${(cy-3).toFixed(2)}" width="14" height="6" rx="3" ry="3" fill="none" stroke="#fff" stroke-opacity="0.18" stroke-width="0.12"/>
404
+ </g>
405
+ ${stars}
406
+ ${dayKnob}
407
+ ${nightKnob}
408
+ </g>
409
+ `;
410
+ }
411
+
412
+ function phaseName(t) {
413
+ if (t < TIMING.lampInEnd) return 'switch appears';
414
+ if (t < TIMING.switchEnd) return 'night to day';
415
+ if (t < TIMING.maskEnd) return 'mask sliding';
416
+ if (t < TIMING.eyeEnd) return 'body eyes waking';
417
+ return 'idle handoff';
418
+ }
419
+
420
+ function computeFrame(t) {
421
+ const lampIn = easeOutCubic(progress(t, TIMING.lampStart, TIMING.lampInEnd));
422
+ const switchU = easeInOut(progress(t, TIMING.switchStart, TIMING.switchEnd));
423
+ const lampOut = smoothstep(TIMING.lampOutStart, TIMING.lampOutEnd, t);
424
+ const maskU = easeOutCubic(progress(t, TIMING.maskStart, TIMING.maskEnd));
425
+ const hatU = easeOutCubic(progress(t, TIMING.hatStart, TIMING.hatEnd));
426
+ const eyeU = easeInOut(progress(t, TIMING.eyeStart, TIMING.eyeEnd));
427
+ const settleU = easeInOut(progress(t, 1.54, TIMING.settleEnd));
428
+ const maskClear = peekEyes ? 1 : maskU;
429
+ return {
430
+ phase: phaseName(t),
431
+ sceneRot: lerp(SLEEP.bodyTilt, 0, settleU),
432
+ scale: lerp(SLEEP.breathScale, 1.0, settleU),
433
+ eyeU,
434
+ wakeGlow: Math.sin(switchU * Math.PI) * 0.18,
435
+ lamp: {
436
+ opacity: lampIn * (1 - lampOut),
437
+ toggleMix: lerp(1, 0, switchU),
438
+ scale: lerp(0.88, 1, lampIn) + Math.sin(switchU * Math.PI) * 0.035,
439
+ rot: Math.sin(switchU * Math.PI * 2) * 1.15 * (1 - switchU),
440
+ glow: Math.sin(switchU * Math.PI),
441
+ },
442
+ mask: {
443
+ tx: lerp(SLEEP.maskTx, 7.6, maskClear),
444
+ ty: lerp(SLEEP.maskTy, -5.1, maskClear) - Math.sin(maskClear * Math.PI) * 0.08,
445
+ rot: lerp(SLEEP.maskRot, 14, maskClear),
446
+ opacity: peekEyes ? 0.08 : (1 - smoothstep(0.68, 1, maskU)),
447
+ },
448
+ hat: {
449
+ tx: lerp(SLEEP.hatTx, -7.0, hatU),
450
+ ty: lerp(SLEEP.hatTy, -6.4, hatU) - Math.sin(hatU * Math.PI) * 0.10,
451
+ rot: lerp(SLEEP.hatRot, -26, hatU),
452
+ scale: lerp(SLEEP.hatScale, 0.86, hatU),
453
+ opacity: 1 - smoothstep(0.62, 1, hatU),
454
+ },
455
+ };
456
+ }
457
+
458
+ function renderFrame(t) {
459
+ const f = computeFrame(t);
460
+ const p = 'si';
461
+ const mask = makeSleepMask(p, f.mask.tx, f.mask.ty, f.mask.rot, SLEEP.maskScale);
462
+ const wakeSwitch = makeWakeSwitch(p, WAKE_SWITCH.cx, WAKE_SWITCH.cy, f.lamp.toggleMix, f.lamp.opacity, f.lamp.scale, f.lamp.rot, f.lamp.glow);
463
+ stage.innerHTML = `
464
+ <style>
465
+ .edge-rim-tight { stroke-opacity: .9; }
466
+ .edge-rim-soft { stroke-opacity: .75; }
467
+ .edge-contact { stroke-opacity: .9; }
468
+ .wrap {
469
+ width: min(960px, 100%);
470
+ display: grid;
471
+ gap: 18px;
472
+ }
473
+ .header {
474
+ display: flex;
475
+ justify-content: space-between;
476
+ gap: 14px;
477
+ align-items: end;
478
+ }
479
+ #stage {
480
+ width: min(520px, 82vw);
481
+ aspect-ratio: 1;
482
+ display: grid;
483
+ place-items: center;
484
+ }
485
+ output {
486
+ min-width: 76px;
487
+ color: rgba(255,255,255,.70);
488
+ font-size: 12px;
489
+ text-align: right;
490
+ }
491
+ .phase {
492
+ display: flex;
493
+ flex-wrap: wrap;
494
+ gap: 9px 16px;
495
+ color: rgba(255,255,255,.62);
496
+ font-size: 12px;
497
+ }
498
+ .phase b { color: rgba(255,255,255,.88); font-weight: 650; }
499
+ @media (prefers-color-scheme: light) {
500
+ .edge-rim-tight { stroke-opacity: .95; }
501
+ .edge-rim-soft { stroke-opacity: .85; }
502
+ .edge-contact { stroke-opacity: .95; }
503
+ .cloud-drop-shadow { flood-opacity: .13; }
504
+ .phase, output { color: rgba(21,33,63,.62); }
505
+ .phase b { color: rgba(21,33,63,.86); }
506
+ .cloud-drop-shadow { flood-opacity: .13; }
507
+ .food-cloud-shadow { flood-opacity: .28; flood-color: #5060FF; }
508
+ .food-cloud > path {
509
+ stroke: #5870E8 !important;
510
+ stroke-width: 1.2 !important;
511
+ stroke-opacity: .9 !important;
512
+ vector-effect: non-scaling-stroke !important;
513
+ }
514
+ }
515
+ </style>
516
+ <defs>
517
+ ${commonDefs(p)}
518
+ <path id="${p}-cloud-shape" d="${CLOUD_D}"/>
519
+ </defs>
520
+ <g class="scene" transform="rotate(${f.sceneRot.toFixed(3)} 12 12)">
521
+ <g transform="translate(12 12) scale(${f.scale.toFixed(4)}) translate(-12 -12)">
522
+ <use href="#${p}-cloud-shape" fill="none" stroke="#FFE9A8" stroke-width="0.92" stroke-linejoin="round" opacity="${f.wakeGlow.toFixed(3)}" filter="url(#${p}-soft)"/>
523
+ ${makeCloudling(p)}
524
+ ${makeBodyEyes(p, f.eyeU)}
525
+ ${makeHat(p, f.hat.tx, f.hat.ty, f.hat.rot, f.hat.scale, f.hat.opacity)}
526
+ <g opacity="${f.mask.opacity.toFixed(3)}">${mask}</g>
527
+ </g>
528
+ </g>
529
+ ${wakeSwitch}
530
+ `;
531
+ scrubber.value = t.toFixed(2);
532
+ timeOut.value = `${t.toFixed(2)} s`;
533
+ phaseEl.innerHTML = `<span>phase: <b>${f.phase}</b></span><span>switch ${((1 - f.lamp.toggleMix) * 100).toFixed(0)}%</span><span>mask ${(progress(t, TIMING.maskStart, TIMING.maskEnd) * 100).toFixed(0)}%</span><span>body eyes ${(f.eyeU * 100).toFixed(0)}%</span><span>tilt ${f.sceneRot.toFixed(1)}deg</span><span>scale ${f.scale.toFixed(3)}</span>`;
534
+ }
535
+
536
+ function currentTime(now) {
537
+ if (!playing) return manualT;
538
+ return Math.min((now - start) / 1000, TIMING.settleEnd);
539
+ }
540
+
541
+ function loop(now) {
542
+ const t = currentTime(now);
543
+ renderFrame(t);
544
+ if (playing && t >= TIMING.settleEnd) {
545
+ playing = false;
546
+ manualT = TIMING.settleEnd;
547
+ { const __btn = document.getElementById('btn-play'); if (__btn) __btn.textContent = 'Play'; }
548
+ }
549
+ requestAnimationFrame(loop);
550
+ }
551
+
552
+ renderFrame(0);
553
+ requestAnimationFrame(loop);
554
+ ]]></script>
555
+ </svg>