summaryrefslogtreecommitdiff
path: root/Base/home/anon
diff options
context:
space:
mode:
authorBrian Gianforcaro <b.gianfo@gmail.com>2020-04-07 01:09:17 -0700
committerAndreas Kling <kling@serenityos.org>2020-04-08 11:07:50 +0200
commit39855fe9ef924a1cd46b64489fc5738d32b93363 (patch)
tree66337729cbb6b58eef89cb76b56a821810623bb4 /Base/home/anon
parent7291d5c86f0a8ab364aed8e5e4a99b3928d0ae91 (diff)
downloadserenity-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')
-rw-r--r--Base/home/anon/www/canvas.html16
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>