diff options
author | Brian Gianforcaro <b.gianfo@gmail.com> | 2020-04-07 01:09:17 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-08 11:07:50 +0200 |
commit | 39855fe9ef924a1cd46b64489fc5738d32b93363 (patch) | |
tree | 66337729cbb6b58eef89cb76b56a821810623bb4 /Base/home/anon/www/canvas.html | |
parent | 7291d5c86f0a8ab364aed8e5e4a99b3928d0ae91 (diff) | |
download | serenity-39855fe9ef924a1cd46b64489fc5738d32b93363.zip |
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().
Diffstat (limited to 'Base/home/anon/www/canvas.html')
-rw-r--r-- | Base/home/anon/www/canvas.html | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Base/home/anon/www/canvas.html b/Base/home/anon/www/canvas.html index b82f553315..8d277ae9b8 100644 --- a/Base/home/anon/www/canvas.html +++ b/Base/home/anon/www/canvas.html @@ -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> |