@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,390 +1,390 @@
1
- <svg id="cloudling" xmlns="http://www.w3.org/2000/svg" viewBox="-6 -6 36 36" preserveAspectRatio="xMidYMid meet">
2
- <style><![CDATA[
3
- .v {
4
- text-align: right;
5
- font: 600 10px ui-monospace, SFMono-Regular, Menlo, monospace;
6
- color: #7A9DFF;
7
- }
8
- .edge-rim-tight { stroke-opacity: .9; }
9
- .edge-rim-soft { stroke-opacity: .75; }
10
- .edge-contact { stroke-opacity: .9; }
11
- .duration-probe {
12
- opacity: 0;
13
- animation: mini-alert-duration-probe 2.6s linear 1 both;
14
- }
15
- @keyframes mini-alert-duration-probe {
16
- from { transform: translateX(0); }
17
- to { transform: translateX(0); }
18
- }
19
- @media (prefers-color-scheme: light) {
20
- .v { color: #3941FF; }
21
- .edge-rim-tight { stroke-opacity: .95; }
22
- .edge-rim-soft { stroke-opacity: .85; }
23
- .edge-contact { stroke-opacity: .95; }
24
- .cloud-drop-shadow { flood-opacity: .13; }
25
- .food-cloud-shadow { flood-opacity: .28; flood-color: #5060FF; }
26
- .food-cloud > path {
27
- stroke: #5870E8 !important;
28
- stroke-width: 1.2 !important;
29
- stroke-opacity: .9 !important;
30
- vector-effect: non-scaling-stroke !important;
31
- }
32
- }
33
- ]]></style>
34
- <defs>
35
- <linearGradient id="body-grad" x1="12" y1="2" x2="12" y2="22" gradientUnits="userSpaceOnUse">
36
- <stop offset="0" stop-color="#93c5fd"/>
37
- <stop offset="0.5" stop-color="#60a5fa"/>
38
- <stop offset="1" stop-color="#3b82f6"/>
39
- </linearGradient>
40
- <linearGradient id="eye-grad" x1="12" y1="3" x2="12" y2="21" gradientUnits="userSpaceOnUse">
41
- <stop offset="0" stop-color="#B1A7FF"/>
42
- <stop offset="0.5" stop-color="#7A9DFF"/>
43
- <stop offset="1" stop-color="#3941FF"/>
44
- </linearGradient>
45
- <linearGradient id="signal-grad" x1="-2" y1="12" x2="26" y2="12" gradientUnits="userSpaceOnUse">
46
- <stop offset="0" stop-color="#B1A7FF" stop-opacity="0.08"/>
47
- <stop offset="0.22" stop-color="#8EA7FF" stop-opacity="0.92"/>
48
- <stop offset="0.78" stop-color="#7A9DFF" stop-opacity="0.92"/>
49
- <stop offset="1" stop-color="#3941FF" stop-opacity="0.08"/>
50
- </linearGradient>
51
- <linearGradient id="alert-grad" x1="19" y1="4" x2="5" y2="22" gradientUnits="userSpaceOnUse">
52
- <stop offset="0" stop-color="#FFD36E" stop-opacity="0.98"/>
53
- <stop offset="0.36" stop-color="#FFA56B" stop-opacity="0.94"/>
54
- <stop offset="0.72" stop-color="#8EA7FF" stop-opacity="0.74"/>
55
- <stop offset="1" stop-color="#3941FF" stop-opacity="0.16"/>
56
- </linearGradient>
57
- <radialGradient id="hi-grad" cx="0.45" cy="0.25" r="0.55">
58
- <stop offset="0" stop-color="#93c5fd" stop-opacity="0.9"/>
59
- <stop offset="1" stop-color="#93c5fd" stop-opacity="0"/>
60
- </radialGradient>
61
- <filter id="drop" x="-40%" y="-40%" width="180%" height="180%">
62
- <feDropShadow class="cloud-drop-shadow" dx="0" dy="0.55" stdDeviation="0.72" flood-color="#3941FF" flood-opacity="0.17"/>
63
- </filter>
64
- <filter id="edge-blur" x="-40%" y="-40%" width="180%" height="180%">
65
- <feGaussianBlur stdDeviation="0.16"/>
66
- </filter>
67
- <filter id="pulse-glow" x="-70%" y="-70%" width="240%" height="240%">
68
- <feGaussianBlur id="pulse-blur" stdDeviation="0.42" result="b"/>
69
- <feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
70
- </filter>
71
- <filter id="alert-glow" x="-80%" y="-80%" width="260%" height="260%">
72
- <feGaussianBlur stdDeviation="0.44" result="b"/>
73
- <feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
74
- </filter>
75
- <path id="cloud-shape" 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-.74 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"/>
76
- <clipPath id="cloud-clip">
77
- <use href="#cloud-shape"/>
78
- </clipPath>
79
- </defs>
80
-
81
- <rect x="-12" y="-12" width="48" height="48" fill="transparent"/>
82
- <rect class="duration-probe" x="-12" y="-12" width="0.01" height="0.01" fill="transparent"/>
83
-
84
- <g id="runtime-layer">
85
- <g id="pulses-layer"></g>
86
- <g id="g-translate">
87
- <g id="g-rotate">
88
- <g id="g-squash">
89
- <g id="edge-system">
90
- <use class="edge-contact" href="#cloud-shape" fill="none" stroke="#7d8aa7" stroke-width="1.00" stroke-linejoin="round" transform="translate(0 .18)" filter="url(#edge-blur)"/>
91
- <use class="edge-rim-soft" href="#cloud-shape" fill="none" stroke="#7A9DFF" stroke-width=".84" stroke-linejoin="round" filter="url(#edge-blur)"/>
92
- <use class="edge-rim-tight" href="#cloud-shape" fill="none" stroke="#aab3c6" stroke-width=".38" stroke-linejoin="round"/>
93
- </g>
94
- <g filter="url(#drop)">
95
- <use href="#cloud-shape" fill="url(#body-grad)"/>
96
- <rect x="1" y="2" width="22" height="11" fill="url(#hi-grad)" clip-path="url(#cloud-clip)"/>
97
- </g>
98
- <g id="rim-flash-layer"></g>
99
- <g id="eyes-counter">
100
- <g id="eyes-js">
101
- <rect id="eye-l" x="6.65" y="9.65" width="2.2" height="4.65" rx="1.1" fill="url(#eye-grad)" stroke="#ffffff" stroke-width="0.08" stroke-opacity="0.7"/>
102
- <rect id="eye-r" x="11.05" y="9.65" width="2.2" height="4.65" rx="1.1" fill="url(#eye-grad)" stroke="#ffffff" stroke-width="0.08" stroke-opacity="0.7"/>
103
- </g>
104
- </g>
105
- </g>
106
- </g>
107
- </g>
108
- </g>
109
-
110
- <g id="__cloudling-export-shims" opacity="0" pointer-events="none" style="display:none">
111
- <g id="phase-readout"></g>
112
- <g id="time-readout"></g>
113
- </g>
114
-
115
- <script type="application/ecmascript"><![CDATA[
116
- const gTrans = document.getElementById("g-translate");
117
- const gRotate = document.getElementById("g-rotate");
118
- const gSquash = document.getElementById("g-squash");
119
- const eyesCounter = document.getElementById("eyes-counter");
120
- const eyeL = document.getElementById("eye-l");
121
- const eyeR = document.getElementById("eye-r");
122
- const pulsesLayer = document.getElementById("pulses-layer");
123
- const rimFlashLayer = document.getElementById("rim-flash-layer");
124
- const pulseBlur = document.getElementById("pulse-blur");
125
- const phaseReadout = document.getElementById("phase-readout");
126
- const timeReadout = document.getElementById("time-readout");
127
-
128
- const CLOUD_D = document.getElementById("cloud-shape").getAttribute("d");
129
- const EYE_BASE = {
130
- l: { x: 6.65, y: 9.65, w: 2.20, h: 4.65, rx: 1.10 },
131
- r: { x: 11.05, y: 9.65, w: 2.20, h: 4.65, rx: 1.10 },
132
- };
133
-
134
- const params = {
135
- totalPeriod: 2600,
136
- ratioA: .22,
137
- ratioB: .50,
138
- shakeAngle: 16,
139
- shakeFreqHz: 7,
140
- jumpY: .52,
141
- squash: .046,
142
- scaleMicro: .040,
143
- scaleMacro: .070,
144
- idleBreathAmp: .018,
145
- idleBreathPeriod: 5000,
146
- pulseLifetimeA: 720,
147
- pulseLifetimeB: 520,
148
- pulseScaleEnd: 1.62,
149
- pulseStrokeWidth: .82,
150
- pulseGlow: .42,
151
- pulseStartRadius: 8.7,
152
- pulseFadeIn: 35,
153
- eyeWiden: .26,
154
- rimPower: 1.12,
155
- };
156
-
157
- let startT = performance.now();
158
- let heldT = 0;
159
- let paused = false;
160
- let pulses = [];
161
- let pulseId = 0;
162
- let lastCycleT = -1;
163
- let emittedA = false;
164
- let emittedBPeaks = 0;
165
- let lastRender = null;
166
-
167
- function clamp(x, lo, hi) { return Math.max(lo, Math.min(hi, x)); }
168
- function easeOutCubic(x) { return 1 - Math.pow(1 - x, 3); }
169
- function easeInOutCubic(x) {
170
- return x < .5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
171
- }
172
- function expPulse(x, center, width) {
173
- const d = (x - center) / width;
174
- return Math.exp(-d * d);
175
- }
176
- function polarPoint(cx, cy, r, deg) {
177
- const a = deg * Math.PI / 180;
178
- return [cx + Math.cos(a) * r, cy + Math.sin(a) * r];
179
- }
180
- function arcPath(cx, cy, r, startDeg, endDeg) {
181
- const [x0, y0] = polarPoint(cx, cy, r, startDeg);
182
- const [x1, y1] = polarPoint(cx, cy, r, endDeg);
183
- const largeArc = Math.abs(endDeg - startDeg) > 180 ? 1 : 0;
184
- const sweep = endDeg >= startDeg ? 1 : 0;
185
- return `M${x0.toFixed(3)} ${y0.toFixed(3)} A${r.toFixed(3)} ${r.toFixed(3)} 0 ${largeArc} ${sweep} ${x1.toFixed(3)} ${y1.toFixed(3)}`;
186
- }
187
- function emitPulse(type, nowMs) {
188
- pulses.push({
189
- id: ++pulseId,
190
- bornT: nowMs,
191
- lifetime: type === "A" ? params.pulseLifetimeA : params.pulseLifetimeB,
192
- type,
193
- });
194
- }
195
- function renderPulses(nowMs) {
196
- pulses = pulses.filter(p => nowMs - p.bornT < p.lifetime);
197
- pulseBlur.setAttribute("stdDeviation", params.pulseGlow.toFixed(3));
198
- let html = "";
199
- for (const p of pulses) {
200
- const ageMs = nowMs - p.bornT;
201
- const t = clamp(ageMs / p.lifetime, 0, 1);
202
- const scale = 1 + (params.pulseScaleEnd - 1) * easeOutCubic(t);
203
- const r = params.pulseStartRadius * scale;
204
- const baseOp = p.type === "A" ? .36 : .86;
205
- const fadeIn = params.pulseFadeIn > 0 ? Math.min(1, ageMs / params.pulseFadeIn) : 1;
206
- const fadeOut = Math.pow(1 - t, p.type === "A" ? 1.20 : 1.48);
207
- const opacity = baseOp * fadeIn * fadeOut;
208
- const wobble = p.type === "B" ? ((p.id % 3) - 1) * 7 : 0;
209
- const strokeW = params.pulseStrokeWidth * (p.type === "A" ? .62 : 1);
210
- const segments = p.type === "A"
211
- ? [[-72, -34], [-10, 20], [36, 58]]
212
- : [[-136, -96], [-54, 16], [42, 82], [130, 170], [190, 218]];
213
- for (let i = 0; i < segments.length; i++) {
214
- const [a0, a1] = segments[i];
215
- const d = arcPath(12, 12, r + (i % 2) * .26, a0 + wobble, a1 + wobble);
216
- const segOp = opacity * (1 - i * .08);
217
- const stroke = (p.type === "B" && i < 2) ? "url(#alert-grad)" : "url(#signal-grad)";
218
- html += `<path d="${d}" fill="none" stroke="${stroke}" stroke-width="${strokeW.toFixed(3)}" stroke-linecap="round" stroke-opacity="${segOp.toFixed(3)}" filter="url(#pulse-glow)"/>`;
219
- }
220
- }
221
- pulsesLayer.innerHTML = html;
222
- }
223
- function setEye(rect, base, widenFactor, heightFactor, tilt) {
224
- const w = base.w * widenFactor;
225
- const h = base.h * heightFactor;
226
- const x = base.x + (base.w - w) / 2;
227
- const y = base.y + (base.h - h) / 2;
228
- rect.setAttribute("x", x.toFixed(3));
229
- rect.setAttribute("y", y.toFixed(3));
230
- rect.setAttribute("width", w.toFixed(3));
231
- rect.setAttribute("height", h.toFixed(3));
232
- rect.setAttribute("rx", Math.min(w / 2, base.rx * widenFactor).toFixed(3));
233
- rect.setAttribute("transform", `rotate(${tilt.toFixed(3)} ${(base.x + base.w / 2).toFixed(3)} ${(base.y + base.h / 2).toFixed(3)})`);
234
- }
235
- function renderAlertLayer(phase, phaseTms, tA, tB, tC, shakePeak, bEnvelope) {
236
- let prep = 0;
237
- let ping = 0;
238
- if (phase === "A") {
239
- prep = easeInOutCubic(clamp(phaseTms / tA, 0, 1));
240
- } else if (phase === "B") {
241
- const b = clamp(phaseTms / tB, 0, 1);
242
- const ping1 = expPulse(b, .10, .055);
243
- const ping2 = expPulse(b, .54, .070);
244
- ping = Math.max(ping1, ping2, shakePeak * bEnvelope * .38);
245
- } else {
246
- const c = clamp(phaseTms / tC, 0, 1);
247
- ping = (1 - easeOutCubic(c)) * .36;
248
- }
249
- const rimOp = clamp((ping * .64 + prep * .13) * params.rimPower, 0, .86);
250
- const rimW = .30 + ping * .50;
251
- rimFlashLayer.innerHTML = rimOp > .015
252
- ? `<use href="#cloud-shape" fill="none" stroke="url(#alert-grad)" stroke-width="${rimW.toFixed(3)}" stroke-linejoin="round" stroke-opacity="${rimOp.toFixed(3)}" filter="url(#alert-glow)"/>`
253
- : "";
254
- }
255
- function phaseAt(tMs) {
256
- const total = params.totalPeriod;
257
- const tA = total * params.ratioA;
258
- const tB = total * params.ratioB;
259
- const tC = total - tA - tB;
260
- let phase = "A";
261
- let phaseTms = tMs;
262
- if (tMs >= tA && tMs < tA + tB) {
263
- phase = "B";
264
- phaseTms = tMs - tA;
265
- } else if (tMs >= tA + tB) {
266
- phase = "C";
267
- phaseTms = tMs - tA - tB;
268
- }
269
- return { phase, phaseTms, tA, tB, tC };
270
- }
271
- function render(tMs, nowMs = performance.now(), allowEmit = false) {
272
- const total = params.totalPeriod;
273
- const tInCycle = ((tMs % total) + total) % total;
274
- if (allowEmit && tInCycle < lastCycleT) {
275
- emittedA = false;
276
- emittedBPeaks = 0;
277
- }
278
- lastCycleT = tInCycle;
279
-
280
- const { phase, phaseTms, tA, tB, tC } = phaseAt(tInCycle);
281
-
282
- if (allowEmit && phase === "A" && !emittedA) {
283
- emitPulse("A", nowMs);
284
- emittedA = true;
285
- }
286
- if (allowEmit && phase === "B") {
287
- const tBSec = phaseTms / 1000;
288
- const peakInterval = 1 / (2 * params.shakeFreqHz);
289
- const expectedPeaks = Math.floor((tBSec - peakInterval / 2) / peakInterval) + 1;
290
- while (emittedBPeaks < expectedPeaks && emittedBPeaks * peakInterval + peakInterval / 2 < (tB / 1000)) {
291
- if (emittedBPeaks % 2 === 0) emitPulse("B", nowMs);
292
- emittedBPeaks++;
293
- }
294
- }
295
-
296
- let rotate = 0;
297
- let jumpY = 0;
298
- let burstX = 1;
299
- let burstY = 1;
300
- let shakePeak = 0;
301
- let bEnvelope = 0;
302
-
303
- if (phase === "B") {
304
- const tBSec = phaseTms / 1000;
305
- const tBTotal = tB / 1000;
306
- const envIn = Math.min(1, tBSec / .15);
307
- const envOut = Math.min(1, (tBTotal - tBSec) / .20);
308
- const env = Math.min(envIn, envOut);
309
- const angularFreq = 2 * Math.PI * params.shakeFreqHz;
310
- const sinV = Math.sin(angularFreq * tBSec);
311
- const absSin = Math.abs(sinV);
312
- shakePeak = absSin;
313
- bEnvelope = env;
314
- rotate = params.shakeAngle * sinV * env;
315
- jumpY = -params.jumpY * Math.abs(Math.sin(angularFreq * tBSec / 2 + Math.PI / 4)) * env;
316
- const micro = 1 + params.scaleMicro * absSin * env;
317
- const macro = 1 + params.scaleMacro * Math.sin(Math.PI * clamp(tBSec / tBTotal, 0, 1));
318
- const squash = 1 - params.squash * absSin * env;
319
- burstX = micro * macro;
320
- burstY = micro * macro * squash;
321
- } else if (phase === "C") {
322
- const tCSec = phaseTms / 1000;
323
- const decay = Math.max(0, 1 - tCSec / (tC / 1000));
324
- const angularFreq = 2 * Math.PI * params.shakeFreqHz * .70;
325
- rotate = params.shakeAngle * decay * decay * .55 * Math.sin(angularFreq * (tB / 1000 + tCSec));
326
- } else {
327
- const p = clamp(phaseTms / tA, 0, 1);
328
- rotate = 1.4 * Math.sin(Math.PI * p);
329
- }
330
-
331
- const breathPhase = (nowMs / params.idleBreathPeriod) * 2 * Math.PI;
332
- const baseBreath = (1 - params.idleBreathAmp) + params.idleBreathAmp * Math.sin(breathPhase);
333
- const sx = baseBreath * burstX;
334
- const sy = baseBreath * burstY;
335
-
336
- gTrans.setAttribute("transform", `translate(0 ${jumpY.toFixed(3)})`);
337
- gRotate.setAttribute("transform", `rotate(${rotate.toFixed(3)} 12 12)`);
338
- gSquash.setAttribute("transform", `translate(12 12) scale(${sx.toFixed(4)} ${sy.toFixed(4)}) translate(-12 -12)`);
339
- eyesCounter.setAttribute("transform", `rotate(${(-rotate).toFixed(3)} 12 12)`);
340
-
341
- let widen = 1;
342
- let height = 1;
343
- let tiltL = 0;
344
- let tiltR = 0;
345
- if (phase === "A") {
346
- const p = clamp(phaseTms / tA, 0, 1);
347
- widen = 1 + params.eyeWiden * easeInOutCubic(p) * .55;
348
- } else if (phase === "B") {
349
- widen = 1 + params.eyeWiden * .95 + shakePeak * bEnvelope * .09;
350
- height = 1.02 + shakePeak * bEnvelope * .045;
351
- tiltL = -3.2 * bEnvelope;
352
- tiltR = 3.2 * bEnvelope;
353
- } else {
354
- const p = clamp(phaseTms / 150, 0, 1);
355
- widen = 1 + params.eyeWiden * (1 - p) * .45;
356
- }
357
- setEye(eyeL, EYE_BASE.l, widen, height, tiltL);
358
- setEye(eyeR, EYE_BASE.r, widen, height, tiltR);
359
-
360
- renderPulses(nowMs);
361
- renderAlertLayer(phase, phaseTms, tA, tB, tC, shakePeak, bEnvelope);
362
- phaseReadout.textContent = `phase: ${phase}`;
363
- timeReadout.textContent = `time: ${Math.round(tInCycle)}ms / ${Math.round(total)}ms`;
364
- lastRender = { t: tInCycle, phase, rotate, jumpY, sx, sy, pulses: pulses.length };
365
- return lastRender;
366
- }
367
- function tick(now) {
368
- if (!paused) {
369
- heldT = now - startT;
370
- render(heldT, now, true);
371
- }
372
- requestAnimationFrame(tick);
373
- }
374
- function syncControls() {
375
- setControl("duration", params.totalPeriod / 1000, 1);
376
- setControl("shake-angle", params.shakeAngle, 0);
377
- setControl("jump-y", params.jumpY, 2);
378
- setControl("squash", params.squash, 3);
379
- setControl("pulse-scale", params.pulseScaleEnd, 2);
380
- setControl("rim-power", params.rimPower, 2);
381
- }
382
- function setControl(id, value, digits) {
383
- const input = document.getElementById(id);
384
- const out = document.getElementById(`${id}-v`);
385
- input.value = String(value);
386
- out.textContent = Number(value).toFixed(digits);
387
- }
388
- requestAnimationFrame(tick);
389
- ]]></script>
1
+ <svg id="cloudling" xmlns="http://www.w3.org/2000/svg" viewBox="-6 -6 36 36" preserveAspectRatio="xMidYMid meet">
2
+ <style><![CDATA[
3
+ .v {
4
+ text-align: right;
5
+ font: 600 10px ui-monospace, SFMono-Regular, Menlo, monospace;
6
+ color: #7A9DFF;
7
+ }
8
+ .edge-rim-tight { stroke-opacity: .9; }
9
+ .edge-rim-soft { stroke-opacity: .75; }
10
+ .edge-contact { stroke-opacity: .9; }
11
+ .duration-probe {
12
+ opacity: 0;
13
+ animation: mini-alert-duration-probe 2.6s linear 1 both;
14
+ }
15
+ @keyframes mini-alert-duration-probe {
16
+ from { transform: translateX(0); }
17
+ to { transform: translateX(0); }
18
+ }
19
+ @media (prefers-color-scheme: light) {
20
+ .v { color: #3941FF; }
21
+ .edge-rim-tight { stroke-opacity: .95; }
22
+ .edge-rim-soft { stroke-opacity: .85; }
23
+ .edge-contact { stroke-opacity: .95; }
24
+ .cloud-drop-shadow { flood-opacity: .13; }
25
+ .food-cloud-shadow { flood-opacity: .28; flood-color: #5060FF; }
26
+ .food-cloud > path {
27
+ stroke: #5870E8 !important;
28
+ stroke-width: 1.2 !important;
29
+ stroke-opacity: .9 !important;
30
+ vector-effect: non-scaling-stroke !important;
31
+ }
32
+ }
33
+ ]]></style>
34
+ <defs>
35
+ <linearGradient id="body-grad" x1="12" y1="2" x2="12" y2="22" gradientUnits="userSpaceOnUse">
36
+ <stop offset="0" stop-color="#93c5fd"/>
37
+ <stop offset="0.5" stop-color="#60a5fa"/>
38
+ <stop offset="1" stop-color="#3b82f6"/>
39
+ </linearGradient>
40
+ <linearGradient id="eye-grad" x1="12" y1="3" x2="12" y2="21" gradientUnits="userSpaceOnUse">
41
+ <stop offset="0" stop-color="#B1A7FF"/>
42
+ <stop offset="0.5" stop-color="#7A9DFF"/>
43
+ <stop offset="1" stop-color="#3941FF"/>
44
+ </linearGradient>
45
+ <linearGradient id="signal-grad" x1="-2" y1="12" x2="26" y2="12" gradientUnits="userSpaceOnUse">
46
+ <stop offset="0" stop-color="#B1A7FF" stop-opacity="0.08"/>
47
+ <stop offset="0.22" stop-color="#8EA7FF" stop-opacity="0.92"/>
48
+ <stop offset="0.78" stop-color="#7A9DFF" stop-opacity="0.92"/>
49
+ <stop offset="1" stop-color="#3941FF" stop-opacity="0.08"/>
50
+ </linearGradient>
51
+ <linearGradient id="alert-grad" x1="19" y1="4" x2="5" y2="22" gradientUnits="userSpaceOnUse">
52
+ <stop offset="0" stop-color="#FFD36E" stop-opacity="0.98"/>
53
+ <stop offset="0.36" stop-color="#FFA56B" stop-opacity="0.94"/>
54
+ <stop offset="0.72" stop-color="#8EA7FF" stop-opacity="0.74"/>
55
+ <stop offset="1" stop-color="#3941FF" stop-opacity="0.16"/>
56
+ </linearGradient>
57
+ <radialGradient id="hi-grad" cx="0.45" cy="0.25" r="0.55">
58
+ <stop offset="0" stop-color="#93c5fd" stop-opacity="0.9"/>
59
+ <stop offset="1" stop-color="#93c5fd" stop-opacity="0"/>
60
+ </radialGradient>
61
+ <filter id="drop" x="-40%" y="-40%" width="180%" height="180%">
62
+ <feDropShadow class="cloud-drop-shadow" dx="0" dy="0.55" stdDeviation="0.72" flood-color="#3941FF" flood-opacity="0.17"/>
63
+ </filter>
64
+ <filter id="edge-blur" x="-40%" y="-40%" width="180%" height="180%">
65
+ <feGaussianBlur stdDeviation="0.16"/>
66
+ </filter>
67
+ <filter id="pulse-glow" x="-70%" y="-70%" width="240%" height="240%">
68
+ <feGaussianBlur id="pulse-blur" stdDeviation="0.42" result="b"/>
69
+ <feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
70
+ </filter>
71
+ <filter id="alert-glow" x="-80%" y="-80%" width="260%" height="260%">
72
+ <feGaussianBlur stdDeviation="0.44" result="b"/>
73
+ <feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
74
+ </filter>
75
+ <path id="cloud-shape" 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-.74 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"/>
76
+ <clipPath id="cloud-clip">
77
+ <use href="#cloud-shape"/>
78
+ </clipPath>
79
+ </defs>
80
+
81
+ <rect x="-12" y="-12" width="48" height="48" fill="transparent"/>
82
+ <rect class="duration-probe" x="-12" y="-12" width="0.01" height="0.01" fill="transparent"/>
83
+
84
+ <g id="runtime-layer">
85
+ <g id="pulses-layer"></g>
86
+ <g id="g-translate">
87
+ <g id="g-rotate">
88
+ <g id="g-squash">
89
+ <g id="edge-system">
90
+ <use class="edge-contact" href="#cloud-shape" fill="none" stroke="#7d8aa7" stroke-width="1.00" stroke-linejoin="round" transform="translate(0 .18)" filter="url(#edge-blur)"/>
91
+ <use class="edge-rim-soft" href="#cloud-shape" fill="none" stroke="#7A9DFF" stroke-width=".84" stroke-linejoin="round" filter="url(#edge-blur)"/>
92
+ <use class="edge-rim-tight" href="#cloud-shape" fill="none" stroke="#aab3c6" stroke-width=".38" stroke-linejoin="round"/>
93
+ </g>
94
+ <g filter="url(#drop)">
95
+ <use href="#cloud-shape" fill="url(#body-grad)"/>
96
+ <rect x="1" y="2" width="22" height="11" fill="url(#hi-grad)" clip-path="url(#cloud-clip)"/>
97
+ </g>
98
+ <g id="rim-flash-layer"></g>
99
+ <g id="eyes-counter">
100
+ <g id="eyes-js">
101
+ <rect id="eye-l" x="6.65" y="9.65" width="2.2" height="4.65" rx="1.1" fill="url(#eye-grad)" stroke="#ffffff" stroke-width="0.08" stroke-opacity="0.7"/>
102
+ <rect id="eye-r" x="11.05" y="9.65" width="2.2" height="4.65" rx="1.1" fill="url(#eye-grad)" stroke="#ffffff" stroke-width="0.08" stroke-opacity="0.7"/>
103
+ </g>
104
+ </g>
105
+ </g>
106
+ </g>
107
+ </g>
108
+ </g>
109
+
110
+ <g id="__cloudling-export-shims" opacity="0" pointer-events="none" style="display:none">
111
+ <g id="phase-readout"></g>
112
+ <g id="time-readout"></g>
113
+ </g>
114
+
115
+ <script type="application/ecmascript"><![CDATA[
116
+ const gTrans = document.getElementById("g-translate");
117
+ const gRotate = document.getElementById("g-rotate");
118
+ const gSquash = document.getElementById("g-squash");
119
+ const eyesCounter = document.getElementById("eyes-counter");
120
+ const eyeL = document.getElementById("eye-l");
121
+ const eyeR = document.getElementById("eye-r");
122
+ const pulsesLayer = document.getElementById("pulses-layer");
123
+ const rimFlashLayer = document.getElementById("rim-flash-layer");
124
+ const pulseBlur = document.getElementById("pulse-blur");
125
+ const phaseReadout = document.getElementById("phase-readout");
126
+ const timeReadout = document.getElementById("time-readout");
127
+
128
+ const CLOUD_D = document.getElementById("cloud-shape").getAttribute("d");
129
+ const EYE_BASE = {
130
+ l: { x: 6.65, y: 9.65, w: 2.20, h: 4.65, rx: 1.10 },
131
+ r: { x: 11.05, y: 9.65, w: 2.20, h: 4.65, rx: 1.10 },
132
+ };
133
+
134
+ const params = {
135
+ totalPeriod: 2600,
136
+ ratioA: .22,
137
+ ratioB: .50,
138
+ shakeAngle: 16,
139
+ shakeFreqHz: 7,
140
+ jumpY: .52,
141
+ squash: .046,
142
+ scaleMicro: .040,
143
+ scaleMacro: .070,
144
+ idleBreathAmp: .018,
145
+ idleBreathPeriod: 5000,
146
+ pulseLifetimeA: 720,
147
+ pulseLifetimeB: 520,
148
+ pulseScaleEnd: 1.62,
149
+ pulseStrokeWidth: .82,
150
+ pulseGlow: .42,
151
+ pulseStartRadius: 8.7,
152
+ pulseFadeIn: 35,
153
+ eyeWiden: .26,
154
+ rimPower: 1.12,
155
+ };
156
+
157
+ let startT = performance.now();
158
+ let heldT = 0;
159
+ let paused = false;
160
+ let pulses = [];
161
+ let pulseId = 0;
162
+ let lastCycleT = -1;
163
+ let emittedA = false;
164
+ let emittedBPeaks = 0;
165
+ let lastRender = null;
166
+
167
+ function clamp(x, lo, hi) { return Math.max(lo, Math.min(hi, x)); }
168
+ function easeOutCubic(x) { return 1 - Math.pow(1 - x, 3); }
169
+ function easeInOutCubic(x) {
170
+ return x < .5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
171
+ }
172
+ function expPulse(x, center, width) {
173
+ const d = (x - center) / width;
174
+ return Math.exp(-d * d);
175
+ }
176
+ function polarPoint(cx, cy, r, deg) {
177
+ const a = deg * Math.PI / 180;
178
+ return [cx + Math.cos(a) * r, cy + Math.sin(a) * r];
179
+ }
180
+ function arcPath(cx, cy, r, startDeg, endDeg) {
181
+ const [x0, y0] = polarPoint(cx, cy, r, startDeg);
182
+ const [x1, y1] = polarPoint(cx, cy, r, endDeg);
183
+ const largeArc = Math.abs(endDeg - startDeg) > 180 ? 1 : 0;
184
+ const sweep = endDeg >= startDeg ? 1 : 0;
185
+ return `M${x0.toFixed(3)} ${y0.toFixed(3)} A${r.toFixed(3)} ${r.toFixed(3)} 0 ${largeArc} ${sweep} ${x1.toFixed(3)} ${y1.toFixed(3)}`;
186
+ }
187
+ function emitPulse(type, nowMs) {
188
+ pulses.push({
189
+ id: ++pulseId,
190
+ bornT: nowMs,
191
+ lifetime: type === "A" ? params.pulseLifetimeA : params.pulseLifetimeB,
192
+ type,
193
+ });
194
+ }
195
+ function renderPulses(nowMs) {
196
+ pulses = pulses.filter(p => nowMs - p.bornT < p.lifetime);
197
+ pulseBlur.setAttribute("stdDeviation", params.pulseGlow.toFixed(3));
198
+ let html = "";
199
+ for (const p of pulses) {
200
+ const ageMs = nowMs - p.bornT;
201
+ const t = clamp(ageMs / p.lifetime, 0, 1);
202
+ const scale = 1 + (params.pulseScaleEnd - 1) * easeOutCubic(t);
203
+ const r = params.pulseStartRadius * scale;
204
+ const baseOp = p.type === "A" ? .36 : .86;
205
+ const fadeIn = params.pulseFadeIn > 0 ? Math.min(1, ageMs / params.pulseFadeIn) : 1;
206
+ const fadeOut = Math.pow(1 - t, p.type === "A" ? 1.20 : 1.48);
207
+ const opacity = baseOp * fadeIn * fadeOut;
208
+ const wobble = p.type === "B" ? ((p.id % 3) - 1) * 7 : 0;
209
+ const strokeW = params.pulseStrokeWidth * (p.type === "A" ? .62 : 1);
210
+ const segments = p.type === "A"
211
+ ? [[-72, -34], [-10, 20], [36, 58]]
212
+ : [[-136, -96], [-54, 16], [42, 82], [130, 170], [190, 218]];
213
+ for (let i = 0; i < segments.length; i++) {
214
+ const [a0, a1] = segments[i];
215
+ const d = arcPath(12, 12, r + (i % 2) * .26, a0 + wobble, a1 + wobble);
216
+ const segOp = opacity * (1 - i * .08);
217
+ const stroke = (p.type === "B" && i < 2) ? "url(#alert-grad)" : "url(#signal-grad)";
218
+ html += `<path d="${d}" fill="none" stroke="${stroke}" stroke-width="${strokeW.toFixed(3)}" stroke-linecap="round" stroke-opacity="${segOp.toFixed(3)}" filter="url(#pulse-glow)"/>`;
219
+ }
220
+ }
221
+ pulsesLayer.innerHTML = html;
222
+ }
223
+ function setEye(rect, base, widenFactor, heightFactor, tilt) {
224
+ const w = base.w * widenFactor;
225
+ const h = base.h * heightFactor;
226
+ const x = base.x + (base.w - w) / 2;
227
+ const y = base.y + (base.h - h) / 2;
228
+ rect.setAttribute("x", x.toFixed(3));
229
+ rect.setAttribute("y", y.toFixed(3));
230
+ rect.setAttribute("width", w.toFixed(3));
231
+ rect.setAttribute("height", h.toFixed(3));
232
+ rect.setAttribute("rx", Math.min(w / 2, base.rx * widenFactor).toFixed(3));
233
+ rect.setAttribute("transform", `rotate(${tilt.toFixed(3)} ${(base.x + base.w / 2).toFixed(3)} ${(base.y + base.h / 2).toFixed(3)})`);
234
+ }
235
+ function renderAlertLayer(phase, phaseTms, tA, tB, tC, shakePeak, bEnvelope) {
236
+ let prep = 0;
237
+ let ping = 0;
238
+ if (phase === "A") {
239
+ prep = easeInOutCubic(clamp(phaseTms / tA, 0, 1));
240
+ } else if (phase === "B") {
241
+ const b = clamp(phaseTms / tB, 0, 1);
242
+ const ping1 = expPulse(b, .10, .055);
243
+ const ping2 = expPulse(b, .54, .070);
244
+ ping = Math.max(ping1, ping2, shakePeak * bEnvelope * .38);
245
+ } else {
246
+ const c = clamp(phaseTms / tC, 0, 1);
247
+ ping = (1 - easeOutCubic(c)) * .36;
248
+ }
249
+ const rimOp = clamp((ping * .64 + prep * .13) * params.rimPower, 0, .86);
250
+ const rimW = .30 + ping * .50;
251
+ rimFlashLayer.innerHTML = rimOp > .015
252
+ ? `<use href="#cloud-shape" fill="none" stroke="url(#alert-grad)" stroke-width="${rimW.toFixed(3)}" stroke-linejoin="round" stroke-opacity="${rimOp.toFixed(3)}" filter="url(#alert-glow)"/>`
253
+ : "";
254
+ }
255
+ function phaseAt(tMs) {
256
+ const total = params.totalPeriod;
257
+ const tA = total * params.ratioA;
258
+ const tB = total * params.ratioB;
259
+ const tC = total - tA - tB;
260
+ let phase = "A";
261
+ let phaseTms = tMs;
262
+ if (tMs >= tA && tMs < tA + tB) {
263
+ phase = "B";
264
+ phaseTms = tMs - tA;
265
+ } else if (tMs >= tA + tB) {
266
+ phase = "C";
267
+ phaseTms = tMs - tA - tB;
268
+ }
269
+ return { phase, phaseTms, tA, tB, tC };
270
+ }
271
+ function render(tMs, nowMs = performance.now(), allowEmit = false) {
272
+ const total = params.totalPeriod;
273
+ const tInCycle = ((tMs % total) + total) % total;
274
+ if (allowEmit && tInCycle < lastCycleT) {
275
+ emittedA = false;
276
+ emittedBPeaks = 0;
277
+ }
278
+ lastCycleT = tInCycle;
279
+
280
+ const { phase, phaseTms, tA, tB, tC } = phaseAt(tInCycle);
281
+
282
+ if (allowEmit && phase === "A" && !emittedA) {
283
+ emitPulse("A", nowMs);
284
+ emittedA = true;
285
+ }
286
+ if (allowEmit && phase === "B") {
287
+ const tBSec = phaseTms / 1000;
288
+ const peakInterval = 1 / (2 * params.shakeFreqHz);
289
+ const expectedPeaks = Math.floor((tBSec - peakInterval / 2) / peakInterval) + 1;
290
+ while (emittedBPeaks < expectedPeaks && emittedBPeaks * peakInterval + peakInterval / 2 < (tB / 1000)) {
291
+ if (emittedBPeaks % 2 === 0) emitPulse("B", nowMs);
292
+ emittedBPeaks++;
293
+ }
294
+ }
295
+
296
+ let rotate = 0;
297
+ let jumpY = 0;
298
+ let burstX = 1;
299
+ let burstY = 1;
300
+ let shakePeak = 0;
301
+ let bEnvelope = 0;
302
+
303
+ if (phase === "B") {
304
+ const tBSec = phaseTms / 1000;
305
+ const tBTotal = tB / 1000;
306
+ const envIn = Math.min(1, tBSec / .15);
307
+ const envOut = Math.min(1, (tBTotal - tBSec) / .20);
308
+ const env = Math.min(envIn, envOut);
309
+ const angularFreq = 2 * Math.PI * params.shakeFreqHz;
310
+ const sinV = Math.sin(angularFreq * tBSec);
311
+ const absSin = Math.abs(sinV);
312
+ shakePeak = absSin;
313
+ bEnvelope = env;
314
+ rotate = params.shakeAngle * sinV * env;
315
+ jumpY = -params.jumpY * Math.abs(Math.sin(angularFreq * tBSec / 2 + Math.PI / 4)) * env;
316
+ const micro = 1 + params.scaleMicro * absSin * env;
317
+ const macro = 1 + params.scaleMacro * Math.sin(Math.PI * clamp(tBSec / tBTotal, 0, 1));
318
+ const squash = 1 - params.squash * absSin * env;
319
+ burstX = micro * macro;
320
+ burstY = micro * macro * squash;
321
+ } else if (phase === "C") {
322
+ const tCSec = phaseTms / 1000;
323
+ const decay = Math.max(0, 1 - tCSec / (tC / 1000));
324
+ const angularFreq = 2 * Math.PI * params.shakeFreqHz * .70;
325
+ rotate = params.shakeAngle * decay * decay * .55 * Math.sin(angularFreq * (tB / 1000 + tCSec));
326
+ } else {
327
+ const p = clamp(phaseTms / tA, 0, 1);
328
+ rotate = 1.4 * Math.sin(Math.PI * p);
329
+ }
330
+
331
+ const breathPhase = (nowMs / params.idleBreathPeriod) * 2 * Math.PI;
332
+ const baseBreath = (1 - params.idleBreathAmp) + params.idleBreathAmp * Math.sin(breathPhase);
333
+ const sx = baseBreath * burstX;
334
+ const sy = baseBreath * burstY;
335
+
336
+ gTrans.setAttribute("transform", `translate(0 ${jumpY.toFixed(3)})`);
337
+ gRotate.setAttribute("transform", `rotate(${rotate.toFixed(3)} 12 12)`);
338
+ gSquash.setAttribute("transform", `translate(12 12) scale(${sx.toFixed(4)} ${sy.toFixed(4)}) translate(-12 -12)`);
339
+ eyesCounter.setAttribute("transform", `rotate(${(-rotate).toFixed(3)} 12 12)`);
340
+
341
+ let widen = 1;
342
+ let height = 1;
343
+ let tiltL = 0;
344
+ let tiltR = 0;
345
+ if (phase === "A") {
346
+ const p = clamp(phaseTms / tA, 0, 1);
347
+ widen = 1 + params.eyeWiden * easeInOutCubic(p) * .55;
348
+ } else if (phase === "B") {
349
+ widen = 1 + params.eyeWiden * .95 + shakePeak * bEnvelope * .09;
350
+ height = 1.02 + shakePeak * bEnvelope * .045;
351
+ tiltL = -3.2 * bEnvelope;
352
+ tiltR = 3.2 * bEnvelope;
353
+ } else {
354
+ const p = clamp(phaseTms / 150, 0, 1);
355
+ widen = 1 + params.eyeWiden * (1 - p) * .45;
356
+ }
357
+ setEye(eyeL, EYE_BASE.l, widen, height, tiltL);
358
+ setEye(eyeR, EYE_BASE.r, widen, height, tiltR);
359
+
360
+ renderPulses(nowMs);
361
+ renderAlertLayer(phase, phaseTms, tA, tB, tC, shakePeak, bEnvelope);
362
+ phaseReadout.textContent = `phase: ${phase}`;
363
+ timeReadout.textContent = `time: ${Math.round(tInCycle)}ms / ${Math.round(total)}ms`;
364
+ lastRender = { t: tInCycle, phase, rotate, jumpY, sx, sy, pulses: pulses.length };
365
+ return lastRender;
366
+ }
367
+ function tick(now) {
368
+ if (!paused) {
369
+ heldT = now - startT;
370
+ render(heldT, now, true);
371
+ }
372
+ requestAnimationFrame(tick);
373
+ }
374
+ function syncControls() {
375
+ setControl("duration", params.totalPeriod / 1000, 1);
376
+ setControl("shake-angle", params.shakeAngle, 0);
377
+ setControl("jump-y", params.jumpY, 2);
378
+ setControl("squash", params.squash, 3);
379
+ setControl("pulse-scale", params.pulseScaleEnd, 2);
380
+ setControl("rim-power", params.rimPower, 2);
381
+ }
382
+ function setControl(id, value, digits) {
383
+ const input = document.getElementById(id);
384
+ const out = document.getElementById(`${id}-v`);
385
+ input.value = String(value);
386
+ out.textContent = Number(value).toFixed(digits);
387
+ }
388
+ requestAnimationFrame(tick);
389
+ ]]></script>
390
390
  </svg>