ソースを参照

moved color consts into color impl

master
Isabelle L. 5年前
コミット
3db823ef64
2個のファイルの変更6行の追加4行の削除
  1. +5
    -3
      src/color.rs
  2. +1
    -1
      src/lib.rs

+ 5
- 3
src/color.rs ファイルの表示

@@ -15,7 +15,9 @@ impl Color {
let (r, g, b) = (self.r as u32, self.g as u32, self.b as u32); let (r, g, b) = (self.r as u32, self.g as u32, self.b as u32);
(r << 16) | (g << 8) | b (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 ファイルの表示

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


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




読み込み中…
キャンセル
保存