JavaScript绘制环形回路图形
直接上代码:
<!DOCTYPE html>
<html>
<head lang="zh">
<meta charset="UTF-8">
<title>456</title>
</head>
<body>
<div id="aaa"></div>
<script type="text/javascript">
var rows = 10, columns = 10;
var cs = [];
!function () {
for (var ri = 0; ri < rows; ri++) {
cs[ri] = [];
for (var ci = 0; ci < columns; ci++) {
cs[ri][ci] = 0;
}
}
console.log(cs);
for (var i = rows - 1; i > 0; i -= 2) {
console.log("i::::" + i);
dcs(i, i);
}
var csstr = "";
for (var idx = 0; idx < cs.length; idx++) {
csstr += "<p>";
csstr += cs[idx];
csstr += "</p>";
}
document.getElementById("aaa").innerHTML = csstr;
}();
function dcs(rowst, columnst) {
console.log(rowst + ":::::" + columnst);
var rr = rows - rowst;
for (var ri = rr; ri < rowst; ri++) {
console.log("rr::::" + rr + "ri::::" + ri);
cs[ri][rr] = 1;
cs[ri][columnst - 1] = 1;
}
var cc = columns - columnst;
for (var ci = cc; ci < columnst; ci++) {
console.log("cc::::" + cc + "ci::::" + ci);
cs[cc][ci] = 1;
cs[rowst - 1][ci] = 1;
}
}
</script>
</body>
</html>