OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <pre id="result"></pre> |
| 5 <canvas id="canvas" width="100" height="50"></canvas> |
| 6 <script> |
| 7 if (window.testRunner) |
| 8 testRunner.dumpAsText(); |
| 9 |
| 10 var canvas = document.getElementById('canvas'); |
| 11 var ctx = canvas.getContext("2d"); |
| 12 for (var i = 0; i < 30; i += 5) { |
| 13 ctx.fillStyle = 'rgba(1, 3, 254, 1)'; |
| 14 ctx.fillRect( 0 + i, i, 25, 25); |
| 15 ctx.fillStyle = 'rgba(8, 252, 248, 0.75)'; |
| 16 ctx.fillRect(25 + i, i, 25, 25); |
| 17 ctx.fillStyle = 'rgba(6, 10, 250, 0.502)'; |
| 18 ctx.fillRect(50 - i, i, 25, 25); |
| 19 ctx.fillRect(50 + i, i, 25, 25); |
| 20 ctx.fillStyle = 'rgba(12, 16, 244, 0.25)'; |
| 21 ctx.fillRect(75 - i, i, 25, 25); |
| 22 ctx.fillRect(75 + i, i, 25, 25); |
| 23 } |
| 24 |
| 25 function dataURLLength(compression) { |
| 26 var length = canvas.toDataURL("image/png", compression).length; |
| 27 result.textContent += compression.toFixed(1) + ' '; |
| 28 result.textContent += 'toDataURL image/png length ' + length + '\n'; |
| 29 return length; |
| 30 } |
| 31 |
| 32 var length3 = dataURLLength(0.3); |
| 33 var length9 = dataURLLength(0.9); |
| 34 |
| 35 result.textContent += (length9 < length3 * 0.7) ? "\nPASS" : "\nFAIL"; |
| 36 </script> |
| 37 </body> |
| 38 <html> |
OLD | NEW |