Skip to content

Commit 5117e03

Browse files
committed
change chequerboard pattern so it's not so violent
1 parent 425864d commit 5117e03

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

imageconverter.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@
368368
rgba = rescale(rgba, options);
369369
if (options.autoCrop || options.autoCropCenter)
370370
rgba = autoCrop(rgba, options);
371-
371+
372372

373373
if ("string"!=typeof options.diffusion)
374374
options.diffusion = "none";
@@ -551,7 +551,7 @@
551551
// Write preview
552552
var cr = fmt.toRGBA(c, palette);
553553
if (c===transparentCol)
554-
cr = ((((x>>2)^(y>>2))&1)?0xFFFFFF:0); // pixel pattern
554+
cr = ((((x>>2)^(y>>2))&1)?0xCCCCCC:0x555555); // pixel pattern
555555
//var oa = cr>>>24; - ignore alpha
556556
var or = (cr>>16)&255;
557557
var og = (cr>>8)&255;
@@ -653,7 +653,7 @@
653653
for (var x=0; x<options.width; x++) {
654654
var na = rgba[n*4+3]/255;
655655
var a = 1-na;
656-
var chequerboard = ((((x>>2)^(y>>2))&1)?0xFFFFFF:0);
656+
var chequerboard = ((((x>>2)^(y>>2))&1)?0xCC:0x55);
657657
rgba[n*4] = rgba[n*4]*na + chequerboard*a;
658658
rgba[n*4+1] = rgba[n*4+1]*na + chequerboard*a;
659659
rgba[n*4+2] = rgba[n*4+2]*na + chequerboard*a;
@@ -745,7 +745,7 @@
745745
y1 = Math.min(y1, (options.height-1)-y2);
746746
x2 = (options.width-1)-x1;
747747
y2 = (options.height-1)-y1;
748-
}
748+
}
749749
// ok, crop!
750750
var w = 1+x2-x1;
751751
var h = 1+y2-y1;
@@ -772,7 +772,7 @@
772772
for (let x=0;x<dstw;x++) {
773773
let oldx = x / scale;
774774
let oldy = y / scale;
775-
let ix = Math.floor(oldx), ax=oldx-ix;
775+
let ix = Math.floor(oldx), ax=oldx-ix;
776776
let iy = Math.floor(oldy), ay=oldy-iy;
777777
let ca = blendRGBA8888(src[ix+(srcw*iy)], src[ix+1+(srcw*iy)], ax);
778778
let cb = blendRGBA8888(src[ix+(srcw*(iy+1))], src[ix+1+(srcw*(iy+1))], ax);

0 commit comments

Comments
 (0)