orz像素脸图。。。

烁灵 posted @ 2015年7月15日 15:58 in 前端 with tags javascript html5 脑壳 , 2634 阅读

随机对称生成的脸图【?】

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>orz</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="stylesheet">
</head>
<body style="text-align:center;background-color:#1e576b">
	<div>
		<input type="text" id="dim" placeholder="dim"/>
		<input type="button" id="submit" value="submit"/>
	</div>
	<div style="margin:1em"><canvas id="logoCanvas"></canvas></div>
</body>
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>

<script type="text/javascript">
	function draw(w, h) {
		
		var w = w || 8;
		var h = h || 8;
		var border = 12;
		var val = [];
		for (var i = 0; i < h; i += 1) {
			var str = [];
			for (var j = 0; j < w / 2; j += 1) {
				var rand = parseInt(Math.random() * 2);
				str[j] = rand;
				str[w - j] = rand;
			}
			val.push(str.join(""));
			console.log(str.join(""));
		}
		
		var canvas=document.getElementById('logoCanvas');
		var fillWidth = border * w;
		var fillHeight = border * h;
		$(canvas).attr("height", fillHeight + "px");
		$(canvas).attr("width", fillWidth + "px");
		var ctx=canvas.getContext('2d');
		ctx.clearRect(0, 0, fillWidth, fillHeight);
		for (var y = 0; y < h; y += 1) {
			for (var x = 0; x < w; x += 1) {
				ctx.fillStyle= val[y][x] == "1" ? '#000' : '#FFF';
				console.log("x y v, %d %d %s", x, y, val[y][x]);
				ctx.fillRect(x * border, y * border, border, border);
			}
		}
	}
	$(document).ready(function() {
		draw();
		$("#submit").click(function(){
			var d = $("#dim").val();
			draw(d, d);
		});
	});

</script>
</html>

唔……

 

 

Avatar_small
Bank of India net ba 说:
2022年8月01日 14:49

Do you have an account in Bank of India, If yes, then you might be happy because of the features and services of BOI which they provide to their customers. BOI allow their customers to register for Internet banking online with new requirements?With this, Bank of India net banking services, customer of BOI can access the complete banking services in online to transfer the funds, Bank of India net banking login generate statements, personalized view of account or more. After registration, you can reset BOI login password online if required too. These are some basic points that need to check before going for online registration of Bank of India internet banking facility, which we are going to discuss below from BOI history.

Avatar_small
pavzi.com 说:
2024年1月05日 00:53

Pavzi website is a multiple Niche or category website which will ensure to provide information and resources on each and every topic. Some of the evergreen topics you will see on our website are Career, Job Recruitment, Educational, Technology, Reviews and others. pavzi.com We are targeting mostly so it is true that Tech, Finance, and Product Reviews. The only reason we have started this website is to make this site the need for your daily search use.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter