mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-07-11 14:34:51 +00:00
wip
This commit is contained in:
parent
7de0355f3a
commit
ee6ff28af5
11 changed files with 157 additions and 95 deletions
|
|
@ -1,48 +0,0 @@
|
|||
export function rotateHeightMap(
|
||||
src: Uint16Array,
|
||||
width: number,
|
||||
height: number,
|
||||
degrees: 90 | 180 | 270
|
||||
) {
|
||||
let outW: number;
|
||||
let outH: number;
|
||||
|
||||
switch (degrees) {
|
||||
case 90:
|
||||
case 270:
|
||||
outW = height;
|
||||
outH = width;
|
||||
break;
|
||||
case 180:
|
||||
outW = width;
|
||||
outH = height;
|
||||
break;
|
||||
}
|
||||
|
||||
const out = new Uint16Array(outW * outH);
|
||||
|
||||
for (let y = 0; y < height; y++) {
|
||||
for (let x = 0; x < width; x++) {
|
||||
const val = src[y * width + x];
|
||||
|
||||
let nx, ny;
|
||||
switch (degrees) {
|
||||
case 90:
|
||||
nx = height - 1 - y;
|
||||
ny = x;
|
||||
break;
|
||||
case 180:
|
||||
nx = width - 1 - x;
|
||||
ny = height - 1 - y;
|
||||
break;
|
||||
case 270:
|
||||
nx = y;
|
||||
ny = width - 1 - x;
|
||||
}
|
||||
|
||||
out[ny * outW + nx] = val;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
@ -1,3 +1,8 @@
|
|||
export function normalize(pathString: string) {
|
||||
/**
|
||||
* Normalizes a path string, but not as complicated as Node's `path.normalize`.
|
||||
* This simply changes all backslashes to `/` (regardless of platform) and
|
||||
* collapses any adjacent slashes to a single slash.
|
||||
*/
|
||||
export function normalizePath(pathString: string) {
|
||||
return pathString.replace(/\\/g, "/").replace(/\/+/g, "/");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue