Last active
August 26, 2016 08:43
-
-
Save wowiwo1/b07caf19e410ee83cbabe4b1424eafbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mat_make(width, height, peak, way) | |
{ | |
var arr = [] | |
var ret = [] | |
for (var i = 0; i < height; i++) | |
ret[i] = [] | |
// init | |
for (var i = 0; i < width * height; i++) | |
arr.push('A'.charCodeAt(0)) | |
// calc | |
for (var i = 0; i < width * height; i++) | |
{ | |
if (i <= peak) | |
arr[i] += i | |
else if (i - 2 * peak < 0) | |
arr[i] += 2 * peak - i | |
} | |
// assemble | |
for (var j = 0; j < height; j++) | |
for (var i = 0; i < width; i++) | |
ret[j][i] = String.fromCharCode((way) ? arr[j + i * height] : arr[i + j * width]) | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment