GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ---/Imagemosaic.html at master · softdyp/--- Expand file tree/ Copy pathImagemosaic.htmlMore file actions 115 lines (80 loc) · 3.03 KB / Copy pathImagemosaic.htmlFile metadata and controls115 lines (80 loc) · 3.03 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>my web</title> <style> body { background:black; color: white; font-size:30px; } #c1 { background:white; } span { color:white; } </style> <script> window.onload = function() { var oC = document.getElementById('c1'); var oGC = oC.getContext('2d'); var yImg = new Image(); yImg.onload = function() { draw(this); }; yImg.src = '1.png'; function draw(obj) { oC.width = obj.width; oC.height = obj.height*2; oGC.drawImage(obj, 0, 0); var oImg = oGC.getImageData(0, 0, obj.width, obj.height); var w = oImg.width; var h = oImg.height; var num = 5;//越小越清晰 var newImg = oGC.createImageData(obj.width, obj.height); var stepW = w/num; var stepH = h/num; for (var i = 0; i<stepH; i++) { for (var j = 0; j <stepW; j++) { var color = getXY(oImg, j*num+ Math.floor(Math.random()*num), i*num+Math.floor(Math.random() * num)); for (var k=0;k<num;k++) { for (var l = 0; l < num; l++) { setXY(newImg, j * num + l, i * num + k, color); } } } } oGC.putImageData(newImg, 0, obj.height); } function getXY(obj, x, y) { //针对一行一列进行操作 var w = obj.width; var h = obj.color; var d = obj.data; var color = []; color[0] = d[4 * (y * w + x)]; color[1] = d[4 * (y * w + x) + 1]; color[2] = d[4 * (y * w + x) + 2]; color[3] = d[4 * (y * w + x) + 3]; return color; } function setXY(obj, x, y, color) { var w = obj.width; var h = obj.color; var d = obj.data; d[4 * (y * w + x)] = color[0]; d[4 * (y * w + x) + 1] = color[1]; d[4 * (y * w + x) + 2] = color[2]; d[4 * (y * w + x) + 3] = color[3]; } }; </script> </head> <body> <canvas id="c1" width="400" height="800"> <span>不支持canva的浏览器</span> </canvas> <!-- 默认宽300,高150--> </body> </html> |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |