Merge pull request #94 from puplakto/1d-to-2d

convert 1d index to 2d array
pull/96/head
Abdullah Alfaraj 2023-02-10 16:30:05 +03:00 committed by GitHub
commit f06f975bb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -107,6 +107,16 @@ async function unSelect() {
return result
}
/**
* Convert 1d index to 2d array
* @param {number} index sequential index
* @param {number} width width of 2d array
* @returns {number[]} [x,y]
*/
function indexToXY(index, width) {
return [index % width, Math.floor(index / width)]
}
// async function layerToSelectionHelper () {
// // console.log("executeAsModal layer.translate")