|
@@ -53,6 +53,14 @@ CanvasRenderingContext2DWrapper::CanvasRenderingContext2DWrapper(CanvasRendering
|
|
|
put_native_property("strokeStyle", stroke_style_getter, stroke_style_setter);
|
|
|
put_native_function("strokeRect", stroke_rect, 4);
|
|
|
put_native_function("drawImage", draw_image, 3);
|
|
|
+
|
|
|
+ put_native_function("beginPath", begin_path, 0);
|
|
|
+ put_native_function("closePath", close_path, 0);
|
|
|
+ put_native_function("stroke", stroke, 0);
|
|
|
+ put_native_function("moveTo", move_to, 0);
|
|
|
+ put_native_function("lineTo", line_to, 0);
|
|
|
+
|
|
|
+ put_native_property("lineWidth", line_width_getter, line_width_setter);
|
|
|
}
|
|
|
|
|
|
CanvasRenderingContext2DWrapper::~CanvasRenderingContext2DWrapper()
|
|
@@ -162,5 +170,68 @@ void CanvasRenderingContext2DWrapper::stroke_style_setter(JS::Interpreter& inter
|
|
|
impl->set_stroke_style(value.to_string());
|
|
|
}
|
|
|
|
|
|
+JS::Value CanvasRenderingContext2DWrapper::line_width_getter(JS::Interpreter& interpreter)
|
|
|
+{
|
|
|
+ auto* impl = impl_from(interpreter);
|
|
|
+ if (!impl)
|
|
|
+ return {};
|
|
|
+ return JS::Value(impl->line_width());
|
|
|
+}
|
|
|
+
|
|
|
+void CanvasRenderingContext2DWrapper::line_width_setter(JS::Interpreter& interpreter, JS::Value value)
|
|
|
+{
|
|
|
+ if (auto* impl = impl_from(interpreter))
|
|
|
+ impl->set_line_width(value.to_double());
|
|
|
+}
|
|
|
+
|
|
|
+JS::Value CanvasRenderingContext2DWrapper::begin_path(JS::Interpreter& interpreter)
|
|
|
+{
|
|
|
+ auto* impl = impl_from(interpreter);
|
|
|
+ if (!impl)
|
|
|
+ return {};
|
|
|
+ impl->begin_path();
|
|
|
+ return JS::js_undefined();
|
|
|
+}
|
|
|
+
|
|
|
+JS::Value CanvasRenderingContext2DWrapper::close_path(JS::Interpreter& interpreter)
|
|
|
+{
|
|
|
+ auto* impl = impl_from(interpreter);
|
|
|
+ if (!impl)
|
|
|
+ return {};
|
|
|
+ impl->close_path();
|
|
|
+ return JS::js_undefined();
|
|
|
+}
|
|
|
+
|
|
|
+JS::Value CanvasRenderingContext2DWrapper::stroke(JS::Interpreter& interpreter)
|
|
|
+{
|
|
|
+ auto* impl = impl_from(interpreter);
|
|
|
+ if (!impl)
|
|
|
+ return {};
|
|
|
+ impl->stroke();
|
|
|
+ return JS::js_undefined();
|
|
|
+}
|
|
|
+
|
|
|
+JS::Value CanvasRenderingContext2DWrapper::move_to(JS::Interpreter& interpreter)
|
|
|
+{
|
|
|
+ auto* impl = impl_from(interpreter);
|
|
|
+ if (!impl)
|
|
|
+ return {};
|
|
|
+ double x = interpreter.argument(0).to_double();
|
|
|
+ double y = interpreter.argument(1).to_double();
|
|
|
+ impl->move_to(x, y);
|
|
|
+ return JS::js_undefined();
|
|
|
+}
|
|
|
+
|
|
|
+JS::Value CanvasRenderingContext2DWrapper::line_to(JS::Interpreter& interpreter)
|
|
|
+{
|
|
|
+ auto* impl = impl_from(interpreter);
|
|
|
+ if (!impl)
|
|
|
+ return {};
|
|
|
+ double x = interpreter.argument(0).to_double();
|
|
|
+ double y = interpreter.argument(1).to_double();
|
|
|
+ impl->line_to(x, y);
|
|
|
+ return JS::js_undefined();
|
|
|
+}
|
|
|
+
|
|
|
}
|
|
|
}
|