mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-10 13:12:56 +00:00
LibWeb: Normalize the angle delta in CanvasPath::ellipse()
This fixes both the incorrect arc and ellipse from #22817.
This commit is contained in:
parent
b31fb36ed3
commit
c6899b79b6
Notes:
sideshowbarker
2024-07-17 02:56:25 +09:00
Author: https://github.com/MacDue
Commit: c6899b79b6
Pull-request: https://github.com/SerenityOS/serenity/pull/23701
4 changed files with 33 additions and 0 deletions
22
Tests/LibWeb/Ref/canvas-arcs-and-ellipses.html
Normal file
22
Tests/LibWeb/Ref/canvas-arcs-and-ellipses.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<link rel="match" href="reference/canvas-arcs-and-ellipses-ref.html" />
|
||||||
|
<style>
|
||||||
|
canvas {
|
||||||
|
border: 1px solid black;
|
||||||
|
image-rendering: pixelated;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<canvas id="canvas" width="125" height="125"></canvas>
|
||||||
|
<script>
|
||||||
|
const canvas = document.getElementById("canvas")
|
||||||
|
|
||||||
|
const context = canvas.getContext("2d");
|
||||||
|
context.beginPath();
|
||||||
|
context.arc(59, 55, 38, 5.3849570248895775, 2.9421639085067177);
|
||||||
|
context.stroke();
|
||||||
|
context.fill();
|
||||||
|
|
||||||
|
context.beginPath();
|
||||||
|
context.ellipse(20,20,15,8,1.2273132071162383,4.1926143018618225,2.8853539230051624);
|
||||||
|
context.stroke();
|
||||||
|
context.fill();
|
||||||
|
</script>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<img src="./images/canvas-arcs-and-ellipses-ref.png">
|
Binary file not shown.
After Width: | Height: | Size: 999 B |
|
@ -157,6 +157,8 @@ WebIDL::ExceptionOr<void> CanvasPath::ellipse(float x, float y, float radius_x,
|
||||||
auto end_point = resolve_point_with_angle(end_angle);
|
auto end_point = resolve_point_with_angle(end_angle);
|
||||||
|
|
||||||
auto delta_theta = end_angle - start_angle;
|
auto delta_theta = end_angle - start_angle;
|
||||||
|
if (delta_theta < 0)
|
||||||
|
delta_theta += AK::Pi<float> * 2;
|
||||||
|
|
||||||
auto transform = active_transform();
|
auto transform = active_transform();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue