CSS21-t100303-make-images.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html lang="en-US">
  4. <head>
  5. <title></title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <meta http-equiv="Content-Script-Type" content="text/javascript">
  8. <script type="text/javascript">
  9. var gWidth = 1024;
  10. var gHeight = 1;
  11. var gBarriers = [ 170, 334, 340, 344, 350, 458 ];
  12. var gColors = [ "green", "red" ];
  13. function append_url(filename, contents_url) {
  14. var p = document.createElement("p");
  15. var a = document.createElement("a");
  16. a.href = contents_url;
  17. var t = document.createTextNode("CSS21-t100303-" + filename);
  18. a.appendChild(t);
  19. p.appendChild(a);
  20. document.body.appendChild(p);
  21. }
  22. function run() {
  23. var canvas = document.getElementById("canvas");
  24. var cx = canvas.getContext("2d");
  25. for (var i in gBarriers) {
  26. var barrier = gBarriers[i];
  27. cx.fillStyle = gColors[1];
  28. cx.fillRect(0, 0, gWidth, gHeight);
  29. cx.fillStyle = gColors[0];
  30. cx.fillRect(0, 0, barrier, gHeight);
  31. append_url(gColors[0] + "-in-" + barrier + "px.png",
  32. canvas.toDataURL("image/png"));
  33. cx.fillStyle = gColors[0];
  34. cx.fillRect(0, 0, gWidth, gHeight);
  35. cx.fillStyle = gColors[1];
  36. cx.fillRect(0, 0, barrier, gHeight);
  37. append_url(gColors[0] + "-outside-" + barrier + "px.png",
  38. canvas.toDataURL("image/png"));
  39. }
  40. }
  41. </script>
  42. </head>
  43. <body onload="run()">
  44. <canvas width="1024" height="1" id="canvas"></canvas>
  45. </body>
  46. </html>