Refactor: Implement SmartCube renderer, improve UI styling, and fix gaps
This commit is contained in:
43
node_modules/matrix-js/lib/generate.js
generated
vendored
Normal file
43
node_modules/matrix-js/lib/generate.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
function generate(val) {
|
||||
return {
|
||||
size: (row, col) => size(val, row, col),
|
||||
diag: (row, col) => diag(val, row, col)
|
||||
}
|
||||
}
|
||||
|
||||
function size(val, row, col) {
|
||||
if (!col) {
|
||||
col = row;
|
||||
}
|
||||
let rows = [];
|
||||
for (let i = 0; i < row; i++) {
|
||||
let cols = [];
|
||||
for (let j = 0; j < col; j++) {
|
||||
cols[j] = val || Math.random();
|
||||
}
|
||||
rows[i] = cols;
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
function diag(val, row, col) {
|
||||
if (!col) {
|
||||
col = row;
|
||||
}
|
||||
let rows = [];
|
||||
for (let i = 0; i < row; i++) {
|
||||
let cols = [];
|
||||
for (let j = 0; j < col; j++) {
|
||||
cols[j] = 0;
|
||||
}
|
||||
rows[i] = cols;
|
||||
if (i < col || row == col) {
|
||||
rows[i][i] = val || Math.random();
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
module.exports = generate;
|
||||
Reference in New Issue
Block a user