add image import border option
This commit is contained in:
parent
7292f1c141
commit
2dff2f3f99
3 changed files with 15 additions and 7 deletions
2
notes.md
2
notes.md
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
## `C` cosmetic, `F` functional, `P` performance, `B` bug fix
|
## `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` detect and report slow framerates
|
||||||
* `F` right click / context menu (object deletion, etc)
|
* `F` right click / context menu (object deletion, etc)
|
||||||
* `P` improve decimation speed by avoiding in/out of Point?
|
* `P` improve decimation speed by avoiding in/out of Point?
|
||||||
|
|
|
||||||
|
|
@ -959,6 +959,8 @@
|
||||||
" <th> invert image</th><td><input id='png-inv' type='checkbox'></td></tr>",
|
" <th> invert image</th><td><input id='png-inv' type='checkbox'></td></tr>",
|
||||||
" <tr><th>base size</th><td><input id='png-base' value='0' size='3'></td>",
|
" <tr><th>base size</th><td><input id='png-base' value='0' size='3'></td>",
|
||||||
" <th> invert alpha</th><td><input id='alpha-inv' type='checkbox'></td></tr>",
|
" <th> invert alpha</th><td><input id='alpha-inv' type='checkbox'></td></tr>",
|
||||||
|
" <tr><th>border size</th><td><input id='png-border' value='0' size='3'></td>",
|
||||||
|
" <th></th><td></td></tr>",
|
||||||
" </table></div>",
|
" </table></div>",
|
||||||
"</div>"
|
"</div>"
|
||||||
]};
|
]};
|
||||||
|
|
@ -967,6 +969,7 @@
|
||||||
loadImage(image, {
|
loadImage(image, {
|
||||||
blur: parseInt($('png-blur').value) || 0,
|
blur: parseInt($('png-blur').value) || 0,
|
||||||
base: parseInt($('png-base').value) || 0,
|
base: parseInt($('png-base').value) || 0,
|
||||||
|
border: parseInt($('png-border').value) || 0,
|
||||||
inv_image: $('png-inv').checked,
|
inv_image: $('png-inv').checked,
|
||||||
inv_alpha: $('alpha-inv').checked,
|
inv_alpha: $('alpha-inv').checked,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -256,20 +256,18 @@ KIRI.worker = {
|
||||||
let points =
|
let points =
|
||||||
width * height + // grid
|
width * height + // grid
|
||||||
height * 2 + 0 + // left/right
|
height * 2 + 0 + // left/right
|
||||||
width * 2 + 0 - // top/bottom
|
width * 2 + 0; // top/bottom
|
||||||
0 // base shared corners
|
|
||||||
;
|
|
||||||
let flats =
|
let flats =
|
||||||
((height-1) * (width-1)) + // surface
|
((height-1) * (width-1)) + // surface
|
||||||
((height-1) * 2) + // left/right
|
((height-1) * 2) + // left/right
|
||||||
((width-1) * 2) + // top/bottom
|
((width-1) * 2) + // top/bottom
|
||||||
1 // base
|
1; // base
|
||||||
;
|
|
||||||
// convert png to grayscale
|
// convert png to grayscale
|
||||||
let gray = new Uint8Array(width * height);
|
let gray = new Uint8Array(width * height);
|
||||||
let gi = 0;
|
let gi = 0;
|
||||||
let invi = info.inv_image ? true : false;
|
let invi = info.inv_image ? true : false;
|
||||||
let inva = info.inv_alpha ? true : false;
|
let inva = info.inv_alpha ? true : false;
|
||||||
|
let border = info.border || 0;
|
||||||
for (let y = 0; y < height; y++) {
|
for (let y = 0; y < height; y++) {
|
||||||
for (let x = 0; x < width; x++) {
|
for (let x = 0; x < width; x++) {
|
||||||
let di = (x + width * y) * 4;
|
let di = (x + width * y) * 4;
|
||||||
|
|
@ -278,6 +276,11 @@ KIRI.worker = {
|
||||||
let b = data[di+2];
|
let b = data[di+2];
|
||||||
let a = data[di+3];
|
let a = data[di+3];
|
||||||
let v = ((r + g + b) / 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 (invi) v = 255 - v;
|
||||||
if (inva) a = 255 - a;
|
if (inva) a = 255 - a;
|
||||||
v *= (a/255);
|
v *= (a/255);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue