@@ -107,12 +107,18 @@ WebIDL::ExceptionOr<void> CanvasPath::ellipse(float x, float y, float radius_x,
107
107
if (radius_y < 0 )
108
108
return WebIDL::IndexSizeError::create (m_self->realm (), MUST (String::formatted (" The minor-axis radius provided ({}) is negative." , radius_y)));
109
109
110
+ // "If counterclockwise is false and endAngle − startAngle is greater than or equal to 2π,
111
+ // or, if counterclockwise is true and startAngle − endAngle is greater than or equal to 2π,
112
+ // then the arc is the whole circumference of this ellipse"
113
+ // Also draw the full ellipse if making a non-zero whole number of turns.
110
114
if (constexpr float tau = M_PI * 2 ; (!counter_clockwise && (end_angle - start_angle) >= tau)
111
- || (counter_clockwise && (start_angle - end_angle) >= tau)) {
115
+ || (counter_clockwise && (start_angle - end_angle) >= tau)
116
+ || (start_angle != end_angle && fmodf (start_angle - end_angle, tau) == 0 )) {
112
117
start_angle = 0 ;
113
118
// FIXME: elliptical_arc_to() incorrectly handles the case where the start/end points are very close.
114
119
// So we slightly fudge the numbers here to correct for that.
115
120
end_angle = tau * 0 .9999f ;
121
+ counter_clockwise = false ;
116
122
} else {
117
123
start_angle = fmodf (start_angle, tau);
118
124
end_angle = fmodf (end_angle, tau);
@@ -154,7 +160,13 @@ WebIDL::ExceptionOr<void> CanvasPath::ellipse(float x, float y, float radius_x,
154
160
auto start_point = resolve_point_with_angle (start_angle);
155
161
auto end_point = resolve_point_with_angle (end_angle);
156
162
157
- auto delta_theta = end_angle - start_angle;
163
+ float delta_theta;
164
+ if (counter_clockwise) {
165
+ delta_theta = start_angle - end_angle;
166
+ } else {
167
+ delta_theta = end_angle - start_angle;
168
+ }
169
+
158
170
if (delta_theta < 0 )
159
171
delta_theta += AK::Pi<float > * 2 ;
160
172
0 commit comments