animaterm

Enum Color

source
pub enum Color {
    Basic(ColorName),
    EightBit(u8),
    Grayscale(u8),
    Truecolor(u8, u8, u8),
}
Expand description

Definition of all available color types.

Variants§

§

Basic(ColorName)

§

EightBit(u8)

§

Grayscale(u8)

§

Truecolor(u8, u8, u8)

Implementations§

source§

impl Color

source

pub fn new(value: ColorName) -> Color

Create a new color by name.

Examples found in repository?
examples/example_5.rs (line 494)
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
fn build_progress_bar(length: usize) -> Graphic {
    let glf = Glyph::new(
        '\u{2588}',
        animaterm::Color::new(ColorName::Red),
        animaterm::Color::new(ColorName::White),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    progress_bar(
        length,
        Glyph::transparent(),
        glf,
        Some(vec![
            Glyph::new(
                '\u{258F}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258E}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258D}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258C}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258B}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258A}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            // Glyph::new(
            //     '\u{2589}',
            //     animaterm::Color::new_truecolor(128, 0, 0),
            //     animaterm::Color::cyan(),
            //     false,
            //     true,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            // ),
        ]),
    )
}
source

pub fn black() -> Color

Get a black color.

Examples found in repository?
examples/example_4.rs (line 22)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
fn main() {
    let mut mgr = Manager::new(true, None, None, None, None, None);

    let screen_size = mgr.screen_size();
    let title = "Navigation help".to_string();
    let text =
        "Press 0 to select display 0\n Press 1 to select display 1\n Press q or Shift+q to quit\n"
            .to_string();
    let keep_existing = true;
    let first_display_id = 0;
    let mbox = message_box(Some(title.clone()), text.clone(), Glyph::default(), 32, 5);
    let mbid = mgr
        .add_graphic(mbox, 1, (1, screen_size.1 as isize - 6))
        .unwrap();
    mgr.set_graphic(mbid, 0, true);
    let empty = Glyph::new(
        ' ',
        Color::green(),
        Color::black(),
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    let full = Glyph::new(
        'X',
        Color::green(),
        Color::black(),
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    let gid = mgr
        .add_graphic(progress_bar(screen_size.0, empty, full, None), 0, (1, 1))
        .unwrap();
    mgr.start_animation(gid, 0);
    let second_display_id = mgr.new_display(keep_existing);
    // let result = mgr.read_result();
    // if let Ok(AnimOk::DisplayStored(disp_id)) = result {
    //     first_display_id = disp_id;
    // }
    let mbox = message_box(Some(title), text, Glyph::default(), 32, 5);
    let mbid = mgr
        .add_graphic(mbox, 1, (1, screen_size.1 as isize - 6))
        .unwrap();
    mgr.set_graphic(mbid, 0, true);

    let mut keep_running = true;
    while keep_running {
        if let Some(key) = mgr.read_key() {
            match key {
                Key::Zero => mgr.restore_display(first_display_id, true),
                Key::One => mgr.restore_display(second_display_id, true),
                Key::Two => mgr.restore_display(2, true),
                Key::Q | Key::ShiftQ => {
                    keep_running = false;
                }
                _ => continue,
            }
        }
    }

    mgr.terminate();
}
source

pub fn red() -> Color

Get a red color.

Examples found in repository?
examples/example_5.rs (line 514)
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
fn build_progress_bar(length: usize) -> Graphic {
    let glf = Glyph::new(
        '\u{2588}',
        animaterm::Color::new(ColorName::Red),
        animaterm::Color::new(ColorName::White),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    progress_bar(
        length,
        Glyph::transparent(),
        glf,
        Some(vec![
            Glyph::new(
                '\u{258F}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258E}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258D}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258C}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258B}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258A}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            // Glyph::new(
            //     '\u{2589}',
            //     animaterm::Color::new_truecolor(128, 0, 0),
            //     animaterm::Color::cyan(),
            //     false,
            //     true,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            // ),
        ]),
    )
}
source

pub fn orange() -> Color

Get a orange color.

source

pub fn indigo() -> Color

Get a indigo color.

source

pub fn violet() -> Color

Get a violet color.

source

pub fn green() -> Color

Get a green color.

Examples found in repository?
examples/example_4.rs (line 21)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
fn main() {
    let mut mgr = Manager::new(true, None, None, None, None, None);

    let screen_size = mgr.screen_size();
    let title = "Navigation help".to_string();
    let text =
        "Press 0 to select display 0\n Press 1 to select display 1\n Press q or Shift+q to quit\n"
            .to_string();
    let keep_existing = true;
    let first_display_id = 0;
    let mbox = message_box(Some(title.clone()), text.clone(), Glyph::default(), 32, 5);
    let mbid = mgr
        .add_graphic(mbox, 1, (1, screen_size.1 as isize - 6))
        .unwrap();
    mgr.set_graphic(mbid, 0, true);
    let empty = Glyph::new(
        ' ',
        Color::green(),
        Color::black(),
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    let full = Glyph::new(
        'X',
        Color::green(),
        Color::black(),
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    let gid = mgr
        .add_graphic(progress_bar(screen_size.0, empty, full, None), 0, (1, 1))
        .unwrap();
    mgr.start_animation(gid, 0);
    let second_display_id = mgr.new_display(keep_existing);
    // let result = mgr.read_result();
    // if let Ok(AnimOk::DisplayStored(disp_id)) = result {
    //     first_display_id = disp_id;
    // }
    let mbox = message_box(Some(title), text, Glyph::default(), 32, 5);
    let mbid = mgr
        .add_graphic(mbox, 1, (1, screen_size.1 as isize - 6))
        .unwrap();
    mgr.set_graphic(mbid, 0, true);

    let mut keep_running = true;
    while keep_running {
        if let Some(key) = mgr.read_key() {
            match key {
                Key::Zero => mgr.restore_display(first_display_id, true),
                Key::One => mgr.restore_display(second_display_id, true),
                Key::Two => mgr.restore_display(2, true),
                Key::Q | Key::ShiftQ => {
                    keep_running = false;
                }
                _ => continue,
            }
        }
    }

    mgr.terminate();
}
More examples
Hide additional examples
examples/example_5.rs (line 20)
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
fn main() {
    let args = parse_arguments();
    let cols = args.cols;
    let rows = args.rows;
    verify_cols_and_rows(cols, rows);
    let mut g = Glyph::default();
    g.set_background(Color::green());
    g.set_char(char::from_u32(9626).unwrap());
    g.set_bright(true);

    let mut mgr = Manager::new(true, cols, rows, Some(g), None, None);
    let (cols, rows) = mgr.screen_size();

    let title = "Navigation help".to_string();
    let text = "CtrlPgUp,CtrlPgDn, -------------------------------------
AltPgUp,AltPgDn, ---------------------------------------
PgUp,PgDn, ---------------------------------------------
U,D, ---------------------------------------------------
CtrlU,CtrlD -------------------------------------------- 
AltU,AltD ----------------------------------------------
AltUp | AltK -------------------------------------------
CtrlUp | CtrlK -----------------------------------------
Up | K -------------------------------------------------
AltDown | AltJ -----------------------------------------
CtrlDown -----------------------------------------------
Down | J -----------------------------------------------
AltLeft | AltH -----------------------------------------
CtrlLeft | Backspace -----------------------------------
Left | H -----------------------------------------------
AltRight | AltL ----------------------------------------
CtrlRight | CtrlL --------------------------------------
Right | L - all above move graphics around the screen --
----------- and up/down layers. ------------------------
Tab - show a message box -------------------------------
Enter - type some text and hit Enter again -------------
        "
    .to_string();
    let mbox = message_box(Some(title), text, Glyph::default(), 60, 23);
    let mbid = mgr.add_graphic(mbox, 4, (1, 10)).unwrap();
    mgr.set_graphic(mbid, 0, true);
    let (gr, pid) = build_graphic(130, 10);
    let gr_layer = 1;
    let gid;
    let result = mgr.add_graphic(gr, gr_layer, (3, 15));
    if let Some(id) = result {
        gid = id;
    } else {
        eprintln!("Did not receive first graphic id");
        exit(2);
    }
    mgr.set_graphic(gid, pid, true);

    let pbid;
    let mut pb_layer = 3;
    let result = mgr.add_graphic(
        build_progress_bar(cols - 4),
        pb_layer,
        (2, (rows - 2) as isize),
    );
    if let Some(id) = result {
        pbid = id;
    } else {
        eprintln!("Did not receive progress bar graphic id");
        exit(2);
    }
    mgr.set_graphic(pbid, 0, true);
    mgr.start_animation(pbid, 0);
    let mut mbox_created = false;
    let mut mbox_id = 100;
    let mut mbox_layer = 2;
    if Path::new("index.txg").exists() {
        if let Some(id) =
            mgr.add_graphic(Graphic::from_file("index.txg").unwrap(), mbox_layer, (1, 0))
        {
            mgr.move_graphic(id, 2, (-1, 0));
            mbox_id = id;
            mbox_layer = 4;
        }
    } else {
        eprintln!("\x1b[97;41;5mERR\x1b[m Unable to load index.txg. Run this example from within top examples directory!");
        eprintln!("\x1b[97;41;5mERR\x1b[m Or copy *.txf and index.txg from there to current dir.");
        exit(1);
    }

    loop {
        if let Some(key) = mgr.read_key() {
            match key {
                Key::AltUnicode(uni) => match (uni[2], uni[4]) {
                    (53, 53) => {
                        //CtrlPgUp
                        mgr.move_graphic(1, 4, (0, 0));
                    }
                    (54, 53) => {
                        //CtrlPgDn
                        mgr.move_graphic(1, 1, (0, 0));
                    }
                    (53, 51) => {
                        //AltPgUp
                        mgr.move_graphic(2, 5, (0, 0));
                    }
                    (54, 51) => {
                        //AltPgDn
                        mgr.move_graphic(2, 2, (0, 0));
                    }
                    _ => {}
                },
                Key::PgUp | Key::U => {
                    mgr.move_graphic(0, 3, (0, 0));
                }
                Key::PgDn | Key::D => {
                    mgr.move_graphic(0, 0, (0, 0));
                }
                Key::CtrlU => {
                    pb_layer = 4;
                    mgr.move_graphic(pbid, pb_layer, (0, 0));
                }
                Key::CtrlD => {
                    mgr.move_graphic(pbid, pb_layer, (0, 0));
                }
                Key::AltU => {
                    mbox_layer = 5;
                    mgr.move_graphic(mbox_id, mbox_layer, (0, 0));
                }
                Key::AltD => {
                    mbox_layer = 2;
                    mgr.move_graphic(mbox_id, mbox_layer, (0, 0));
                }
                Key::AltUp | Key::AltK => {
                    mgr.move_graphic(mbox_id, mbox_layer, (0, -1));
                }
                Key::CtrlUp | Key::CtrlK => {
                    mgr.move_graphic(pbid, pb_layer, (0, -1));
                }
                Key::Up | Key::K => {
                    mgr.stop_animation(gid);
                    mgr.move_graphic(gid, 1, (0, -1));
                    mgr.set_graphic(gid, 1, true);
                }
                Key::AltDown | Key::AltJ => {
                    mgr.move_graphic(mbox_id, mbox_layer, (0, 1));
                }
                Key::CtrlDown => {
                    mgr.move_graphic(pbid, pb_layer, (0, 1));
                }
                Key::Down | Key::J => {
                    mgr.pause_animation_on_frame(pbid, 100);
                    mgr.move_graphic(gid, 1, (0, 1));
                    mgr.set_graphic(gid, pid, true);
                }
                Key::AltLeft | Key::AltH => {
                    mgr.move_graphic(mbox_id, mbox_layer, (-1, 0));
                }
                Key::CtrlLeft | Key::Backspace => {
                    mgr.move_graphic(pbid, pb_layer, (-1, 0));
                }
                Key::Left | Key::H => {
                    mgr.move_graphic(gid, 1, (-1, 0));
                    mgr.start_animation(gid, 0);
                    mgr.start_animation(pbid, 0);
                }
                Key::AltRight | Key::AltL => {
                    mgr.move_graphic(mbox_id, mbox_layer, (1, 0));
                }
                Key::CtrlRight | Key::CtrlL => {
                    mgr.move_graphic(pbid, pb_layer, (1, 0));
                }
                Key::Right | Key::L => {
                    mgr.move_graphic(gid, 1, (1, 0));
                }
                Key::Tab => {
                    mbox_layer += 1;
                    if !mbox_created {
                        if let  Some(mbid) = mgr.add_graphic(
                            build_mbox(60, 20, "La ku ka ra cza ga wi ga ba ga da da da ja nie".to_string(),
                            "lastBuildDate: Tue, 12 Apr 2022 07:52:44 GMT
* generator: Oddmuse
* copyright: This work is licensed to you under version 2 of the GNU General Public License. Alternatively, you may choose to receive this work under
 any other license that grants the right to use, copy, modify, and distribute the work, as long as that license imposes the restriction that derivative
 works have to grant the same rights and impose the same restriction. For example, you may choose to receive this work under the GNU Free
 Documentation License, the CreativeCommons ShareAlike License, the XEmacs manual license, or similar licenses.
* license: https://creativecommons.org/licenses/sa/1.0/
* license: https://www.gnu.org/copyleft/fdl.html
* license: https://www.gnu.org/copyleft/gpl.html".to_string()                        ),
                        mbox_layer,
                        (0, 0),
                    ){
                        mgr.set_graphic(mbid, 0, true);
                            mbox_created = true;
                            mbox_id = mbid;
                        }
                    }
                }
                Key::CtrlA => {
                    mgr.start_animation(gid, 0);
                }
                Key::CtrlB => {
                    mgr.stop_animation(gid);
                }
                Key::Insert => {
                    mgr.set_graphic(gid, 2, false);
                }
                Key::Delete => {}
                Key::Home => {
                    mgr.set_glyph(gid, Glyph::default(), 1, 1);
                    mgr.move_graphic(gid, 1, (0, 0));
                    mgr.empty_frame(gid);
                }
                Key::Escape | Key::Q | Key::CtrlQ => {
                    break;
                }
                Key::Enter => {
                    if !mbox_created {
                        mbox_layer += 1;
                        if let Some(tid) = mgr.add_graphic(
                            build_mbox(
                                40,
                                1,
                                "Please enter title and hit Enter".to_string(),
                                String::new(),
                            ),
                            mbox_layer,
                            (cols as isize / 2 - 20, rows as isize / 2),
                        ) {
                            mgr.set_graphic(tid, 0, true);
                            let line = mgr.read_line();
                            if let Some(mbid) = mgr.add_graphic(
                                build_mbox(
                                    60,
                                    20,
                                    line,
                                    "Hit Enter to type content in.".to_string(),
                                ),
                                mbox_layer,
                                (0, 0),
                            ) {
                                mgr.delete_graphic(tid);
                                mbox_id = mbid;
                                mgr.set_graphic(mbid, 0, true);
                                mbox_created = true;
                            }
                        }
                    } else {
                        let mut x = 1;
                        let mut y = 1;
                        mbox_created = false;
                        let mut rev = Glyph::default();
                        rev.set_reverse(true);
                        for i in 1..31 {
                            mgr.set_glyph(mbox_id, rev, i, 1);
                        }
                        loop {
                            if let Some(c) = mgr.read_char() {
                                if c == '\t' {
                                    break;
                                }
                                if c as u8 == 8 || c as u8 == 127 {
                                    x -= 1;
                                    if x == 0 {
                                        if y > 1 {
                                            y -= 1;
                                            x = 58;
                                        } else {
                                            x = 1;
                                        }
                                    }
                                    mgr.set_glyph(mbox_id, Glyph::default(), x, y);
                                    continue;
                                }
                                if c == '\n' {
                                    break;
                                }

                                mgr.set_glyph(mbox_id, Glyph::default_with_char(c), x, y);
                                x += 1;
                                if x > 58 {
                                    x = 1;
                                    y += 1;
                                }
                            }
                        }
                    }
                }
                _ => {
                    println!("You pressed: {:?}", key);
                }
            }
        }
    }
    mgr.terminate();
}
source

pub fn yellow() -> Color

Get a yellow color.

source

pub fn blue() -> Color

Get a blue color.

source

pub fn magenta() -> Color

Get a magenta color.

source

pub fn cyan() -> Color

Get a cyan color.

Examples found in repository?
examples/example_5.rs (line 515)
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
fn build_progress_bar(length: usize) -> Graphic {
    let glf = Glyph::new(
        '\u{2588}',
        animaterm::Color::new(ColorName::Red),
        animaterm::Color::new(ColorName::White),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    progress_bar(
        length,
        Glyph::transparent(),
        glf,
        Some(vec![
            Glyph::new(
                '\u{258F}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258E}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258D}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258C}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258B}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            Glyph::new(
                '\u{258A}',
                animaterm::Color::red(),
                animaterm::Color::cyan(),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            ),
            // Glyph::new(
            //     '\u{2589}',
            //     animaterm::Color::new_truecolor(128, 0, 0),
            //     animaterm::Color::cyan(),
            //     false,
            //     true,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            //     false,
            // ),
        ]),
    )
}
source

pub fn white() -> Color

Get a white color.

source

pub fn new_8bit(red: u8, green: u8, blue: u8) -> Color

Get a new 8-bit color defined by three values ranging from 0 to 5.

Examples found in repository?
examples/example_5.rs (line 416)
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
fn build_graphic(cols: usize, rows: usize) -> (Graphic, usize) {
    let start_frame = 0;
    let mut library = HashMap::with_capacity(2);
    library.insert(
        start_frame,
        vec![
            Glyph::new(
                '\u{2580}',
                animaterm::Color::new_8bit(0, 5, 0),
                animaterm::Color::new_8bit(0, 0, 5),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            );
            rows * cols
        ],
    );
    let mut animations = HashMap::new();
    animations.insert(
        0,
        Animation::new(
            false,
            true,
            vec![(1, Timestamp::new(0, 500)), (0, Timestamp::new(0, 500))],
            Timestamp::now(),
        ),
    );

    let mut gr = Graphic::new(cols, rows, start_frame, library, Some(animations));
    let pid = gr
        .add_to_library(vec![
            Glyph::new(
                '\u{2580}',
                animaterm::Color::new_truecolor(0, 255, 255),
                animaterm::Color::new_truecolor(0, 0, 255),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            );
            rows * cols
        ])
        .unwrap();
    (gr, pid)
}
More examples
Hide additional examples
examples/example_3.rs (line 14)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
fn main() {
    let mut mgr = Manager::new(true, None, None, None, None, None);

    let mut library = HashMap::with_capacity(2);
    let cols = 10;
    let rows = 5;
    let start_frame = 0;
    let glyph_1 = Glyph::new(
        '\u{2580}',
        Color::new_8bit(0, 0, 5),
        Color::new_8bit(5, 5, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    let glyph_2 = Glyph::new(
        '\u{258C}',
        Color::new_truecolor(255, 255, 255),
        Color::new_truecolor(255, 0, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );

    library.insert(start_frame, vec![glyph_1; rows * cols]);
    library.insert(start_frame + 1, vec![glyph_2; rows * cols]);
    let gr = Graphic::new(cols, rows, start_frame, library, None);

    let layer = 0;
    let offset = (15, 5);
    let graphic_id = mgr.add_graphic(gr, layer, offset).unwrap();
    let screen_size = mgr.screen_size();
    let title = "Navigation help".to_string();
    let text = "Use arrows to move graphic around \nPress q or Shift+q to quit\n".to_string();
    let mbox = message_box(Some(title), text, Glyph::default(), 37, 5);
    let mbid = mgr
        .add_graphic(mbox, 1, (1, screen_size.1 as isize - 6))
        .unwrap();
    mgr.set_graphic(graphic_id, start_frame, true);
    mgr.set_graphic(mbid, 0, true);

    let mut keep_running = true;
    while keep_running {
        if let Some(key) = mgr.read_key() {
            match key {
                Key::Left => mgr.move_graphic(graphic_id, layer, (-1, 0)),
                Key::Right => mgr.move_graphic(graphic_id, layer, (1, 0)),
                Key::Up => mgr.move_graphic(graphic_id, layer, (0, -1)),
                Key::Down => mgr.move_graphic(graphic_id, layer, (0, 1)),
                Key::Q | Key::ShiftQ => {
                    keep_running = false;
                }
                _ => continue,
            }
        }
    }

    mgr.terminate();
}
examples/example_1.rs (line 26)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
fn main() {
    let macros = Some(vec![
        (Key::AltM, MacroSequence::empty()),
        (
            Key::T,
            MacroSequence::from_text(
                "This text was typed with a single key press!".to_string(),
                Duration::from_millis(100),
                false,
            ),
        ),
    ]);
    let mut mgr = Manager::new(true, None, None, None, None, macros);

    let mut library = HashMap::with_capacity(2);
    let cols = 10;
    let rows = 5;
    let start_frame = 0;
    let glyph_1 = Glyph::new(
        '\u{2580}',
        Color::new_8bit(0, 0, 5),
        Color::new_8bit(5, 5, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    let glyph_2 = Glyph::new(
        '\u{258C}',
        Color::new_truecolor(255, 255, 255),
        Color::new_truecolor(255, 0, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );

    library.insert(start_frame, vec![glyph_1; rows * cols]);
    library.insert(start_frame + 1, vec![glyph_2; rows * cols]);
    let gr = Graphic::new(cols, rows, start_frame, library, None);

    let layer = 0;
    let offset = (15, 5);
    let graphic_id = mgr.add_graphic(gr, layer, offset).unwrap();
    let screen_size = mgr.screen_size();
    let title = "Navigation help".to_string();
    let text = "Press 0 to set current frame to 0\n Press 1 to set current frame to 1\n Press t to type text using macro\n Press AltM to define a macro\n\nPress q or Shift+q to quit\n".to_string();
    let mbox = message_box(Some(title), text, Glyph::default(), 37, 7);
    let mbid = mgr.add_graphic(mbox, 1, (1, screen_size.1 as isize - 10));
    if let Some(mid) = mbid {
        mgr.set_graphic(mid, 0, true);
    }

    let mut keep_running = true;
    mgr.move_cursor(1, 1);
    let mut macro_mode: u8 = 0;
    let mut looped = false;
    while keep_running {
        let read_result = mgr.read_key();
        if read_result.is_none() {
            continue;
        }
        let key = read_result.unwrap();
        if let Some(ch) = map_key_to_char(&key) {
            if macro_mode == 0 {
                print!("{}", ch);
            }
        }
        match key {
            Key::Zero => mgr.set_graphic(graphic_id, start_frame, true),
            Key::One => mgr.set_graphic(graphic_id, start_frame + 1, true),
            Key::AltM => match macro_mode {
                0 => {
                    // let (max_x, may_y)=mgr.screen_size();
                    // mgr.clear_area(0, (0,1),(max_x,4) );
                    println!("Press trigger key (or AltM again to toggle macro looping)");
                    macro_mode = 1;
                }
                1 => {
                    looped = !looped;
                    println!("Macro looping: {}", looped);
                }
                2 => {
                    println!("Macro is defined!");
                    macro_mode = 0;
                    looped = false;
                }
                _ => {
                    println!("This should not happen");
                }
            },
            Key::Q | Key::ShiftQ => {
                keep_running = false;
            }
            other => {
                if macro_mode == 1 {
                    println!("Macro trigger: {}", other);
                    println!("Not type macro sequence, followed by AltM");
                    macro_mode = 2;
                } else if macro_mode == 2 {
                    println!("Macro sequence add: {}", other)
                } else {
                    continue;
                }
            }
        }
    }

    mgr.terminate();
}
examples/example_2.rs (line 14)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
fn main() {
    let mut mgr = Manager::new(true, None, None, None, None, None);

    let mut library = HashMap::with_capacity(2);
    let cols = 10;
    let rows = 5;
    let start_frame = 0;
    let glyph_1 = Glyph::new(
        '\u{2580}',
        Color::new_8bit(0, 0, 5),
        Color::new_8bit(5, 5, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    let glyph_2 = Glyph::new(
        '\u{258C}',
        Color::new_truecolor(255, 255, 255),
        Color::new_truecolor(255, 0, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );

    library.insert(start_frame, vec![glyph_1; rows * cols]);
    library.insert(start_frame + 1, vec![glyph_2; rows * cols]);
    let ordering = vec![
        (start_frame, Timestamp::new(0, 500)),
        (start_frame + 1, Timestamp::new(0, 500)),
    ];
    let running = false;
    let looping = true;
    let start_time = Timestamp::now();
    let animation = Animation::new(running, looping, ordering, start_time);
    let mut animations = HashMap::new();
    let anim_id = 0;
    animations.insert(anim_id, animation);
    let mut gr = Graphic::new(cols, rows, start_frame, library, Some(animations));
    let fast_ordering = vec![
        (start_frame, Timestamp::new(0, 200)),
        (start_frame + 1, Timestamp::new(0, 200)),
    ];
    let mut fast_anim_id = anim_id;
    if let Some(id) = gr.add_animation(Animation::new(running, looping, fast_ordering, start_time))
    {
        fast_anim_id = id;
    };

    let layer = 0;
    let offset = (15, 5);
    let graphic_id = mgr.add_graphic(gr, layer, offset).unwrap();
    let screen_size = mgr.screen_size();
    let title = "Navigation help".to_string();
    let text = "Press 0 to set current frame to 0\n Press 1 to set current frame to 1\n Press a|Shift+a|Ctrl+a start anim \n Press s or Shift+s stop animation\n\n Press q or Shift+q to quit\n".to_string();
    let mbox = message_box(Some(title), text, Glyph::default(), 80, 17);
    let mbid = mgr
        .add_graphic(mbox, 1, (1, screen_size.1 as isize - 8))
        .unwrap();
    mgr.set_graphic(mbid, 0, true);

    let var_ordering = vec![
        (start_frame, Timestamp::new(0, 400)),
        (start_frame + 1, Timestamp::new(0, 400)),
        (start_frame, Timestamp::new(0, 300)),
        (start_frame + 1, Timestamp::new(0, 300)),
        (start_frame, Timestamp::new(0, 200)),
        (start_frame + 1, Timestamp::new(0, 200)),
        (start_frame, Timestamp::new(0, 100)),
        (start_frame + 1, Timestamp::new(0, 100)),
        (start_frame, Timestamp::new(0, 200)),
        (start_frame + 1, Timestamp::new(0, 200)),
        (start_frame, Timestamp::new(0, 300)),
        (start_frame + 1, Timestamp::new(0, 300)),
    ];
    // let mut all_results_read = false;
    // while !all_results_read {
    //     let result = mgr.read_result();
    //     match result {
    //         Ok(AnimOk::AllResultsRead) => all_results_read = true,
    //         _ => continue,
    //     }
    // }
    mgr.add_animation(
        graphic_id,
        Animation::new(false, true, var_ordering, Timestamp::now()),
    );
    let mut var_anim_id = 0;

    if let Ok(AnimOk::AnimationAdded(anim_id)) = mgr.read_result() {
        var_anim_id = anim_id;
    }

    let mut keep_running = true;
    while keep_running {
        if let Some(key) = mgr.read_key() {
            match key {
                Key::Zero => mgr.set_graphic(graphic_id, start_frame, true),
                Key::One => mgr.set_graphic(graphic_id, start_frame + 1, true),
                Key::A => mgr.start_animation(graphic_id, anim_id),
                Key::ShiftA => mgr.start_animation(graphic_id, fast_anim_id),
                Key::P => mgr.pause_animation(graphic_id),
                Key::CtrlP => mgr.pause_animation(graphic_id),
                Key::ShiftP => mgr.pause_animation_on_frame(graphic_id, start_frame),
                Key::CtrlA => mgr.start_animation(graphic_id, var_anim_id),
                Key::S | Key::ShiftS => mgr.stop_animation(graphic_id),
                Key::Q | Key::ShiftQ => {
                    keep_running = false;
                }
                _ => continue,
            }
        }
    }

    mgr.terminate();
}
source

pub fn new_gray(brightness: u8) -> Color

Get a new Grayscale color defined by value from 0 to 23.

Examples found in repository?
examples/example_5.rs (line 473)
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
fn build_mbox(cols: usize, rows: usize, title: String, content: String) -> Graphic {
    message_box(
        Some(title),
        content,
        Glyph::new(
            ' ',
            animaterm::Color::new_gray(0),
            animaterm::Color::new_gray(22),
            false,
            false,
            false,
            false,
            false,
            false,
            false,
            false,
            false,
            false,
        ),
        cols,
        rows,
    )
}
source

pub fn new_truecolor(red: u8, green: u8, blue: u8) -> Color

Get a new Truecolor defined by three values ranging from 0 to 255 each.

Examples found in repository?
examples/example_5.rs (line 448)
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
fn build_graphic(cols: usize, rows: usize) -> (Graphic, usize) {
    let start_frame = 0;
    let mut library = HashMap::with_capacity(2);
    library.insert(
        start_frame,
        vec![
            Glyph::new(
                '\u{2580}',
                animaterm::Color::new_8bit(0, 5, 0),
                animaterm::Color::new_8bit(0, 0, 5),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            );
            rows * cols
        ],
    );
    let mut animations = HashMap::new();
    animations.insert(
        0,
        Animation::new(
            false,
            true,
            vec![(1, Timestamp::new(0, 500)), (0, Timestamp::new(0, 500))],
            Timestamp::now(),
        ),
    );

    let mut gr = Graphic::new(cols, rows, start_frame, library, Some(animations));
    let pid = gr
        .add_to_library(vec![
            Glyph::new(
                '\u{2580}',
                animaterm::Color::new_truecolor(0, 255, 255),
                animaterm::Color::new_truecolor(0, 0, 255),
                false,
                true,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
            );
            rows * cols
        ])
        .unwrap();
    (gr, pid)
}
More examples
Hide additional examples
examples/example_3.rs (line 29)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
fn main() {
    let mut mgr = Manager::new(true, None, None, None, None, None);

    let mut library = HashMap::with_capacity(2);
    let cols = 10;
    let rows = 5;
    let start_frame = 0;
    let glyph_1 = Glyph::new(
        '\u{2580}',
        Color::new_8bit(0, 0, 5),
        Color::new_8bit(5, 5, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    let glyph_2 = Glyph::new(
        '\u{258C}',
        Color::new_truecolor(255, 255, 255),
        Color::new_truecolor(255, 0, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );

    library.insert(start_frame, vec![glyph_1; rows * cols]);
    library.insert(start_frame + 1, vec![glyph_2; rows * cols]);
    let gr = Graphic::new(cols, rows, start_frame, library, None);

    let layer = 0;
    let offset = (15, 5);
    let graphic_id = mgr.add_graphic(gr, layer, offset).unwrap();
    let screen_size = mgr.screen_size();
    let title = "Navigation help".to_string();
    let text = "Use arrows to move graphic around \nPress q or Shift+q to quit\n".to_string();
    let mbox = message_box(Some(title), text, Glyph::default(), 37, 5);
    let mbid = mgr
        .add_graphic(mbox, 1, (1, screen_size.1 as isize - 6))
        .unwrap();
    mgr.set_graphic(graphic_id, start_frame, true);
    mgr.set_graphic(mbid, 0, true);

    let mut keep_running = true;
    while keep_running {
        if let Some(key) = mgr.read_key() {
            match key {
                Key::Left => mgr.move_graphic(graphic_id, layer, (-1, 0)),
                Key::Right => mgr.move_graphic(graphic_id, layer, (1, 0)),
                Key::Up => mgr.move_graphic(graphic_id, layer, (0, -1)),
                Key::Down => mgr.move_graphic(graphic_id, layer, (0, 1)),
                Key::Q | Key::ShiftQ => {
                    keep_running = false;
                }
                _ => continue,
            }
        }
    }

    mgr.terminate();
}
examples/example_1.rs (line 41)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
fn main() {
    let macros = Some(vec![
        (Key::AltM, MacroSequence::empty()),
        (
            Key::T,
            MacroSequence::from_text(
                "This text was typed with a single key press!".to_string(),
                Duration::from_millis(100),
                false,
            ),
        ),
    ]);
    let mut mgr = Manager::new(true, None, None, None, None, macros);

    let mut library = HashMap::with_capacity(2);
    let cols = 10;
    let rows = 5;
    let start_frame = 0;
    let glyph_1 = Glyph::new(
        '\u{2580}',
        Color::new_8bit(0, 0, 5),
        Color::new_8bit(5, 5, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    let glyph_2 = Glyph::new(
        '\u{258C}',
        Color::new_truecolor(255, 255, 255),
        Color::new_truecolor(255, 0, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );

    library.insert(start_frame, vec![glyph_1; rows * cols]);
    library.insert(start_frame + 1, vec![glyph_2; rows * cols]);
    let gr = Graphic::new(cols, rows, start_frame, library, None);

    let layer = 0;
    let offset = (15, 5);
    let graphic_id = mgr.add_graphic(gr, layer, offset).unwrap();
    let screen_size = mgr.screen_size();
    let title = "Navigation help".to_string();
    let text = "Press 0 to set current frame to 0\n Press 1 to set current frame to 1\n Press t to type text using macro\n Press AltM to define a macro\n\nPress q or Shift+q to quit\n".to_string();
    let mbox = message_box(Some(title), text, Glyph::default(), 37, 7);
    let mbid = mgr.add_graphic(mbox, 1, (1, screen_size.1 as isize - 10));
    if let Some(mid) = mbid {
        mgr.set_graphic(mid, 0, true);
    }

    let mut keep_running = true;
    mgr.move_cursor(1, 1);
    let mut macro_mode: u8 = 0;
    let mut looped = false;
    while keep_running {
        let read_result = mgr.read_key();
        if read_result.is_none() {
            continue;
        }
        let key = read_result.unwrap();
        if let Some(ch) = map_key_to_char(&key) {
            if macro_mode == 0 {
                print!("{}", ch);
            }
        }
        match key {
            Key::Zero => mgr.set_graphic(graphic_id, start_frame, true),
            Key::One => mgr.set_graphic(graphic_id, start_frame + 1, true),
            Key::AltM => match macro_mode {
                0 => {
                    // let (max_x, may_y)=mgr.screen_size();
                    // mgr.clear_area(0, (0,1),(max_x,4) );
                    println!("Press trigger key (or AltM again to toggle macro looping)");
                    macro_mode = 1;
                }
                1 => {
                    looped = !looped;
                    println!("Macro looping: {}", looped);
                }
                2 => {
                    println!("Macro is defined!");
                    macro_mode = 0;
                    looped = false;
                }
                _ => {
                    println!("This should not happen");
                }
            },
            Key::Q | Key::ShiftQ => {
                keep_running = false;
            }
            other => {
                if macro_mode == 1 {
                    println!("Macro trigger: {}", other);
                    println!("Not type macro sequence, followed by AltM");
                    macro_mode = 2;
                } else if macro_mode == 2 {
                    println!("Macro sequence add: {}", other)
                } else {
                    continue;
                }
            }
        }
    }

    mgr.terminate();
}
examples/example_2.rs (line 29)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
fn main() {
    let mut mgr = Manager::new(true, None, None, None, None, None);

    let mut library = HashMap::with_capacity(2);
    let cols = 10;
    let rows = 5;
    let start_frame = 0;
    let glyph_1 = Glyph::new(
        '\u{2580}',
        Color::new_8bit(0, 0, 5),
        Color::new_8bit(5, 5, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );
    let glyph_2 = Glyph::new(
        '\u{258C}',
        Color::new_truecolor(255, 255, 255),
        Color::new_truecolor(255, 0, 0),
        false,
        true,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
        false,
    );

    library.insert(start_frame, vec![glyph_1; rows * cols]);
    library.insert(start_frame + 1, vec![glyph_2; rows * cols]);
    let ordering = vec![
        (start_frame, Timestamp::new(0, 500)),
        (start_frame + 1, Timestamp::new(0, 500)),
    ];
    let running = false;
    let looping = true;
    let start_time = Timestamp::now();
    let animation = Animation::new(running, looping, ordering, start_time);
    let mut animations = HashMap::new();
    let anim_id = 0;
    animations.insert(anim_id, animation);
    let mut gr = Graphic::new(cols, rows, start_frame, library, Some(animations));
    let fast_ordering = vec![
        (start_frame, Timestamp::new(0, 200)),
        (start_frame + 1, Timestamp::new(0, 200)),
    ];
    let mut fast_anim_id = anim_id;
    if let Some(id) = gr.add_animation(Animation::new(running, looping, fast_ordering, start_time))
    {
        fast_anim_id = id;
    };

    let layer = 0;
    let offset = (15, 5);
    let graphic_id = mgr.add_graphic(gr, layer, offset).unwrap();
    let screen_size = mgr.screen_size();
    let title = "Navigation help".to_string();
    let text = "Press 0 to set current frame to 0\n Press 1 to set current frame to 1\n Press a|Shift+a|Ctrl+a start anim \n Press s or Shift+s stop animation\n\n Press q or Shift+q to quit\n".to_string();
    let mbox = message_box(Some(title), text, Glyph::default(), 80, 17);
    let mbid = mgr
        .add_graphic(mbox, 1, (1, screen_size.1 as isize - 8))
        .unwrap();
    mgr.set_graphic(mbid, 0, true);

    let var_ordering = vec![
        (start_frame, Timestamp::new(0, 400)),
        (start_frame + 1, Timestamp::new(0, 400)),
        (start_frame, Timestamp::new(0, 300)),
        (start_frame + 1, Timestamp::new(0, 300)),
        (start_frame, Timestamp::new(0, 200)),
        (start_frame + 1, Timestamp::new(0, 200)),
        (start_frame, Timestamp::new(0, 100)),
        (start_frame + 1, Timestamp::new(0, 100)),
        (start_frame, Timestamp::new(0, 200)),
        (start_frame + 1, Timestamp::new(0, 200)),
        (start_frame, Timestamp::new(0, 300)),
        (start_frame + 1, Timestamp::new(0, 300)),
    ];
    // let mut all_results_read = false;
    // while !all_results_read {
    //     let result = mgr.read_result();
    //     match result {
    //         Ok(AnimOk::AllResultsRead) => all_results_read = true,
    //         _ => continue,
    //     }
    // }
    mgr.add_animation(
        graphic_id,
        Animation::new(false, true, var_ordering, Timestamp::now()),
    );
    let mut var_anim_id = 0;

    if let Ok(AnimOk::AnimationAdded(anim_id)) = mgr.read_result() {
        var_anim_id = anim_id;
    }

    let mut keep_running = true;
    while keep_running {
        if let Some(key) = mgr.read_key() {
            match key {
                Key::Zero => mgr.set_graphic(graphic_id, start_frame, true),
                Key::One => mgr.set_graphic(graphic_id, start_frame + 1, true),
                Key::A => mgr.start_animation(graphic_id, anim_id),
                Key::ShiftA => mgr.start_animation(graphic_id, fast_anim_id),
                Key::P => mgr.pause_animation(graphic_id),
                Key::CtrlP => mgr.pause_animation(graphic_id),
                Key::ShiftP => mgr.pause_animation_on_frame(graphic_id, start_frame),
                Key::CtrlA => mgr.start_animation(graphic_id, var_anim_id),
                Key::S | Key::ShiftS => mgr.stop_animation(graphic_id),
                Key::Q | Key::ShiftQ => {
                    keep_running = false;
                }
                _ => continue,
            }
        }
    }

    mgr.terminate();
}

Trait Implementations§

source§

impl Clone for Color

source§

fn clone(&self) -> Color

Returns a copy of the value. Read more
1.6.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Color

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Color

source§

fn eq(&self, other: &Color) -> bool

Tests for self and other values to be equal, and is used by ==.
1.6.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Color

source§

impl StructuralPartialEq for Color

Auto Trait Implementations§

§

impl Freeze for Color

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnwindSafe for Color

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.