mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
LibWeb: Add CanvasRenderingContext2D.clearRect()
Similar to fillRect, except this API fills with transparent black.
This commit is contained in:
parent
4559faf8d8
commit
d434ae71b3
Notes:
sideshowbarker
2024-07-18 21:19:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d434ae71b32
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user