summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-paint-api/hidpi/canvas-reset-ref.html
blob: 24cab5da54d010ec3506ef6b8d9b310b745a2c2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html>
<html>
<body>
<canvas id ="canvas"></canvas>
<script>
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext("2d");

// Adjust the canvas to get highdpi rendering.
canvas.style.width = '270px';
canvas.style.height = '275px';
canvas.width = 270 * devicePixelRatio;
canvas.height = 275 * devicePixelRatio;
ctx.scale(devicePixelRatio, devicePixelRatio);

var fillW = 250;
var fillH = 50;
ctx.beginPath();
ctx.rect(0, 0, fillW, fillH);
ctx.closePath();
ctx.clip();
ctx.fillStyle = 'green';
ctx.fillRect(0, 0, fillW, fillH);
</script>
</body>
</html>