Function fltk::draw::set_draw_rgb_color

source ยท
pub fn set_draw_rgb_color(r: u8, g: u8, b: u8)
Expand description

Sets the drawing color

Examples found in repository?
examples/custom_dial.rs (line 24)
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
    pub fn new(x: i32, y: i32, w: i32, h: i32, label: &str) -> Self {
        let value = Rc::from(RefCell::from(0));
        let mut main_wid = group::Group::new(x, y, w, h, None)
            .with_label(label)
            .with_align(Align::Top);
        let mut value_frame =
            frame::Frame::new(main_wid.x(), main_wid.y() + 80, main_wid.w(), 40, "0");
        value_frame.set_label_size(26);
        main_wid.end();
        let value_c = value.clone();
        main_wid.draw(move |w| {
            draw::set_draw_rgb_color(230, 230, 230);
            draw::draw_pie(w.x(), w.y(), w.w(), w.h(), 0., 180.);
            draw::set_draw_hex_color(0xb0bf1a);
            draw::draw_pie(
                w.x(),
                w.y(),
                w.w(),
                w.h(),
                (100 - *value_c.borrow()) as f64 * 1.8,
                180.,
            );
            draw::set_draw_color(Color::White);
            draw::draw_pie(
                w.x() - 50 + w.w() / 2,
                w.y() - 50 + w.h() / 2,
                100,
                100,
                0.,
                360.,
            );
            w.draw_children();
        });
        Self {
            main_wid,
            value,
            value_frame,
        }
    }
More examples
Hide additional examples
examples/counter3.rs (line 53)
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
fn main() {
    let app = app::App::default();
    let mut win = window::Window::default()
        .with_size(WIDTH, HEIGHT)
        .with_label("Flutter-like!");
    let mut col = group::Flex::default_fill().column();
    let mut bar = frame::Frame::default()
        .with_label("  FLTK App!")
        .with_align(Align::Left | Align::Inside);
    col.fixed(&bar, 60);
    let mut text = frame::Frame::default()
        .with_label("You have pushed the button this many times:")
        .with_align(Align::Bottom | Align::Inside);
    let mut count = frame::Frame::default()
        .with_label("0")
        .with_align(Align::Top | Align::Inside);
    let mut row = group::Flex::default();
    col.fixed(&row, 60);
    frame::Frame::default();
    let mut but = button::Button::default().with_label("@+6plus");
    row.fixed(&but, 60);
    let spacing = frame::Frame::default();
    row.fixed(&spacing, 20);
    row.end();
    let spacing = frame::Frame::default();
    col.fixed(&spacing, 20);
    col.end();
    win.end();
    win.make_resizable(true);
    win.show();

    // Theming
    app::background(255, 255, 255);
    app::set_visible_focus(false);

    bar.set_frame(FrameType::FlatBox);
    bar.set_label_size(22);
    bar.set_label_color(Color::White);
    bar.set_color(BLUE);
    bar.draw(|b| {
        draw::set_draw_rgb_color(211, 211, 211);
        draw::draw_rectf(0, b.height(), b.width(), 3);
    });

    text.set_label_size(18);
    text.set_label_font(Font::Times);

    count.set_label_size(36);
    count.set_label_color(GRAY);

    but.set_color(BLUE);
    but.set_selection_color(SEL_BLUE);
    but.set_label_color(Color::White);
    but.set_frame(FrameType::OFlatFrame);
    // End theming

    but.set_callback(move |_| {
        let label = (count.label().parse::<i32>().unwrap() + 1).to_string();
        count.set_label(&label);
    });

    app.run().unwrap();
}