|
@@ -204,13 +204,21 @@ void CanvasRenderingContext2D::quadratic_curve_to(float cx, float cy, float x, f
|
|
m_path.quadratic_bezier_curve_to({ cx, cy }, { x, y });
|
|
m_path.quadratic_bezier_curve_to({ cx, cy }, { x, y });
|
|
}
|
|
}
|
|
|
|
|
|
-void CanvasRenderingContext2D::arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise)
|
|
|
|
|
|
+DOM::ExceptionOr<void> CanvasRenderingContext2D::arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise)
|
|
{
|
|
{
|
|
- ellipse(x, y, radius, radius, 0, start_angle, end_angle, counter_clockwise);
|
|
|
|
|
|
+ if (radius < 0)
|
|
|
|
+ return DOM::IndexSizeError::create(String::formatted("The radius provided ({}) is negative.", radius));
|
|
|
|
+ return ellipse(x, y, radius, radius, 0, start_angle, end_angle, counter_clockwise);
|
|
}
|
|
}
|
|
|
|
|
|
-void CanvasRenderingContext2D::ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise)
|
|
|
|
|
|
+DOM::ExceptionOr<void> CanvasRenderingContext2D::ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise)
|
|
{
|
|
{
|
|
|
|
+ if (radius_x < 0)
|
|
|
|
+ return DOM::IndexSizeError::create(String::formatted("The major-axis radius provided ({}) is negative.", radius_x));
|
|
|
|
+
|
|
|
|
+ if (radius_y < 0)
|
|
|
|
+ return DOM::IndexSizeError::create(String::formatted("The minor-axis radius provided ({}) is negative.", radius_y));
|
|
|
|
+
|
|
if ((!counter_clockwise && (end_angle - start_angle) >= M_TAU)
|
|
if ((!counter_clockwise && (end_angle - start_angle) >= M_TAU)
|
|
|| (counter_clockwise && (start_angle - end_angle) >= M_TAU)) {
|
|
|| (counter_clockwise && (start_angle - end_angle) >= M_TAU)) {
|
|
start_angle = 0;
|
|
start_angle = 0;
|
|
@@ -261,6 +269,7 @@ void CanvasRenderingContext2D::ellipse(float x, float y, float radius_x, float r
|
|
m_path.elliptical_arc_to(end_point, { radius_x, radius_y }, rotation, delta_theta > M_PI, !counter_clockwise);
|
|
m_path.elliptical_arc_to(end_point, { radius_x, radius_y }, rotation, delta_theta > M_PI, !counter_clockwise);
|
|
|
|
|
|
m_path.close();
|
|
m_path.close();
|
|
|
|
+ return {};
|
|
}
|
|
}
|
|
|
|
|
|
void CanvasRenderingContext2D::rect(float x, float y, float width, float height)
|
|
void CanvasRenderingContext2D::rect(float x, float y, float width, float height)
|