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