Cube: Two small tweaks

I noticed these when playing with the demo locally:

- Use RGB32 instead of RGBA32 for the bitmap buffer. This avoids some
  flickering that would sometimes occur.

- Clip the gradient fill to the widget rect rather than the painter
  clip rect. In practice, the painter was always clipped to the widget
  rect here, but it seems logical to say "fill widget with gradient."
This commit is contained in:
Andreas Kling 2020-04-18 13:46:55 +02:00
parent fca08bd000
commit 9a109128f8
Notes: sideshowbarker 2024-07-19 07:30:56 +09:00

View File

@ -62,7 +62,7 @@ private:
Cube::Cube()
{
m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGBA32, { WIDTH, HEIGHT });
m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, { WIDTH, HEIGHT });
m_accumulated_time = 0;
m_cycles = 0;
@ -142,7 +142,7 @@ void Cube::timer_event(Core::TimerEvent&)
}
GUI::Painter painter(*m_bitmap);
painter.fill_rect_with_gradient(Gfx::Orientation::Vertical, painter.clip_rect(), Gfx::Color::White, Gfx::Color::Blue);
painter.fill_rect_with_gradient(Gfx::Orientation::Vertical, m_bitmap->rect(), Gfx::Color::White, Gfx::Color::Blue);
auto to_point = [](const FloatVector3& v) {
return Gfx::Point(v.x(), v.y());