content/canvas/test/test_2d.composite.uncovered.fill.color-burn.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <title>Canvas test: 2d.composite.uncovered.fill.source-out</title>
michael@0 3 <!-- Testing: fill() draws pixels not covered by the source object as (0,0,0,0), and does not leave the pixels unchanged. -->
michael@0 4 <script src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 5 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
michael@0 6 <body>
michael@0 7 <canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
michael@0 8 <script>
michael@0 9 function isPixel(ctx, x,y, r,g,b,a, pos, colour, d) {
michael@0 10 var pixel = ctx.getImageData(x, y, 1, 1);
michael@0 11 var pr = pixel.data[0],
michael@0 12 pg = pixel.data[1],
michael@0 13 pb = pixel.data[2],
michael@0 14 pa = pixel.data[3];
michael@0 15 ok(r-d <= pr && pr <= r+d &&
michael@0 16 g-d <= pg && pg <= g+d &&
michael@0 17 b-d <= pb && pb <= b+d &&
michael@0 18 a-d <= pa && pa <= a+d,
michael@0 19 "pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
michael@0 20 }
michael@0 21 function todo_isPixel(ctx, x,y, r,g,b,a, pos, colour, d) {
michael@0 22 var pixel = ctx.getImageData(x, y, 1, 1);
michael@0 23 var pr = pixel.data[0],
michael@0 24 pg = pixel.data[1],
michael@0 25 pb = pixel.data[2],
michael@0 26 pa = pixel.data[3];
michael@0 27 todo(r-d <= pr && pr <= r+d &&
michael@0 28 g-d <= pg && pg <= g+d &&
michael@0 29 b-d <= pb && pb <= b+d &&
michael@0 30 a-d <= pa && pa <= a+d,
michael@0 31 "pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
michael@0 32 }
michael@0 33
michael@0 34 SimpleTest.waitForExplicitFinish();
michael@0 35 addLoadEvent(function () {
michael@0 36
michael@0 37 var canvas = document.getElementById('c');
michael@0 38 var ctx = canvas.getContext('2d');
michael@0 39
michael@0 40
michael@0 41 ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
michael@0 42 ctx.fillRect(0, 0, 100, 50);
michael@0 43 ctx.globalCompositeOperation = 'color-burn';
michael@0 44 ctx.fillStyle = 'rgba(0, 0, 255, 0.75)';
michael@0 45 ctx.translate(0, 25);
michael@0 46 ctx.fillRect(0, 50, 100, 50);
michael@0 47 isPixel(ctx, 50,25, 0,255,0,128, "50,25", "0,255,0,128", 5);
michael@0 48
michael@0 49 SimpleTest.finish();
michael@0 50
michael@0 51 });
michael@0 52 </script>
michael@0 53

mercurial