1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/test_2d.composite.uncovered.fill.source-out.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<title>Canvas test: 2d.composite.uncovered.fill.source-out</title> 1.6 +<!-- Testing: fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. --> 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 + 1.44 +ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; 1.45 +ctx.fillRect(0, 0, 100, 50); 1.46 +ctx.globalCompositeOperation = 'source-out'; 1.47 +ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; 1.48 +ctx.translate(0, 25); 1.49 +ctx.fillRect(0, 50, 100, 50); 1.50 +isPixel(ctx, 50,25, 0,0,0,0, "50,25", "0,0,0,0", 5); 1.51 + 1.52 +SimpleTest.finish(); 1.53 + 1.54 +}); 1.55 +</script> 1.56 +