1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40:03 -04:00

Added App::clear_color() that apps can use to specify background color

This commit is contained in:
Emil Ernerfeldt
2020-12-18 22:34:48 +01:00
parent 9ea8d907fd
commit c3c4f28a9d
6 changed files with 33 additions and 11 deletions

View File

@@ -55,10 +55,13 @@ impl WebBackend {
Ok((output, paint_jobs))
}
pub fn paint(&mut self, paint_jobs: egui::PaintJobs) -> Result<(), JsValue> {
let bg_color = egui::color::TRANSPARENT; // Use background css color.
pub fn paint(
&mut self,
clear_color: egui::Rgba,
paint_jobs: egui::PaintJobs,
) -> Result<(), JsValue> {
self.painter.paint_jobs(
bg_color,
clear_color,
paint_jobs,
&self.ctx.texture(),
self.ctx.pixels_per_point(),
@@ -214,7 +217,7 @@ impl AppRunner {
}
pub fn paint(&mut self, paint_jobs: egui::PaintJobs) -> Result<(), JsValue> {
self.web_backend.paint(paint_jobs)
self.web_backend.paint(self.app.clear_color(), paint_jobs)
}
}

View File

@@ -328,11 +328,12 @@ impl Painter {
self.canvas.width() as i32,
self.canvas.height() as i32,
);
let clear_color: Srgba = clear_color.into();
gl.clear_color(
clear_color[0],
clear_color[1],
clear_color[2],
clear_color[3],
clear_color[0] as f32 / 255.0,
clear_color[1] as f32 / 255.0,
clear_color[2] as f32 / 255.0,
clear_color[3] as f32 / 255.0,
);
gl.clear(Gl::COLOR_BUFFER_BIT);