1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/test_2d.composite.transparent.xor.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<title>Canvas test: 2d.composite.transparent.xor</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 + 1.24 +SimpleTest.waitForExplicitFinish(); 1.25 +addLoadEvent(function () { 1.26 + 1.27 +var canvas = document.getElementById('c'); 1.28 +var ctx = canvas.getContext('2d'); 1.29 + 1.30 + 1.31 +ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; 1.32 +ctx.fillRect(0, 0, 100, 50); 1.33 +ctx.globalCompositeOperation = 'xor'; 1.34 +ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; 1.35 +ctx.fillRect(0, 0, 100, 50); 1.36 +isPixel(ctx, 50,25, 0,63,191,127, "50,25", "0,63,191,127", 5); 1.37 + 1.38 +SimpleTest.finish(); 1.39 + 1.40 +}); 1.41 +</script> 1.42 +