diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 3c08f1e73c..ebb7640ce6 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -64,6 +64,17 @@ void CanvasRenderingContext2D::fill_rect(float x, float y, float width, float he did_draw(rect); } +void CanvasRenderingContext2D::clear_rect(float x, float y, float width, float height) +{ + auto painter = this->painter(); + if (!painter) + return; + + auto rect = m_transform.map(Gfx::FloatRect(x, y, width, height)); + painter->clear_rect(enclosing_int_rect(rect), Color()); + did_draw(rect); +} + void CanvasRenderingContext2D::set_stroke_style(String style) { m_stroke_style = Gfx::Color::from_string(style).value_or(Color::Black); diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index 58cccfc6e6..8a8a1f860f 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -57,6 +57,7 @@ public: void fill_rect(float x, float y, float width, float height); void stroke_rect(float x, float y, float width, float height); + void clear_rect(float x, float y, float width, float height); void draw_image(const HTMLImageElement&, float x, float y); diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl index bcfa544c67..97f0462601 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.idl @@ -2,6 +2,7 @@ interface CanvasRenderingContext2D { undefined fillRect(double x, double y, double w, double h); undefined strokeRect(double x, double y, double w, double h); + undefined clearRect(double x, double y, double w, double h); undefined scale(double x, double y); undefined translate(double x, double y);