1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/test_2d.composite.clip.lighter.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<title>Canvas test: 2d.composite.clip.lighter</title> 1.6 +<!-- Testing: fill() does not affect pixels outside the clip region. --> 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 + 1.25 +SimpleTest.waitForExplicitFinish(); 1.26 +addLoadEvent(function () { 1.27 + 1.28 +var canvas = document.getElementById('c'); 1.29 +var ctx = canvas.getContext('2d'); 1.30 + 1.31 + 1.32 +ctx.fillStyle = '#0f0'; 1.33 +ctx.fillRect(0, 0, 100, 50); 1.34 +ctx.globalCompositeOperation = 'lighter'; 1.35 +ctx.rect(-20, -20, 10, 10); 1.36 +ctx.clip(); 1.37 +ctx.fillStyle = '#f00'; 1.38 +ctx.fillRect(0, 0, 50, 50); 1.39 +isPixel(ctx, 25,25, 0,255,0,255, "25,25", "0,255,0,255", 0); 1.40 +isPixel(ctx, 75,25, 0,255,0,255, "75,25", "0,255,0,255", 0); 1.41 + 1.42 +SimpleTest.finish(); 1.43 + 1.44 +}); 1.45 +</script> 1.46 +