3 <script type=
"application/x-javascript">
4 function createImage() {
5 var image = document.createElement('canvas');
8 // We use this to colour the individual pixels
9 var dotter = image.getContext('
2d').createImageData(
1,
1);
11 // Colour the black pixesl.
16 image.getContext('
2d').putImageData(dotter,
0,
0);
17 image.getContext('
2d').putImageData(dotter,
1,
1);
19 // Colour the white pixels.
24 image.getContext('
2d').putImageData(dotter,
1,
0);
25 image.getContext('
2d').putImageData(dotter,
0,
1);
29 function drawFillRect(canvas, image, smoothing) {
30 var ctx = canvas.getContext('
2d');
31 var pattern = ctx.createPattern(image,
"repeat");
32 ctx.fillStyle = pattern;
33 ctx.imageSmoothingEnabled = smoothing;
35 ctx.fillRect(
0,
0, canvas.width, canvas.height);
38 function drawFill(canvas, image, smoothing) {
39 var ctx = canvas.getContext('
2d');
40 var pattern = ctx.createPattern(image,
"repeat");
41 ctx.fillStyle = pattern;
42 ctx.imageSmoothingEnabled = smoothing;
51 function drawStroke(canvas, image, smoothing) {
52 var ctx = canvas.getContext('
2d');
53 var pattern = ctx.createPattern(image,
"repeat");
54 ctx.strokeStyle = pattern;
56 ctx.imageSmoothingEnabled = smoothing;
65 if (window.testRunner)
66 testRunner.dumpAsTextWithPixelResults();
68 var image = createImage();
69 drawFillRect(document.getElementById('unsmoothedFillRect'), image,
71 drawFillRect(document.getElementById('smoothedFillRect'), image,
73 drawFill(document.getElementById('unsmoothedFill'), image,
75 drawFill(document.getElementById('smoothedFill'), image,
77 drawStroke(document.getElementById('unsmoothedStroke'), image,
79 drawStroke(document.getElementById('smoothedStroke'), image,
85 <body onload=
"draw()">
87 <canvas id=
"unsmoothedFillRect" width=
"100" height=
"100"></canvas>
88 <canvas id=
"smoothedFillRect" width =
"100" height=
"100"></canvas>
91 <canvas id=
"unsmoothedFill" width=
"100" height=
"100"></canvas>
92 <canvas id=
"smoothedFill" width =
"100" height=
"100"></canvas>
95 <canvas id=
"unsmoothedStroke" width=
"100" height=
"100"></canvas>
96 <canvas id=
"smoothedStroke" width =
"100" height=
"100"></canvas>