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