1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

LibWeb: Add canvas.strokeRect(), and fix scale & translate

Add an implementation of CanvasRenderingContext2DWrapper.strokeRect().
While implementing this I fixed fillRect() and the new strokeRect() to
honor the .scale() and .translate() values that had previously been plumbed.

Also enhance the canvas.html demo to utilize strokeRect(), scale(), and translate().
This commit is contained in:
Brian Gianforcaro 2020-04-07 01:09:17 -07:00 committed by Andreas Kling
parent 7291d5c86f
commit 39855fe9ef
5 changed files with 80 additions and 3 deletions

View file

@ -16,8 +16,20 @@ canvas {
<script>
document.addEventListener("DOMContentLoaded", function() {
ctx = document.getElementById("foo").getContext("2d");
ctx.fillStyle = 'red';
ctx.fillRect(10, 10, 200, 100);
var width = 200;
var height = 100;
for (var i = 0; i < 2; i++)
{
ctx.fillStyle = 'red';
ctx.fillRect(10, 10, width, height);
ctx.strokeStyle = 'blue';
ctx.strokeRect(10, 10, width, height);
ctx.scale(0.5, 0.5);
ctx.translate(10 + width * 2, 10 + height * 2);
}
});
</script>
</head>