mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibWeb: Add canvas.fill
This implements only one of the two forms of this function, ctx.fill(winding_rule). Also tweaks the quadratic curve demo to have a nice looking filled shape.
This commit is contained in:
parent
f54b41f748
commit
a82419469f
5 changed files with 52 additions and 0 deletions
|
@ -179,6 +179,15 @@ void CanvasRenderingContext2D::stroke()
|
|||
painter->stroke_path(m_path, m_stroke_style, m_line_width);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::fill(Gfx::Painter::WindingRule winding)
|
||||
{
|
||||
auto painter = this->painter();
|
||||
if (!painter)
|
||||
return;
|
||||
|
||||
painter->fill_path(m_path, m_fill_style, winding);
|
||||
}
|
||||
|
||||
RefPtr<ImageData> CanvasRenderingContext2D::create_image_data(JS::GlobalObject& global_object, int width, int height) const
|
||||
{
|
||||
return ImageData::create_with_size(global_object, width, height);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <LibGfx/AffineTransform.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/Path.h>
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
|
||||
|
@ -71,6 +72,7 @@ public:
|
|||
void line_to(float x, float y);
|
||||
void quadratic_curve_to(float cx, float cy, float x, float y);
|
||||
void stroke();
|
||||
void fill(Gfx::Painter::WindingRule);
|
||||
|
||||
RefPtr<ImageData> create_image_data(JS::GlobalObject&, int width, int height) const;
|
||||
void put_image_data(const ImageData&, float x, float y);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue