Clear canvas with background color
This commit is contained in:
parent
69068d926d
commit
c5f49ee51a
|
@ -43,11 +43,11 @@ pub struct Canvas {
|
|||
|
||||
impl Canvas {
|
||||
#[inline]
|
||||
pub fn new(width: usize, height: usize) -> Self {
|
||||
pub fn new(color: u32, width: usize, height: usize) -> Self {
|
||||
Self {
|
||||
width,
|
||||
height,
|
||||
buffer: vec![0; width * height].into_boxed_slice(),
|
||||
buffer: vec![color; width * height].into_boxed_slice(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,11 +250,13 @@ pub struct Graphics {
|
|||
|
||||
impl Graphics {
|
||||
pub fn new(config: &Config) -> Self {
|
||||
let canvas = Canvas::new(2000, 2000);
|
||||
|
||||
let mut colors = Colors::default();
|
||||
Self::load_colors(&config.colors, &mut colors);
|
||||
|
||||
let bg = &config.colors.background;
|
||||
let bg = ((bg.r as u32) << 16) | ((bg.g as u32) << 8) | (bg.b as u32);
|
||||
let canvas = Canvas::new(bg, 2000, 2000);
|
||||
|
||||
let glyph_cache = GlyphCache::new(colors.clone(), &config.fonts);
|
||||
let cell_cache = Default::default();
|
||||
|
||||
|
@ -316,7 +318,8 @@ impl Graphics {
|
|||
}
|
||||
|
||||
pub fn resize(&mut self, width: usize, height: usize) {
|
||||
self.canvas = Canvas::new(width, height);
|
||||
let bg = self.color_to_u32(&Color::Named(NamedColor::Background));
|
||||
self.canvas = Canvas::new(bg, width, height);
|
||||
self.cell_cache.clear();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue