2 <title>Canvas test:
2d.line.join.miter
</title>
3 <!-- Testing: lineJoin 'miter' is rendered correctly -->
4 <script src=
"/MochiKit/MochiKit.js"></script>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
8 <canvas id=
"c" width=
"100" height=
"50"><p class=
"fallback">FAIL (fallback content)
</p></canvas>
10 function isPixel(ctx
, x
,y
, r
,g
,b
,a
, pos
, colour
, d
) {
11 var pixel
= ctx
.getImageData(x
, y
, 1, 1);
12 var pr
= pixel
.data
[0],
16 ok(r
-d
<= pr
&& pr
<= r
+d
&&
17 g
-d
<= pg
&& pg
<= g
+d
&&
18 b
-d
<= pb
&& pb
<= b
+d
&&
19 a
-d
<= pa
&& pa
<= a
+d
,
20 "pixel "+pos
+" is "+pr
+","+pg
+","+pb
+","+pa
+"; expected "+colour
+" +/- "+d
);
23 SimpleTest
.waitForExplicitFinish();
24 MochiKit
.DOM
.addLoadEvent(function () {
26 var canvas
= document
.getElementById('c');
27 var ctx
= canvas
.getContext('2d');
29 ctx
.fillStyle
= '#0f0';
30 ctx
.fillRect(0, 0, 100, 50);
32 ctx
.lineJoin
= 'miter';
35 ctx
.fillStyle
= '#f00';
36 ctx
.strokeStyle
= '#0f0';
38 ctx
.fillStyle
= '#f00';
39 ctx
.strokeStyle
= '#0f0';
41 ctx
.fillRect(10, 10, 30, 20);
42 ctx
.fillRect(20, 10, 20, 30);
51 ctx
.fillStyle
= '#0f0';
52 ctx
.strokeStyle
= '#f00';
60 ctx
.fillRect(60, 10, 30, 20);
61 ctx
.fillRect(70, 10, 20, 30);
63 isPixel(ctx
, 38,12, 0,255,0,255, "38,12", "0,255,0,255", 0);
64 isPixel(ctx
, 39,11, 0,255,0,255, "39,11", "0,255,0,255", 0);
65 isPixel(ctx
, 40,10, 0,255,0,255, "40,10", "0,255,0,255", 0);
66 isPixel(ctx
, 41,9, 0,255,0,255, "41,9", "0,255,0,255", 0);
67 isPixel(ctx
, 42,8, 0,255,0,255, "42,8", "0,255,0,255", 0);
69 isPixel(ctx
, 88,12, 0,255,0,255, "88,12", "0,255,0,255", 0);
70 isPixel(ctx
, 89,11, 0,255,0,255, "89,11", "0,255,0,255", 0);
71 isPixel(ctx
, 90,10, 0,255,0,255, "90,10", "0,255,0,255", 0);
72 isPixel(ctx
, 91,9, 0,255,0,255, "91,9", "0,255,0,255", 0);
73 isPixel(ctx
, 92,8, 0,255,0,255, "92,8", "0,255,0,255", 0);