| <!DOCTYPE html> |
| <title>Canvas test: toDataURL.png.primarycolours</title> |
| <script src="../tests.js"></script> |
| <link rel="stylesheet" href="../tests.css"> |
| <link rel="prev" href="toDataURL.zerosize.html" title="toDataURL.zerosize"> |
| <link rel="next" href="toDataURL.png.complexcolours.html" title="toDataURL.png.complexcolours"> |
| <body class="show_output"> |
| <p> |
| <a href="toDataURL.zerosize.html" accesskey="p" title="[p] toDataURL.zerosize"><</a> |
| <a href="index.html">[index]</a> |
| <a href="toDataURL.png.complexcolours.html" accesskey="n" title="[n] toDataURL.png.complexcolours">></a> |
| <h1><a href="index.toDataURL.html">toDataURL</a>.<a href="index.toDataURL.png.html">png</a>.primarycolours</h1> |
| <p class="desc">toDataURL with PNG handles simple colours correctly</p> |
| <div class="refs">References: |
| <ul> |
| <li><a href="spec.html#testrefs.toDataURL.png">toDataURL.png</a> |
| |
| </ul> |
| </div> |
| |
| <p class="output">Actual output:</p> |
| <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> |
| <p class="output expectedtext">Expected output:<p><img src="toDataURL.png.primarycolours.png" class="output expected" id="expected" alt=""> |
| <ul id="d"></ul> |
| <script> |
| _addTest(function(canvas, ctx) { |
| |
| ctx.fillStyle = '#ff0'; |
| ctx.fillRect(0, 0, 25, 40); |
| ctx.fillStyle = '#0ff'; |
| ctx.fillRect(25, 0, 50, 40); |
| ctx.fillStyle = '#00f'; |
| ctx.fillRect(75, 0, 25, 40); |
| ctx.fillStyle = '#fff'; |
| ctx.fillRect(0, 40, 100, 10); |
| var data = canvas.toDataURL(); |
| ctx.fillStyle = '#f00'; |
| ctx.fillRect(0, 0, 100, 50); |
| var img = new Image(); |
| deferTest(); |
| img.onload = wrapFunction(function () |
| { |
| ctx.drawImage(img, 0, 0); |
| |
| _assertPixel(canvas, 12,20, 255,255,0,255, "12,20", "255,255,0,255"); |
| _assertPixel(canvas, 50,20, 0,255,255,255, "50,20", "0,255,255,255"); |
| _assertPixel(canvas, 87,20, 0,0,255,255, "87,20", "0,0,255,255"); |
| _assertPixel(canvas, 50,45, 255,255,255,255, "50,45", "255,255,255,255"); |
| }); |
| img.src = data; |
| |
| |
| }); |
| </script> |
| |