1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

LibWeb: Add canvas.strokeRect(), and fix scale & translate

Add an implementation of CanvasRenderingContext2DWrapper.strokeRect().
While implementing this I fixed fillRect() and the new strokeRect() to
honor the .scale() and .translate() values that had previously been plumbed.

Also enhance the canvas.html demo to utilize strokeRect(), scale(), and translate().
This commit is contained in:
Brian Gianforcaro 2020-04-07 01:09:17 -07:00 committed by Andreas Kling
parent 7291d5c86f
commit 39855fe9ef
5 changed files with 80 additions and 3 deletions

View file

@ -49,13 +49,18 @@ public:
void set_fill_style(String);
String fill_style() const;
void set_stroke_style(String);
String stroke_style() const;
void fill_rect(int x, int y, int width, int height);
void stroke_rect(int x, int y, int width, int height);
void scale(double sx, double sy);
void translate(double x, double y);
private:
explicit CanvasRenderingContext2D(HTMLCanvasElement&);
Gfx::Rect compute_rect(int x, int y, int width, int height);
void did_draw(const Gfx::Rect&);
OwnPtr<Gfx::Painter> painter();
@ -67,6 +72,7 @@ private:
double m_translate_x { 0 };
double m_translate_y { 0 };
Gfx::Color m_fill_style;
Gfx::Color m_stroke_style;
};
}