blob: 963c9b472beef3ff35d8d2bd18b5c6fde85f315e (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<!DOCTYPE html>
<style>
canvas {
width: 100px;
height: 100px;
image-rendering: pixelated;
}
</style>
<body>
<!-- Draw to a canvas already in the DOM. -->
<!-- The resulting image should be 100x100, consisting of 4 50x50 blocks of solid color, with no blurring of edges -->
<canvas width="2" height="2"></canvas>
</body>
<script>
// Ignore the render tree.
if (window.testRunner)
window.testRunner.dumpAsTextWithPixelResults();
var canvas = document.getElementsByTagName("canvas")[0];
var context = canvas.getContext("2d");
var imageHandle = context.createImageData(canvas.width, canvas.height);
var index = 0;
imageHandle.data[index++] = 255;
imageHandle.data[index++] = 0;
imageHandle.data[index++] = 0;
imageHandle.data[index++] = 255;
imageHandle.data[index++] = 0;
imageHandle.data[index++] = 255;
imageHandle.data[index++] = 0;
imageHandle.data[index++] = 255;
imageHandle.data[index++] = 0;
imageHandle.data[index++] = 0;
imageHandle.data[index++] = 255;
imageHandle.data[index++] = 255;
imageHandle.data[index++] = 0;
imageHandle.data[index++] = 0;
imageHandle.data[index++] = 0;
imageHandle.data[index++] = 255;
context.putImageData(imageHandle, 0, 0);
</script>
|