mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:07:45 +00:00
LibWeb: Add canvas.quadraticCurveTo()
Also adds a test, and removes debug spam ™️
This commit is contained in:
parent
9f3f98d4c0
commit
0a55679de4
7 changed files with 70 additions and 2 deletions
|
@ -63,6 +63,7 @@ CanvasRenderingContext2DWrapper::CanvasRenderingContext2DWrapper(CanvasRendering
|
|||
put_native_function("stroke", stroke, 0);
|
||||
put_native_function("moveTo", move_to, 2);
|
||||
put_native_function("lineTo", line_to, 2);
|
||||
put_native_function("quadraticCurveTo", quadratic_curve_to, 4);
|
||||
|
||||
put_native_function("createImageData", create_image_data, 1);
|
||||
put_native_function("putImageData", put_image_data, 3);
|
||||
|
@ -240,6 +241,19 @@ JS::Value CanvasRenderingContext2DWrapper::line_to(JS::Interpreter& interpreter)
|
|||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
JS::Value CanvasRenderingContext2DWrapper::quadratic_curve_to(JS::Interpreter& interpreter)
|
||||
{
|
||||
auto* impl = impl_from(interpreter);
|
||||
if (!impl)
|
||||
return {};
|
||||
double cx = interpreter.argument(0).to_double();
|
||||
double cy = interpreter.argument(1).to_double();
|
||||
double x = interpreter.argument(2).to_double();
|
||||
double y = interpreter.argument(3).to_double();
|
||||
impl->quadratic_curve_to(cx, cy, x, y);
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
JS::Value CanvasRenderingContext2DWrapper::create_image_data(JS::Interpreter& interpreter)
|
||||
{
|
||||
auto* impl = impl_from(interpreter);
|
||||
|
|
|
@ -58,6 +58,7 @@ private:
|
|||
static JS::Value stroke(JS::Interpreter&);
|
||||
static JS::Value move_to(JS::Interpreter&);
|
||||
static JS::Value line_to(JS::Interpreter&);
|
||||
static JS::Value quadratic_curve_to(JS::Interpreter&);
|
||||
|
||||
static JS::Value create_image_data(JS::Interpreter&);
|
||||
static JS::Value put_image_data(JS::Interpreter&);
|
||||
|
|
|
@ -165,10 +165,13 @@ void CanvasRenderingContext2D::line_to(float x, float y)
|
|||
m_path.line_to({ x, y });
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::quadratic_curve_to(float cx, float cy, float x, float y)
|
||||
{
|
||||
m_path.quadratic_bezier_curve_to({ cx, cy }, { x, y });
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::stroke()
|
||||
{
|
||||
dbg() << "stroke path " << m_path;
|
||||
|
||||
auto painter = this->painter();
|
||||
if (!painter)
|
||||
return;
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
void close_path();
|
||||
void move_to(float x, float y);
|
||||
void line_to(float x, float y);
|
||||
void quadratic_curve_to(float cx, float cy, float x, float y);
|
||||
void stroke();
|
||||
|
||||
RefPtr<ImageData> create_image_data(JS::GlobalObject&, int width, int height) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue