unicode_rs/unicode/
shapes.rs

1//! Shape Unicode characters
2//! Geometric shapes for icons and visual elements
3
4use super::{UnicodeProvider, UnicodeTheme};
5
6/// Basic geometric shapes
7#[derive(Debug, Clone, Copy)]
8pub enum Shape {
9    /// Circle
10    Circle,
11    /// Square
12    Square,
13    /// Triangle
14    Triangle,
15    /// Diamond
16    Diamond,
17    /// Star
18    Star,
19    /// Heart
20    Heart,
21    /// Plus
22    Plus,
23    /// Cross
24    Cross,
25    /// Dot
26    Dot,
27    /// Bullet
28    Bullet,
29}
30
31impl UnicodeProvider for Shape {
32    fn get_char(&self, theme: UnicodeTheme) -> char {
33        match (self, theme) {
34            (Shape::Circle, UnicodeTheme::Minimal) => 'o',
35            (Shape::Circle, UnicodeTheme::Basic) => '○',
36            (Shape::Circle, UnicodeTheme::Rich) => '●',
37            (Shape::Circle, UnicodeTheme::Fancy) => '🔴',
38
39            (Shape::Square, UnicodeTheme::Minimal) => '#',
40            (Shape::Square, UnicodeTheme::Basic) => '□',
41            (Shape::Square, UnicodeTheme::Rich) => '■',
42            (Shape::Square, UnicodeTheme::Fancy) => '🟦',
43
44            (Shape::Triangle, UnicodeTheme::Minimal) => '^',
45            (Shape::Triangle, UnicodeTheme::Basic) => '△',
46            (Shape::Triangle, UnicodeTheme::Rich) => '▲',
47            (Shape::Triangle, UnicodeTheme::Fancy) => '🔺',
48
49            (Shape::Diamond, UnicodeTheme::Minimal) => '<',
50            (Shape::Diamond, UnicodeTheme::Basic) => '◇',
51            (Shape::Diamond, UnicodeTheme::Rich) => '◆',
52            (Shape::Diamond, UnicodeTheme::Fancy) => '💎',
53
54            (Shape::Star, UnicodeTheme::Minimal) => '*',
55            (Shape::Star, UnicodeTheme::Basic) => '☆',
56            (Shape::Star, UnicodeTheme::Rich) => '★',
57            (Shape::Star, UnicodeTheme::Fancy) => '⭐',
58
59            (Shape::Heart, UnicodeTheme::Minimal) => '<',
60            (Shape::Heart, UnicodeTheme::Basic) => '♡',
61            (Shape::Heart, UnicodeTheme::Rich) => '♥',
62            (Shape::Heart, UnicodeTheme::Fancy) => '❤',
63
64            (Shape::Plus, UnicodeTheme::Minimal) => '+',
65            (Shape::Plus, UnicodeTheme::Basic) => '+',
66            (Shape::Plus, UnicodeTheme::Rich) => '✚',
67            (Shape::Plus, UnicodeTheme::Fancy) => '➕',
68
69            (Shape::Cross, UnicodeTheme::Minimal) => 'x',
70            (Shape::Cross, UnicodeTheme::Basic) => '✕',
71            (Shape::Cross, UnicodeTheme::Rich) => '✖',
72            (Shape::Cross, UnicodeTheme::Fancy) => '❌',
73
74            (Shape::Dot, UnicodeTheme::Minimal) => '.',
75            (Shape::Dot, UnicodeTheme::Basic) => '•',
76            (Shape::Dot, UnicodeTheme::Rich) => '●',
77            (Shape::Dot, UnicodeTheme::Fancy) => '🔴',
78
79            (Shape::Bullet, UnicodeTheme::Minimal) => '*',
80            (Shape::Bullet, UnicodeTheme::Basic) => '•',
81            (Shape::Bullet, UnicodeTheme::Rich) => '●',
82            (Shape::Bullet, UnicodeTheme::Fancy) => '🔸',
83        }
84    }
85}
86
87/// Convenience constants for shapes
88pub mod chars {
89    use super::*;
90
91    pub const CIRCLE: Shape = Shape::Circle;
92    pub const SQUARE: Shape = Shape::Square;
93    pub const TRIANGLE: Shape = Shape::Triangle;
94    pub const DIAMOND: Shape = Shape::Diamond;
95    pub const STAR: Shape = Shape::Star;
96    pub const HEART: Shape = Shape::Heart;
97    pub const PLUS: Shape = Shape::Plus;
98    pub const CROSS: Shape = Shape::Cross;
99    pub const DOT: Shape = Shape::Dot;
100    pub const BULLET: Shape = Shape::Bullet;
101}