diff --git a/notes.md b/notes.md index 0b950923..256c4d8e 100644 --- a/notes.md +++ b/notes.md @@ -23,6 +23,8 @@ ## `C` cosmetic, `F` functional, `P` performance, `B` bug fix +* `F` image import borders +* `F` mesh / stl export (like w/ images, rotate, scale, future cleanup ops) * `F` detect and report slow framerates * `F` right click / context menu (object deletion, etc) * `P` improve decimation speed by avoiding in/out of Point? diff --git a/src/kiri/main.js b/src/kiri/main.js index 199815db..d94a569d 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -959,6 +959,8 @@ "  invert image", " base size", "  invert alpha", + " border size", + " ", " ", "" ]}; @@ -967,6 +969,7 @@ loadImage(image, { blur: parseInt($('png-blur').value) || 0, base: parseInt($('png-base').value) || 0, + border: parseInt($('png-border').value) || 0, inv_image: $('png-inv').checked, inv_alpha: $('alpha-inv').checked, }); diff --git a/src/kiri/worker.js b/src/kiri/worker.js index c3b8c4b8..788a5dbc 100644 --- a/src/kiri/worker.js +++ b/src/kiri/worker.js @@ -256,20 +256,18 @@ KIRI.worker = { let points = width * height + // grid height * 2 + 0 + // left/right - width * 2 + 0 - // top/bottom - 0 // base shared corners - ; + width * 2 + 0; // top/bottom let flats = ((height-1) * (width-1)) + // surface - ((height-1) * 2) + // left/right - ((width-1) * 2) + // top/bottom - 1 // base - ; + ((height-1) * 2) + // left/right + ((width-1) * 2) + // top/bottom + 1; // base // convert png to grayscale let gray = new Uint8Array(width * height); let gi = 0; let invi = info.inv_image ? true : false; let inva = info.inv_alpha ? true : false; + let border = info.border || 0; for (let y = 0; y < height; y++) { for (let x = 0; x < width; x++) { let di = (x + width * y) * 4; @@ -278,6 +276,11 @@ KIRI.worker = { let b = data[di+2]; let a = data[di+3]; let v = ((r + g + b) / 3); + if (border) { + if (x < border || y < border || x > width-border-1 || y > height-border-1) { + v = 255; + } + } if (invi) v = 255 - v; if (inva) a = 255 - a; v *= (a/255);