Ver código fonte

moved color consts into color impl

master
Isabelle L. 5 anos atrás
pai
commit
3db823ef64
2 arquivos alterados com 6 adições e 4 exclusões
  1. +5
    -3
      src/color.rs
  2. +1
    -1
      src/lib.rs

+ 5
- 3
src/color.rs Ver arquivo

@@ -15,7 +15,9 @@ impl Color {
let (r, g, b) = (self.r as u32, self.g as u32, self.b as u32);
(r << 16) | (g << 8) | b
}
}

pub const BLACK: Color = Color { r: 0x00, g: 0x00, b: 0x00 };
pub const WHITE: Color = Color { r: 0xff, g: 0xff, b: 0xff };
/// white color
pub const WHITE: Color = Color { r: 0xff, g: 0xff, b: 0xff };
/// black color
pub const BLACK: Color = Color { r: 0x00, g: 0x00, b: 0x00 };
}

+ 1
- 1
src/lib.rs Ver arquivo

@@ -82,7 +82,7 @@ impl Context {

/// clears the pixel buffer
pub fn clear(&mut self, color: Option<color::Color>) {
let color = color.unwrap_or(color::BLACK);
let color = color.unwrap_or(Color::BLACK);
self.pixel_buffer.as_mut_ref().iter_mut().for_each(|pixel| *pixel = color.as_u32());
}



Carregando…
Cancelar
Salvar