1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/test_2d.path.arc.shape.3.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<title>Canvas test: 2d.path.arc.shape.3</title> 1.6 +<!-- Testing: arc() from 0 to -pi/2 does not draw anything in the wrong quadrant --> 1.7 +<script src="/tests/SimpleTest/SimpleTest.js"></script> 1.8 +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> 1.9 +<body> 1.10 +<canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> 1.11 +<script> 1.12 +function isPixel(ctx, x,y, r,g,b,a, pos, colour, d) { 1.13 + var pixel = ctx.getImageData(x, y, 1, 1); 1.14 + var pr = pixel.data[0], 1.15 + pg = pixel.data[1], 1.16 + pb = pixel.data[2], 1.17 + pa = pixel.data[3]; 1.18 + ok(r-d <= pr && pr <= r+d && 1.19 + g-d <= pg && pg <= g+d && 1.20 + b-d <= pb && pb <= b+d && 1.21 + a-d <= pa && pa <= a+d, 1.22 + "pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d); 1.23 +} 1.24 +function todo_isPixel(ctx, x,y, r,g,b,a, pos, colour, d) { 1.25 + var pixel = ctx.getImageData(x, y, 1, 1); 1.26 + var pr = pixel.data[0], 1.27 + pg = pixel.data[1], 1.28 + pb = pixel.data[2], 1.29 + pa = pixel.data[3]; 1.30 + todo(r-d <= pr && pr <= r+d && 1.31 + g-d <= pg && pg <= g+d && 1.32 + b-d <= pb && pb <= b+d && 1.33 + a-d <= pa && pa <= a+d, 1.34 + "pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d); 1.35 +} 1.36 + 1.37 +SimpleTest.waitForExplicitFinish(); 1.38 +addLoadEvent(function () { 1.39 + 1.40 +var canvas = document.getElementById('c'); 1.41 +var ctx = canvas.getContext('2d'); 1.42 + 1.43 +ctx.fillStyle = '#0f0'; 1.44 +ctx.fillRect(0, 0, 100, 50); 1.45 +ctx.lineWidth = 100; 1.46 +ctx.strokeStyle = '#f00'; 1.47 +ctx.beginPath(); 1.48 +ctx.arc(0, 50, 50, 0, -Math.PI/2, false); 1.49 +ctx.stroke(); 1.50 +isPixel(ctx, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 0); 1.51 +isPixel(ctx, 1,1, 0,255,0,255, "1,1", "0,255,0,255", 0); 1.52 +isPixel(ctx, 98,1, 0,255,0,255, "98,1", "0,255,0,255", 0); 1.53 +isPixel(ctx, 1,48, 0,255,0,255, "1,48", "0,255,0,255", 0); 1.54 +isPixel(ctx, 98,48, 0,255,0,255, "98,48", "0,255,0,255", 0); 1.55 + 1.56 +SimpleTest.finish(); 1.57 + 1.58 +}); 1.59 +</script> 1.60 +