1const BASE: u32 = 0xF0000;
6
7#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
8pub enum Icon {
9 Files = 0,
10 Search = 1,
11 Git = 2,
12 Settings = 3,
13 Folder = 4,
14 FolderOpen = 5,
15 File = 6,
16 ChevronRight = 7,
17 ChevronDown = 8,
18 Close = 9,
19 ReplaceAll = 10,
20 Globe = 11,
21 Check = 12,
22 Agents = 13,
23 Outline = 14,
24 Layers = 15,
26 ListBullet = 30,
28 ListNumber = 53,
29 ListTask = 16,
30 Quote = 17,
31 Code = 18,
32 Link = 19,
33 Table = 20,
34 Picture = 21,
35 Sigma = 22,
36 Rule = 23,
37 Comment = 24,
38 Export = 25,
39 Play = 26,
40 Cite = 27,
41 More = 28,
42 Diagram = 29,
43 Track = 31,
44 PlayAll = 32,
45 Stop = 33,
46 Restart = 34,
47 AddCell = 35,
48 AddText = 36,
49 Terminal = 37,
50 Diff = 38,
51 Replace = 39,
52 ArrowUp = 40,
53 ArrowDown = 41,
54 Maximize = 42,
56 Minimize = 43,
57 Panel = 44,
59 SymbolFunction = 45,
62 SymbolType = 46,
63 SymbolField = 47,
64 SymbolValue = 48,
65 Bell = 49,
67 Question = 50,
69 CircleCheck = 51,
70 CircleX = 52,
71 HidePane = 54,
75 HidePanel = 55,
78 ShowPane = 56,
80 Smile = 57,
82 Power = 58,
84 FolderFilled = 59,
90 FileRust = 60,
91 FilePython = 61,
92 FileMarkdown = 62,
93 FileGit = 63,
94 FileJson = 64,
95 FileConfig = 65,
96 FileCode = 66,
97 HideSidebar = 90,
100 ShowSidebar = 91,
103 AgentClaude = 67,
111 AgentCodex = 68,
112 AgentGemini = 69,
113 Program = 70,
114 AgentOpenCode = 71,
115 AgentCopilot = 72,
116 AgentCursor = 73,
117 AgentKiro = 74,
118 Log = 92,
120 ChevronLeft = 93,
122 Cloud = 94,
124 Send = 95,
126 Copy = 96,
128}
129
130#[derive(Clone, Copy, Debug, PartialEq, Eq)]
132pub struct Piece {
133 pub icon: Icon,
134 pub width: u8,
135 pub height: u8,
136 pub column: u8,
137 pub row: u8,
138}
139
140impl Piece {
141 pub fn symbol(self) -> char {
142 let code = (self.icon as u32) << 8
143 | u32::from(self.width) << 6
144 | u32::from(self.height) << 4
145 | u32::from(self.column) << 2
146 | u32::from(self.row);
147 char::from_u32(BASE + code).expect("the private plane holds every code")
148 }
149
150 pub fn decode(symbol: &str) -> Option<Self> {
151 let mut chars = symbol.chars();
152 let code = (chars.next()? as u32).checked_sub(BASE)?;
153 if chars.next().is_some() || code >= 1 << 12 {
154 return None;
155 }
156 let icon = match code >> 8 {
157 0 => Icon::Files,
158 1 => Icon::Search,
159 2 => Icon::Git,
160 13 => Icon::Agents,
161 14 => Icon::Outline,
162 15 => Icon::Layers,
163 _ => Icon::Settings,
164 };
165 Some(Self {
166 icon,
167 width: (code >> 6 & 3) as u8,
168 height: (code >> 4 & 3) as u8,
169 column: (code >> 2 & 3) as u8,
170 row: (code & 3) as u8,
171 })
172 }
173
174 pub fn fallback(self) -> &'static str {
176 const ART: [[[&str; 3]; 2]; 7] = [
177 [["▛", "▀", "▜"], ["▙", "▄", "▟"]],
178 [["▞", "▀", "▚"], ["▚", "▄", "▟"]],
179 [["●", "─", "●"], ["●", "─", "╯"]],
180 [["▚", "▀", "▞"], ["▞", "▄", "▚"]],
181 [["▗", "▄", "▖"], ["▐", "█", "▌"]],
182 [["▪", "─", "─"], [" ", "▪", "─"]],
183 [["▗", "▀", "▖"], ["▝", "▀", "▘"]],
184 ];
185 let art = match self.icon {
186 Icon::Agents => 4,
187 Icon::Outline => 5,
188 Icon::Layers => 6,
189 other => (other as usize).min(3),
190 };
191 if self.width == 1 || self.height == 1 {
192 if self.column > 0 {
193 return " ";
194 }
195 return match self.icon {
196 Icon::Files => "▤",
197 Icon::Search => "⌕",
198 Icon::Git => "⎇",
199 Icon::Agents => "◉",
200 Icon::Outline => "≡",
201 Icon::Layers => "≋",
202 _ => "⚙",
203 };
204 }
205 ART[art][self.row.min(1) as usize][self.column.min(2) as usize]
206 }
207}
208
209type Point = (f32, f32);
210
211fn segment(p: Point, a: Point, b: Point) -> f32 {
212 let (dx, dy) = (b.0 - a.0, b.1 - a.1);
213 let t = (((p.0 - a.0) * dx + (p.1 - a.1) * dy) / (dx * dx + dy * dy)).clamp(0.0, 1.0);
214 ((p.0 - a.0 - t * dx).powi(2) + (p.1 - a.1 - t * dy).powi(2)).sqrt()
215}
216
217fn path(p: Point, points: &[Point]) -> f32 {
219 points
220 .windows(2)
221 .map(|pair| segment(p, pair[0], pair[1]))
222 .fold(f32::MAX, f32::min)
223}
224
225fn circle(p: Point, c: Point) -> f32 {
226 ((p.0 - c.0).powi(2) + (p.1 - c.1).powi(2)).sqrt()
227}
228
229fn ring(p: Point, c: Point, radius: f32) -> f32 {
231 (circle(p, c) - radius).abs()
232}
233
234fn rounded(p: Point, min: Point, max: Point, radius: f32) -> f32 {
236 let (cx, cy) = ((min.0 + max.0) / 2.0, (min.1 + max.1) / 2.0);
237 let (qx, qy) = (
238 (p.0 - cx).abs() - (max.0 - min.0) / 2.0 + radius,
239 (p.1 - cy).abs() - (max.1 - min.1) / 2.0 + radius,
240 );
241 let outside = (qx.max(0.0).powi(2) + qy.max(0.0).powi(2)).sqrt();
242 (outside + qx.max(qy).min(0.0) - radius).abs()
243}
244
245fn solid(p: Point, min: Point, max: Point, radius: f32) -> f32 {
247 let (cx, cy) = ((min.0 + max.0) / 2.0, (min.1 + max.1) / 2.0);
248 let (qx, qy) = (
249 (p.0 - cx).abs() - (max.0 - min.0) / 2.0 + radius,
250 (p.1 - cy).abs() - (max.1 - min.1) / 2.0 + radius,
251 );
252 let outside = (qx.max(0.0).powi(2) + qy.max(0.0).powi(2)).sqrt();
253 (outside + qx.max(qy).min(0.0) - radius).max(0.0)
254}
255
256fn disc(p: Point, c: Point, radius: f32) -> f32 {
258 (circle(p, c) - radius).max(0.0)
259}
260
261fn cut(fill: f32, line: f32, half: f32) -> f32 {
264 if line < half { f32::MAX } else { fill }
265}
266
267fn replace(p: Point) -> f32 {
270 rounded(p, (2.0, 14.0), (10.0, 22.0), 2.0)
271 .min(path(
272 p,
273 &[(6.0, 10.0), (6.0, 5.0), (6.9, 2.9), (9.0, 2.0), (10.0, 2.0)],
274 ))
275 .min(path(p, &[(3.0, 7.0), (6.0, 10.0), (9.0, 7.0)]))
276 .min(path(p, &[(14.0, 4.0), (14.6, 2.6), (16.0, 2.0)]))
277 .min(path(p, &[(16.0, 10.0), (14.6, 9.4), (14.0, 8.0)]))
278 .min(path(p, &[(20.0, 2.0), (21.4, 2.6), (22.0, 4.0)]))
279 .min(path(p, &[(22.0, 8.0), (21.4, 9.4), (20.0, 10.0)]))
280}
281
282fn half_stroke(icon: Icon) -> f32 {
285 match icon {
286 Icon::Files
287 | Icon::Search
288 | Icon::Git
289 | Icon::Settings
290 | Icon::Outline
291 | Icon::Layers
292 | Icon::File
293 | Icon::Folder
294 | Icon::FolderOpen
295 | Icon::ChevronRight
296 | Icon::ChevronLeft
297 | Icon::ChevronDown
298 | Icon::Close
299 | Icon::ArrowUp
300 | Icon::ArrowDown
301 | Icon::Replace
302 | Icon::Maximize
303 | Icon::Minimize
304 | Icon::SymbolFunction
305 | Icon::SymbolType
306 | Icon::SymbolField
307 | Icon::SymbolValue
308 | Icon::HidePane
309 | Icon::HidePanel
310 | Icon::ShowPane
311 | Icon::HideSidebar
312 | Icon::ShowSidebar
313 | Icon::ReplaceAll => 0.9,
314 Icon::Agents => 0.8,
315 Icon::AgentClaude => 1.3,
316 Icon::AgentCodex
317 | Icon::Program
318 | Icon::AgentOpenCode
319 | Icon::AgentCopilot
320 | Icon::AgentCursor
321 | Icon::AgentKiro => 1.0,
322 Icon::AgentGemini => 0.5,
323 Icon::Check => 1.7,
324 _ => 1.15,
325 }
326}
327
328pub fn inked(icon: Icon, u: f32, v: f32) -> bool {
331 let p = (u * 24.0, v * 24.0);
332 let distance = match icon {
333 Icon::Files => path(
335 p,
336 &[
337 (9.0, 18.0),
338 (7.6, 17.4),
339 (7.0, 16.0),
340 (7.0, 4.0),
341 (7.6, 2.6),
342 (9.0, 2.0),
343 (16.0, 2.0),
344 (20.0, 6.0),
345 (20.0, 16.0),
346 (19.4, 17.4),
347 (18.0, 18.0),
348 (9.0, 18.0),
349 ],
350 )
351 .min(path(
352 p,
353 &[
354 (20.0, 7.0),
355 (17.0, 7.0),
356 (15.6, 6.4),
357 (15.0, 5.0),
358 (15.0, 2.0),
359 ],
360 ))
361 .min(path(
362 p,
363 &[
364 (3.0, 7.6),
365 (3.0, 20.4),
366 (3.5, 21.5),
367 (4.6, 22.0),
368 (14.4, 22.0),
369 ],
370 )),
371 Icon::Search => ring(p, (11.0, 11.0), 7.0).min(segment(p, (16.65, 16.65), (20.0, 20.0))),
372 Icon::Git => {
373 let joint = (9.0, 9.0);
374 let quarter = p.0 >= joint.0 && p.1 >= joint.1;
375 let curve = if quarter {
376 ring(p, joint, 9.0)
377 } else {
378 f32::MAX
379 };
380 ring(p, (6.0, 18.0), 3.0)
381 .min(ring(p, (18.0, 6.0), 3.0))
382 .min(segment(p, (6.0, 3.0), (6.0, 15.0)))
383 .min(curve)
384 }
385 Icon::Settings => segment(p, (20.0, 7.0), (11.0, 7.0))
387 .min(segment(p, (14.0, 17.0), (5.0, 17.0)))
388 .min(ring(p, (17.0, 17.0), 3.0))
389 .min(ring(p, (7.0, 7.0), 3.0)),
390 Icon::Agents => rounded(p, (4.0, 8.5), (20.0, 20.5), 3.0)
391 .min(path(p, &[(12.0, 8.5), (12.0, 3.5), (8.5, 3.5)]))
392 .min(segment(p, (9.0, 13.0), (9.0, 15.5)))
393 .min(segment(p, (15.0, 13.0), (15.0, 15.5)))
394 .min(segment(p, (1.5, 14.5), (4.0, 14.5)))
395 .min(segment(p, (20.0, 14.5), (22.5, 14.5))),
396 Icon::File => path(
398 p,
399 &[
400 (15.0, 2.0),
401 (6.0, 2.0),
402 (4.6, 2.6),
403 (4.0, 4.0),
404 (4.0, 20.0),
405 (4.6, 21.4),
406 (6.0, 22.0),
407 (18.0, 22.0),
408 (19.4, 21.4),
409 (20.0, 20.0),
410 (20.0, 7.0),
411 (15.0, 2.0),
412 ],
413 )
414 .min(path(
415 p,
416 &[
417 (14.0, 2.0),
418 (14.0, 6.0),
419 (14.6, 7.4),
420 (16.0, 8.0),
421 (20.0, 8.0),
422 ],
423 )),
424 Icon::Folder => path(
425 p,
426 &[
427 (20.0, 20.0),
428 (21.4, 19.4),
429 (22.0, 18.0),
430 (22.0, 8.0),
431 (21.4, 6.6),
432 (20.0, 6.0),
433 (12.1, 6.0),
434 (10.4, 5.1),
435 (9.6, 3.9),
436 (7.9, 3.0),
437 (4.0, 3.0),
438 (2.6, 3.6),
439 (2.0, 5.0),
440 (2.0, 18.0),
441 (2.6, 19.4),
442 (4.0, 20.0),
443 (20.0, 20.0),
444 ],
445 ),
446 Icon::FolderOpen => path(
447 p,
448 &[
449 (6.0, 14.0),
450 (7.5, 11.1),
451 (9.2, 10.0),
452 (20.0, 10.0),
453 (21.9, 12.5),
454 (20.4, 18.5),
455 (18.5, 20.0),
456 (4.0, 20.0),
457 (2.6, 19.4),
458 (2.0, 18.0),
459 (2.0, 5.0),
460 (2.6, 3.6),
461 (4.0, 3.0),
462 (7.9, 3.0),
463 (9.6, 3.9),
464 (10.4, 5.1),
465 (12.1, 6.0),
466 (18.0, 6.0),
467 (19.4, 6.6),
468 (20.0, 8.0),
469 (20.0, 10.0),
470 ],
471 ),
472 Icon::Layers => path(
474 p,
475 &[
476 (12.0, 2.5),
477 (21.5, 7.5),
478 (12.0, 12.5),
479 (2.5, 7.5),
480 (12.0, 2.5),
481 ],
482 )
483 .min(path(p, &[(2.5, 12.5), (12.0, 17.5), (21.5, 12.5)]))
484 .min(path(p, &[(2.5, 17.0), (12.0, 22.0), (21.5, 17.0)])),
485 Icon::Outline => segment(p, (21.0, 6.0), (8.0, 6.0))
487 .min(segment(p, (21.0, 12.0), (13.0, 12.0)))
488 .min(segment(p, (21.0, 18.0), (13.0, 18.0)))
489 .min(path(
490 p,
491 &[
492 (3.0, 6.0),
493 (3.0, 10.0),
494 (3.6, 11.4),
495 (5.0, 12.0),
496 (8.0, 12.0),
497 ],
498 ))
499 .min(path(
500 p,
501 &[
502 (3.0, 10.0),
503 (3.0, 16.0),
504 (3.6, 17.4),
505 (5.0, 18.0),
506 (8.0, 18.0),
507 ],
508 )),
509 Icon::ListBullet => (circle(p, (5.0, 6.5)) - 0.4)
510 .min(circle(p, (5.0, 12.0)) - 0.4)
511 .min(circle(p, (5.0, 17.5)) - 0.4)
512 .min(segment(p, (9.5, 6.5), (20.5, 6.5)))
513 .min(segment(p, (9.5, 12.0), (20.5, 12.0)))
514 .min(segment(p, (9.5, 17.5), (20.5, 17.5))),
515 Icon::ListNumber => path(p, &[(3.8, 5.2), (5.4, 4.0), (5.4, 9.5)])
516 .min(path(
517 p,
518 &[
519 (3.6, 15.0),
520 (5.0, 13.8),
521 (6.8, 14.8),
522 (3.6, 19.8),
523 (7.2, 19.8),
524 ],
525 ))
526 .min(segment(p, (10.5, 6.8), (20.5, 6.8)))
527 .min(segment(p, (10.5, 16.8), (20.5, 16.8))),
528 Icon::ListTask => rounded(p, (4.0, 4.0), (20.0, 20.0), 3.5)
529 .min(path(p, &[(8.0, 12.2), (11.0, 15.2), (16.2, 9.0)])),
530 Icon::Quote => segment(p, (4.5, 5.0), (4.5, 19.0))
531 .min(segment(p, (9.5, 7.0), (20.5, 7.0)))
532 .min(segment(p, (9.5, 12.0), (20.5, 12.0)))
533 .min(segment(p, (9.5, 17.0), (16.5, 17.0))),
534 Icon::Code => path(p, &[(8.5, 6.5), (3.0, 12.0), (8.5, 17.5)])
535 .min(path(p, &[(15.5, 6.5), (21.0, 12.0), (15.5, 17.5)])),
536 Icon::Link => rounded(p, (2.5, 8.0), (13.5, 16.0), 4.0).min(rounded(
537 p,
538 (10.5, 8.0),
539 (21.5, 16.0),
540 4.0,
541 )),
542 Icon::Table => rounded(p, (3.0, 4.5), (21.0, 19.5), 2.5)
543 .min(segment(p, (3.0, 9.5), (21.0, 9.5)))
544 .min(segment(p, (3.0, 14.5), (21.0, 14.5)))
545 .min(segment(p, (12.0, 4.5), (12.0, 19.5))),
546 Icon::Track => path(
548 p,
549 &[
550 (4.0, 16.5),
551 (15.5, 5.0),
552 (19.0, 8.5),
553 (7.5, 20.0),
554 (4.0, 20.0),
555 (4.0, 16.5),
556 ],
557 )
558 .min(path(p, &[(13.0, 20.5), (21.0, 20.5)])),
559 Icon::Diagram => rounded(p, (2.5, 3.5), (10.0, 9.5), 1.5)
560 .min(rounded(p, (14.0, 3.5), (21.5, 9.5), 1.5))
561 .min(rounded(p, (14.0, 14.5), (21.5, 20.5), 1.5))
562 .min(path(p, &[(10.0, 6.5), (14.0, 6.5)]))
563 .min(path(p, &[(6.2, 9.5), (6.2, 17.5), (14.0, 17.5)])),
564 Icon::Picture => rounded(p, (3.0, 4.5), (21.0, 19.5), 2.5)
565 .min(ring(p, (8.5, 9.8), 1.5))
566 .min(path(
567 p,
568 &[
569 (3.5, 18.0),
570 (9.5, 12.8),
571 (13.5, 16.2),
572 (16.2, 13.8),
573 (20.5, 17.5),
574 ],
575 )),
576 Icon::Sigma => path(
577 p,
578 &[
579 (18.0, 7.5),
580 (18.0, 4.5),
581 (5.5, 4.5),
582 (12.5, 12.0),
583 (5.5, 19.5),
584 (18.0, 19.5),
585 (18.0, 16.5),
586 ],
587 ),
588 Icon::Rule => segment(p, (3.0, 12.0), (21.0, 12.0))
589 .min(segment(p, (8.0, 6.5), (16.0, 6.5)))
590 .min(segment(p, (8.0, 17.5), (16.0, 17.5))),
591 Icon::Comment => rounded(p, (3.0, 4.0), (21.0, 16.5), 3.5)
592 .min(path(p, &[(8.0, 16.5), (8.0, 20.5), (12.5, 16.5)])),
593 Icon::Export => path(p, &[(12.0, 3.5), (12.0, 15.0)])
594 .min(path(p, &[(7.0, 10.5), (12.0, 15.5), (17.0, 10.5)]))
595 .min(segment(p, (4.0, 20.0), (20.0, 20.0))),
596 Icon::Play => path(p, &[(7.0, 4.5), (19.5, 12.0), (7.0, 19.5), (7.0, 4.5)]),
597 Icon::PlayAll => path(p, &[(3.0, 5.5), (12.0, 12.0), (3.0, 18.5), (3.0, 5.5)]).min(path(
598 p,
599 &[(12.0, 5.5), (21.0, 12.0), (12.0, 18.5), (12.0, 5.5)],
600 )),
601 Icon::Stop => rounded(p, (6.0, 6.0), (18.0, 18.0), 1.5),
602 Icon::Restart => {
603 let angle = (p.1 - 12.0).atan2(p.0 - 12.0);
605 let gap = angle > -1.1 && angle < 0.1;
606 let arc = if gap {
607 f32::MAX
608 } else {
609 ring(p, (12.0, 12.0), 7.5)
610 };
611 arc.min(path(p, &[(19.5, 4.0), (19.5, 10.0), (13.8, 10.0)]))
612 }
613 Icon::AddCell => rounded(p, (3.0, 6.0), (21.0, 18.0), 2.0)
614 .min(segment(p, (12.0, 9.0), (12.0, 15.0)))
615 .min(segment(p, (9.0, 12.0), (15.0, 12.0))),
616 Icon::AddText => segment(p, (3.0, 6.0), (21.0, 6.0))
617 .min(segment(p, (3.0, 11.0), (13.0, 11.0)))
618 .min(segment(p, (3.0, 16.0), (10.0, 16.0)))
619 .min(segment(p, (18.0, 13.0), (18.0, 21.0)))
620 .min(segment(p, (14.0, 17.0), (22.0, 17.0))),
621 Icon::Cite => path(p, &[(9.0, 4.5), (5.5, 4.5), (5.5, 19.5), (9.0, 19.5)])
622 .min(path(
623 p,
624 &[(15.0, 4.5), (18.5, 4.5), (18.5, 19.5), (15.0, 19.5)],
625 ))
626 .min(segment(p, (12.0, 9.0), (12.0, 15.0))),
627 Icon::More => (circle(p, (5.0, 12.0)) - 0.5)
628 .min(circle(p, (12.0, 12.0)) - 0.5)
629 .min(circle(p, (19.0, 12.0)) - 0.5),
630 Icon::ChevronRight => path(p, &[(9.5, 6.5), (15.0, 12.0), (9.5, 17.5)]),
631 Icon::ChevronLeft => path(p, &[(14.5, 6.5), (9.0, 12.0), (14.5, 17.5)]),
632 Icon::ChevronDown => path(p, &[(6.5, 9.5), (12.0, 15.0), (17.5, 9.5)]),
633 Icon::Close => {
634 segment(p, (6.5, 6.5), (17.5, 17.5)).min(segment(p, (17.5, 6.5), (6.5, 17.5)))
635 }
636 Icon::Replace => replace(p),
637 Icon::ArrowUp => path(p, &[(5.0, 12.0), (12.0, 5.0), (19.0, 12.0)]).min(segment(
638 p,
639 (12.0, 5.0),
640 (12.0, 19.0),
641 )),
642 Icon::ArrowDown => path(p, &[(19.0, 12.0), (12.0, 19.0), (5.0, 12.0)]).min(segment(
643 p,
644 (12.0, 5.0),
645 (12.0, 19.0),
646 )),
647 Icon::ReplaceAll => replace(p)
648 .min(path(
649 p,
650 &[
651 (14.0, 14.0),
652 (15.4, 14.6),
653 (16.0, 16.0),
654 (16.0, 20.0),
655 (15.4, 21.4),
656 (14.0, 22.0),
657 ],
658 ))
659 .min(path(
660 p,
661 &[
662 (20.0, 14.0),
663 (21.4, 14.6),
664 (22.0, 16.0),
665 (22.0, 20.0),
666 (21.4, 21.4),
667 (20.0, 22.0),
668 ],
669 )),
670 Icon::Check => path(p, &[(4.5, 12.5), (9.5, 17.5), (19.5, 6.5)]),
671 Icon::HidePane => rounded(p, (3.0, 3.0), (21.0, 21.0), 2.0)
673 .min(segment(p, (15.0, 3.0), (15.0, 21.0)))
674 .min(solid(p, (15.0, 3.0), (21.0, 21.0), 2.0)),
675 Icon::HidePanel => rounded(p, (3.0, 3.0), (21.0, 21.0), 2.0)
676 .min(segment(p, (3.0, 15.0), (21.0, 15.0)))
677 .min(solid(p, (3.0, 15.0), (21.0, 21.0), 2.0)),
678 Icon::ShowPane => {
679 rounded(p, (3.0, 3.0), (21.0, 21.0), 2.0).min(segment(p, (15.0, 3.0), (15.0, 21.0)))
680 }
681 Icon::HideSidebar => rounded(p, (3.0, 3.0), (21.0, 21.0), 2.0)
683 .min(segment(p, (9.0, 3.0), (9.0, 21.0)))
684 .min(solid(p, (3.0, 3.0), (9.0, 21.0), 2.0)),
685 Icon::ShowSidebar => {
686 rounded(p, (3.0, 3.0), (21.0, 21.0), 2.0).min(segment(p, (9.0, 3.0), (9.0, 21.0)))
687 }
688 Icon::Maximize => path(p, &[(15.0, 3.0), (21.0, 3.0), (21.0, 9.0)])
689 .min(path(p, &[(9.0, 21.0), (3.0, 21.0), (3.0, 15.0)]))
690 .min(segment(p, (21.0, 3.0), (14.0, 10.0)))
691 .min(segment(p, (3.0, 21.0), (10.0, 14.0))),
692 Icon::Minimize => path(p, &[(4.0, 14.0), (10.0, 14.0), (10.0, 20.0)])
693 .min(path(p, &[(20.0, 10.0), (14.0, 10.0), (14.0, 4.0)]))
694 .min(segment(p, (14.0, 10.0), (21.0, 3.0)))
695 .min(segment(p, (3.0, 21.0), (10.0, 14.0))),
696 Icon::SymbolFunction => path(
698 p,
699 &[
700 (12.0, 2.5),
701 (20.5, 7.2),
702 (20.5, 16.8),
703 (12.0, 21.5),
704 (3.5, 16.8),
705 (3.5, 7.2),
706 (12.0, 2.5),
707 ],
708 )
709 .min(path(p, &[(3.8, 7.3), (12.0, 12.0), (20.2, 7.3)]))
710 .min(segment(p, (12.0, 12.0), (12.0, 21.5))),
711 Icon::SymbolType => path(
712 p,
713 &[
714 (8.5, 3.0),
715 (7.0, 3.0),
716 (5.5, 4.5),
717 (5.5, 10.0),
718 (3.5, 12.0),
719 (5.5, 14.0),
720 (5.5, 19.5),
721 (7.0, 21.0),
722 (8.5, 21.0),
723 ],
724 )
725 .min(path(
726 p,
727 &[
728 (15.5, 3.0),
729 (17.0, 3.0),
730 (18.5, 4.5),
731 (18.5, 10.0),
732 (20.5, 12.0),
733 (18.5, 14.0),
734 (18.5, 19.5),
735 (17.0, 21.0),
736 (15.5, 21.0),
737 ],
738 )),
739 Icon::SymbolField => {
740 rounded(p, (3.0, 7.5), (21.0, 16.5), 2.5).min(segment(p, (7.0, 12.0), (12.0, 12.0)))
741 }
742 Icon::SymbolValue => {
743 segment(p, (4.5, 9.0), (19.5, 9.0)).min(segment(p, (4.5, 15.0), (19.5, 15.0)))
744 }
745 Icon::Terminal => path(p, &[(3.5, 6.0), (10.0, 12.0), (3.5, 18.0)]).min(segment(
746 p,
747 (12.5, 18.0),
748 (20.5, 18.0),
749 )),
750 Icon::Panel => {
751 rounded(p, (3.0, 3.0), (21.0, 21.0), 4.0).min(segment(p, (3.0, 15.0), (21.0, 15.0)))
752 }
753 Icon::Diff => rounded(p, (3.0, 3.0), (21.0, 21.0), 4.0)
754 .min(segment(p, (12.0, 6.5), (12.0, 12.5)))
755 .min(segment(p, (9.0, 9.5), (15.0, 9.5)))
756 .min(segment(p, (9.0, 16.5), (15.0, 16.5))),
757 Icon::Bell => {
759 let dome = if p.1 <= 9.0 {
760 ring(p, (12.0, 9.0), 6.0)
761 } else {
762 f32::MAX
763 };
764 dome.min(path(
765 p,
766 &[(6.0, 9.0), (6.0, 12.5), (5.2, 15.4), (3.2, 17.5)],
767 ))
768 .min(path(
769 p,
770 &[(18.0, 9.0), (18.0, 12.5), (18.8, 15.4), (20.8, 17.5)],
771 ))
772 .min(segment(p, (3.2, 17.5), (20.8, 17.5)))
773 .min(path(p, &[(10.2, 20.8), (12.0, 21.8), (13.8, 20.8)]))
774 }
775 Icon::Question => ring(p, (12.0, 12.0), 9.5)
776 .min(path(
777 p,
778 &[
779 (9.3, 9.2),
780 (10.1, 7.6),
781 (12.0, 7.0),
782 (14.0, 7.7),
783 (14.8, 9.4),
784 (14.0, 11.0),
785 (12.0, 12.2),
786 (12.0, 13.6),
787 ],
788 ))
789 .min(circle(p, (12.0, 17.0)) - 0.4),
790 Icon::CircleCheck => {
791 ring(p, (12.0, 12.0), 9.5).min(path(p, &[(8.0, 12.3), (10.8, 15.0), (16.0, 9.5)]))
792 }
793 Icon::FolderFilled => {
795 solid(p, (3.0, 4.2), (10.5, 9.0), 1.6).min(solid(p, (3.0, 7.2), (21.0, 19.4), 2.0))
796 }
797 Icon::FileRust => {
799 let letter = segment(p, (9.0, 7.3), (9.0, 16.7))
800 .min(path(
801 p,
802 &[
803 (9.0, 7.3),
804 (12.6, 7.3),
805 (14.3, 8.0),
806 (15.0, 9.6),
807 (14.3, 11.2),
808 (12.6, 11.9),
809 (9.0, 11.9),
810 ],
811 ))
812 .min(segment(p, (12.4, 11.9), (15.3, 16.7)));
813 cut(disc(p, (12.0, 12.0), 9.2), letter, 0.95)
814 }
815 Icon::FilePython => {
817 let letter = segment(p, (9.4, 7.3), (9.4, 16.7)).min(path(
818 p,
819 &[
820 (9.4, 7.3),
821 (12.9, 7.3),
822 (14.7, 8.1),
823 (15.4, 9.9),
824 (14.7, 11.7),
825 (12.9, 12.5),
826 (9.4, 12.5),
827 ],
828 ));
829 cut(disc(p, (12.0, 12.0), 9.2), letter, 0.95)
830 }
831 Icon::FileMarkdown => path(
833 p,
834 &[
835 (2.5, 17.0),
836 (2.5, 7.0),
837 (7.0, 12.5),
838 (11.5, 7.0),
839 (11.5, 17.0),
840 ],
841 )
842 .min(segment(p, (18.0, 7.5), (18.0, 16.5)))
843 .min(path(p, &[(14.5, 13.0), (18.0, 16.5), (21.5, 13.0)])),
844 Icon::FileGit => {
846 let across = (p.0 - 12.0).abs() + (p.1 - 12.0).abs();
847 let diamond = ((across - 9.6) * std::f32::consts::FRAC_1_SQRT_2).max(0.0);
848 cut(diamond, circle(p, (12.0, 12.0)), 2.7)
849 }
850 Icon::FileJson => {
852 let brace = |side: f32| {
853 let x = |from: f32| 12.0 + side * (from - 12.0);
854 path(
855 p,
856 &[
857 (x(9.0), 4.0),
858 (x(7.2), 4.5),
859 (x(6.4), 6.2),
860 (x(6.4), 9.6),
861 (x(5.6), 11.3),
862 (x(3.8), 12.0),
863 (x(5.6), 12.7),
864 (x(6.4), 14.4),
865 (x(6.4), 17.8),
866 (x(7.2), 19.5),
867 (x(9.0), 20.0),
868 ],
869 )
870 };
871 brace(1.0).min(brace(-1.0))
872 }
873 Icon::FileConfig => path(p, &[(8.0, 4.0), (5.0, 4.0), (5.0, 20.0), (8.0, 20.0)])
875 .min(path(
876 p,
877 &[(16.0, 4.0), (19.0, 4.0), (19.0, 20.0), (16.0, 20.0)],
878 ))
879 .min(segment(p, (9.6, 9.8), (14.4, 9.8)))
880 .min(segment(p, (9.6, 14.2), (14.4, 14.2))),
881 Icon::FileCode => path(p, &[(8.0, 7.5), (3.5, 12.0), (8.0, 16.5)])
883 .min(path(p, &[(16.0, 7.5), (20.5, 12.0), (16.0, 16.5)]))
884 .min(segment(p, (13.6, 5.5), (10.4, 18.5))),
885 Icon::Power => {
887 let open = if p.1 >= 6.4 {
888 ring(p, (12.0, 13.0), 9.0)
889 } else {
890 f32::MAX
891 };
892 open.min(segment(p, (12.0, 2.0), (12.0, 12.0)))
893 }
894 Icon::AgentClaude => segment(p, (12.0, 3.5), (12.0, 20.5))
896 .min(segment(p, (3.5, 12.0), (20.5, 12.0)))
897 .min(segment(p, (6.0, 6.0), (18.0, 18.0)))
898 .min(segment(p, (18.0, 6.0), (6.0, 18.0))),
899 Icon::AgentCodex => path(
901 p,
902 &[
903 (12.0, 2.5),
904 (20.3, 7.25),
905 (20.3, 16.75),
906 (12.0, 21.5),
907 (3.7, 16.75),
908 (3.7, 7.25),
909 (12.0, 2.5),
910 ],
911 )
912 .min(path(p, &[(9.2, 9.6), (11.8, 12.0), (9.2, 14.4)]))
913 .min(segment(p, (13.4, 14.4), (15.4, 14.4))),
914 Icon::AgentGemini => {
916 let (x, y) = (((p.0 - 12.0) / 10.0).abs(), ((p.1 - 12.0) / 10.0).abs());
917 if x.powf(0.75) + y.powf(0.75) <= 1.0 {
918 0.0
919 } else {
920 f32::MAX
921 }
922 }
923 Icon::Program => solid(p, (5.0, 5.0), (19.0, 19.0), 3.5),
925 Icon::AgentOpenCode => cut(
927 solid(p, (5.0, 5.0), (19.0, 19.0), 3.5),
928 ring(p, (12.0, 12.0), 3.6),
929 1.15,
930 ),
931 Icon::AgentCopilot => {
933 let (dx, dy) = (p.0 - 12.0, p.1 - 12.0);
934 let open = dx > 0.0 && dy.abs() < dx * 0.9;
935 let letter = if open {
936 f32::MAX
937 } else {
938 ring(p, (12.0, 12.0), 3.6)
939 };
940 cut(solid(p, (5.0, 5.0), (19.0, 19.0), 3.5), letter, 1.15)
941 }
942 Icon::AgentCursor => {
945 let arrow = [
946 (8.6, 7.0),
947 (8.6, 16.6),
948 (11.0, 14.4),
949 (12.8, 18.0),
950 (14.6, 17.2),
951 (12.8, 13.6),
952 (16.0, 13.4),
953 ];
954 let inside =
955 arrow
956 .iter()
957 .zip(arrow.iter().cycle().skip(1))
958 .fold(false, |inside, (a, b)| {
959 let crosses = (a.1 > p.1) != (b.1 > p.1)
960 && p.0 < (b.0 - a.0) * (p.1 - a.1) / (b.1 - a.1) + a.0;
961 inside != crosses
962 });
963 if inside {
964 f32::MAX
965 } else {
966 solid(p, (5.0, 5.0), (19.0, 19.0), 3.5)
967 }
968 }
969 Icon::AgentKiro => {
971 let letter = segment(p, (9.4, 8.2), (9.4, 15.8))
972 .min(segment(p, (14.6, 8.2), (9.7, 12.3)))
973 .min(segment(p, (11.4, 10.9), (14.6, 15.8)));
974 cut(solid(p, (5.0, 5.0), (19.0, 19.0), 3.5), letter, 1.15)
975 }
976 Icon::Log => segment(p, (4.0, 5.5), (20.0, 5.5))
977 .min(segment(p, (4.0, 10.0), (15.0, 10.0)))
978 .min(segment(p, (4.0, 14.5), (18.0, 14.5)))
979 .min(segment(p, (4.0, 19.0), (11.0, 19.0))),
980 Icon::Smile => ring(p, (12.0, 12.0), 9.5)
981 .min(circle(p, (9.0, 9.6)) - 0.35)
982 .min(circle(p, (15.0, 9.6)) - 0.35)
983 .min(path(
984 p,
985 &[
986 (8.0, 14.0),
987 (9.6, 15.5),
988 (12.0, 16.1),
989 (14.4, 15.5),
990 (16.0, 14.0),
991 ],
992 )),
993 Icon::CircleX => ring(p, (12.0, 12.0), 9.5)
994 .min(segment(p, (8.8, 8.8), (15.2, 15.2)))
995 .min(segment(p, (15.2, 8.8), (8.8, 15.2))),
996 Icon::Globe => {
997 let (x, y) = ((p.0 - 12.0) / 4.5, (p.1 - 12.0) / 9.5);
998 let meridian = ((x * x + y * y).sqrt() - 1.0).abs() * 4.5;
999 ring(p, (12.0, 12.0), 9.5)
1000 .min(meridian)
1001 .min(segment(p, (2.5, 12.0), (21.5, 12.0)))
1002 }
1003 Icon::Cloud => {
1006 let big = circle(p, (9.0, 12.0)) - 7.0;
1007 let small = circle(p, (17.5, 14.5)) - 4.5;
1008 let (cx, cy, hx, hy) = (13.25, 14.5, 4.25, 4.5);
1009 let (qx, qy) = ((p.0 - cx).abs() - hx, (p.1 - cy).abs() - hy);
1010 let outside = (qx.max(0.0).powi(2) + qy.max(0.0).powi(2)).sqrt();
1011 let foot = outside + qx.max(qy).min(0.0);
1012 big.min(small).min(foot).abs()
1013 }
1014 Icon::Send => path(
1016 p,
1017 &[
1018 (22.0, 2.0),
1019 (15.0, 22.0),
1020 (11.0, 13.0),
1021 (2.0, 9.0),
1022 (22.0, 2.0),
1023 ],
1024 )
1025 .min(segment(p, (22.0, 2.0), (11.0, 13.0))),
1026 Icon::Copy => rounded(p, (8.0, 8.0), (22.0, 22.0), 2.0).min(path(
1028 p,
1029 &[
1030 (4.0, 16.0),
1031 (2.9, 15.6),
1032 (2.0, 14.0),
1033 (2.0, 4.0),
1034 (2.6, 2.6),
1035 (4.0, 2.0),
1036 (14.0, 2.0),
1037 (15.4, 2.6),
1038 (16.0, 4.0),
1039 ],
1040 )),
1041 };
1042 distance < half_stroke(icon)
1043}
1044
1045#[cfg(test)]
1046mod tests {
1047 use super::*;
1048
1049 #[test]
1050 fn pieces_survive_the_grid() {
1051 for icon in [
1052 Icon::Files,
1053 Icon::Search,
1054 Icon::Git,
1055 Icon::Settings,
1056 Icon::Layers,
1057 ] {
1058 let piece = Piece {
1059 icon,
1060 width: 3,
1061 height: 2,
1062 column: 2,
1063 row: 1,
1064 };
1065 let text = piece.symbol().to_string();
1066 assert_eq!(Piece::decode(&text), Some(piece));
1067 }
1068 assert_eq!(Piece::decode("a"), None);
1069 }
1070
1071 #[test]
1072 fn every_icon_has_ink() {
1073 for icon in [
1074 Icon::Files,
1075 Icon::Search,
1076 Icon::Git,
1077 Icon::Settings,
1078 Icon::Agents,
1079 Icon::Layers,
1080 Icon::Folder,
1081 Icon::File,
1082 Icon::Maximize,
1083 Icon::Minimize,
1084 Icon::Panel,
1085 Icon::SymbolFunction,
1086 Icon::SymbolType,
1087 Icon::SymbolField,
1088 Icon::SymbolValue,
1089 Icon::Bell,
1090 Icon::Question,
1091 Icon::CircleCheck,
1092 Icon::CircleX,
1093 Icon::HidePane,
1094 Icon::HidePanel,
1095 Icon::ShowPane,
1096 Icon::HideSidebar,
1097 Icon::ShowSidebar,
1098 Icon::Smile,
1099 Icon::Power,
1100 Icon::FolderFilled,
1101 Icon::FileRust,
1102 Icon::FilePython,
1103 Icon::FileMarkdown,
1104 Icon::FileGit,
1105 Icon::FileJson,
1106 Icon::FileConfig,
1107 Icon::FileCode,
1108 Icon::Log,
1109 Icon::AgentClaude,
1110 Icon::AgentCodex,
1111 Icon::AgentGemini,
1112 Icon::Program,
1113 Icon::AgentOpenCode,
1114 Icon::AgentCopilot,
1115 Icon::AgentCursor,
1116 Icon::AgentKiro,
1117 Icon::Cloud,
1118 Icon::Send,
1119 Icon::Copy,
1120 ] {
1121 let dots = (0..50)
1122 .flat_map(|y| (0..50).map(move |x| (x, y)))
1123 .filter(|(x, y)| inked(icon, *x as f32 / 50.0, *y as f32 / 50.0))
1124 .count();
1125 assert!(dots > 150, "{icon:?} has {dots}");
1126 }
1127 }
1128}