mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:47:35 +00:00
LibWeb: Add canvas context2d roundRect
This commit is contained in:
parent
efadee7e6e
commit
b640747116
7 changed files with 231 additions and 4 deletions
40
Tests/LibWeb/Ref/canvas-path-rect.html
Normal file
40
Tests/LibWeb/Ref/canvas-path-rect.html
Normal file
|
@ -0,0 +1,40 @@
|
|||
<link rel="match" href="reference/canvas-path-rect-ref.html" />
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
}
|
||||
body {
|
||||
background-color: white;
|
||||
}
|
||||
</style>
|
||||
<canvas width=500 height=500></canvas>
|
||||
<script>
|
||||
function drawRect() {
|
||||
var canvas = document.querySelector("canvas");
|
||||
var ctx = canvas.getContext("2d");
|
||||
ctx.fillStyle = 'black';
|
||||
ctx.fillRect(0, 0, 500, 500);
|
||||
|
||||
ctx.fillStyle = 'red';
|
||||
ctx.beginPath();
|
||||
ctx.rect(10, 20, 150, 100);
|
||||
ctx.fill();
|
||||
|
||||
ctx.fillStyle = 'yellow';
|
||||
ctx.beginPath();
|
||||
ctx.roundRect(50, 310, 100, 100, 25);
|
||||
ctx.fill('evenodd');
|
||||
|
||||
ctx.fillStyle = 'green';
|
||||
ctx.beginPath();
|
||||
ctx.rect(200, 210, 100, 100);
|
||||
ctx.fill('evenodd');
|
||||
|
||||
ctx.rotate(0.2);
|
||||
ctx.fillStyle = 'orange';
|
||||
ctx.beginPath();
|
||||
ctx.roundRect(325, 300, 100, 100, [ { x: 5, y: 20 }, 10, { x: 15, y: 30 }, 20 ]);
|
||||
ctx.fill('evenodd');
|
||||
}
|
||||
drawRect();
|
||||
</script>
|
15
Tests/LibWeb/Ref/reference/canvas-path-rect-ref.html
Normal file
15
Tests/LibWeb/Ref/reference/canvas-path-rect-ref.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
}
|
||||
body {
|
||||
background-color: white;
|
||||
}
|
||||
</style>
|
||||
<!-- To rebase:
|
||||
1. Open canvas-path-rect.html in Ladybird
|
||||
2. Resize the window just above the width of the canvas
|
||||
3. Right click > "Take Full Screenshot"
|
||||
4. Update the image below:
|
||||
-->
|
||||
<img src="./images/canvas-path-rect-ref.png">
|
BIN
Tests/LibWeb/Ref/reference/images/canvas-path-rect-ref.png
Normal file
BIN
Tests/LibWeb/Ref/reference/images/canvas-path-rect-ref.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Loading…
Add table
Add a link
Reference in a new issue