pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
Fields§
§r: u8
§g: u8
§b: u8
§a: u8
Implementations§
Source§impl Color
impl Color
Sourcepub fn RGB(r: u8, g: u8, b: u8) -> Color
pub fn RGB(r: u8, g: u8, b: u8) -> Color
Examples found in repository?
examples/simple.rs (line 45)
5fn main() {
6 let mut a = Axle::default();
7 let (mut old_x, mut old_y) = a.mouse_pos();
8
9 let (width, height) = a.size();
10 println!("{}x{}", width, height);
11
12 a.circle(Point::new(100, 100), 100);
13
14 let center = Point::new(width as i32 / 2, height as i32 / 2);
15
16 let fps = a.fps(60.0);
17
18 loop {
19 let (x, y) = a.mouse_pos();
20 a.line(Point::new(old_x, old_y), Point::new(x, y));
21 old_x = x;
22 old_y = y;
23
24 if a.mouse_pressed(MouseButton::Left) {
25 a.pen_down();
26 } else {
27 a.pen_up();
28 }
29
30 if a.keyboard_pressed(Key::L) {
31 a.line(Point::new(x, y), center);
32 }
33
34 if a.keyboard_pressed(Key::C) {
35 a.clear();
36 }
37
38 let events = a.events();
39 for e in &events {
40 if let Event::Quit { .. } = *e {
41 return;
42 }
43 }
44
45 a.background(Color::RGB(255, 128, 0));
46 a.set_draw_color(Color::RGB(0, 0, 0));
47 a.draw();
48 a.sleep(fps);
49 }
50}
pub fn RGBA(r: u8, g: u8, b: u8, a: u8) -> Color
pub fn to_u32(&self, format: &PixelFormat) -> u32
pub fn from_u32(format: &PixelFormat, pixel: u32) -> Color
pub fn rgb(&self) -> (u8, u8, u8)
pub fn rgba(&self) -> (u8, u8, u8, u8)
Trait Implementations§
impl Copy for Color
impl Eq for Color
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more