retroglyph_core/symbols/bar.rs
1/// Filled 1/8 from the bottom.
2pub const ONE_EIGHTH: char = '▁';
3/// Filled 1/4 from the bottom.
4pub const ONE_QUARTER: char = '▂';
5/// Filled 3/8 from the bottom.
6pub const THREE_EIGHTHS: char = '▃';
7/// Filled 1/2 from the bottom.
8pub const HALF: char = '▄';
9/// Filled 5/8 from the bottom.
10pub const FIVE_EIGHTHS: char = '▅';
11/// Filled 3/4 from the bottom.
12pub const THREE_QUARTERS: char = '▆';
13/// Filled 7/8 from the bottom.
14pub const SEVEN_EIGHTHS: char = '▇';
15/// A fully filled cell.
16pub const FULL: char = '█';
17
18/// The nine bar levels from empty to full, indexed `0..=8`: a blank cell, then
19/// [`ONE_EIGHTH`] through [`FULL`] in order.
20///
21/// Indexing this directly by `round(fraction * 8.0) as usize` turns a `0.0..=1.0` magnitude
22/// into the right glyph for one bar column. Six of these eight are outside CP437 (only ' ' and
23/// [`FULL`] are covered); a pixel backend resolving glyphs through a CP437 table draws the other
24/// six as its fallback solid block, which erases the ramp's granularity. For a bar that has to
25/// stay legible on a CP437-only tileset/sprite path, use [`SHADE_LEVELS`] instead.
26pub const NINE_LEVELS: [char; 9] = [
27 ' ',
28 ONE_EIGHTH,
29 ONE_QUARTER,
30 THREE_EIGHTHS,
31 HALF,
32 FIVE_EIGHTHS,
33 THREE_QUARTERS,
34 SEVEN_EIGHTHS,
35 FULL,
36];
37
38/// A light shade: 25% coverage, CP437 code point 176 (`U+2591`).
39pub const LIGHT_SHADE: char = '░';
40/// A medium shade: 50% coverage, CP437 code point 177 (`U+2592`).
41pub const MEDIUM_SHADE: char = '▒';
42/// A dark shade: 75% coverage, CP437 code point 178 (`U+2593`).
43pub const DARK_SHADE: char = '▓';
44
45/// The five bar levels from empty to full, indexed `0..=4`: a blank cell, then [`LIGHT_SHADE`],
46/// [`MEDIUM_SHADE`], [`DARK_SHADE`], and [`FULL`] in order.
47///
48/// Every glyph here is in CP437 (verified against `CP437_TO_UNICODE` in `retroglyph-window`),
49/// unlike [`NINE_LEVELS`]: a caller drawing through a pixel backend that resolves glyphs via a
50/// CP437 table, or a tileset/sprite backend that can't tint an arbitrary glyph by `Style::fg`,
51/// can use this ramp and still get five distinguishable fill levels instead of collapsing to a
52/// single fallback block. Index it by `round(fraction * 4.0) as usize` for one bar column.
53pub const SHADE_LEVELS: [char; 5] = [' ', LIGHT_SHADE, MEDIUM_SHADE, DARK_SHADE, FULL];