minor blend changes.

This commit is contained in:
Christopher Jeffrey 2015-04-10 13:01:00 -07:00
parent eebbcdd702
commit 46b493d02e
2 changed files with 32 additions and 14 deletions

View File

@ -4171,6 +4171,7 @@ Element.prototype.render = function() {
x = xl;
for (; x < xl + 2; x++) {
if (!lines[y][x]) continue;
// lines[y][x][0] = blend(this.dattr, lines[y][x][0]);
lines[y][x][0] = blend(lines[y][x][0]);
lines[y].dirty = true;
}
@ -4181,6 +4182,7 @@ Element.prototype.render = function() {
if (!lines[y]) continue;
for (x = xi + 1; x < xl; x++) {
if (!lines[y][x]) continue;
// lines[y][x][0] = blend(this.dattr, lines[y][x][0]);
lines[y][x][0] = blend(lines[y][x][0]);
lines[y].dirty = true;
}
@ -8723,17 +8725,24 @@ function blend(attr, attr2) {
if (bg2 === 0x1ff) bg2 = 0;
bg = colors.mixColors(bg, bg2);
} else {
if (bg < 8) {
bg += 8;
if (blend._cache[bg] != null) {
bg = blend._cache[bg];
// } else if (bg < 8) {
// bg += 8;
} else if (bg >= 8 && bg <= 15) {
bg -= 8;
} else {
var name = colors.ncolors[bg];
if (name) {
for (var i = 0; i < colors.ncolors.length; i++) {
if (name === colors.ncolors[i] && bg !== i) {
bg = i;
break;
if (name === colors.ncolors[i] && i !== bg) {
var c = colors.vcolors[bg];
var nc = colors.vcolors[i];
if (nc[0] + nc[1] + nc[2] < c[0] + c[1] + c[2]) {
blend._cache[bg] = i;
bg = i;
break;
}
}
}
}
@ -8756,17 +8765,24 @@ function blend(attr, attr2) {
fg = colors.mixColors(fg, fg2);
}
} else {
if (fg < 8) {
fg += 8;
if (blend._cache[fg] != null) {
fg = blend._cache[fg];
// } else if (fg < 8) {
// fg += 8;
} else if (fg >= 8 && fg <= 15) {
fg -= 8;
} else {
var name = colors.ncolors[fg];
if (name) {
for (var i = 0; i < colors.ncolors.length; i++) {
if (name === colors.ncolors[i] && fg !== i) {
fg = i;
break;
if (name === colors.ncolors[i] && i !== fg) {
var c = colors.vcolors[fg];
var nc = colors.vcolors[i];
if (nc[0] + nc[1] + nc[2] < c[0] + c[1] + c[2]) {
blend._cache[fg] = i;
fg = i;
break;
}
}
}
}
@ -8779,6 +8795,8 @@ function blend(attr, attr2) {
return attr;
}
blend._cache = {};
/**
* Helpers
*/

View File

@ -23,10 +23,10 @@ var bg = blessed.box({
var under = blessed.box({
parent: screen,
shadow: true,
left: 2,
top: 2,
width: '30%',
height: '20%',
left: 10,
top: 4,
width: '40%',
height: '30%',
style: {
bg: 'yellow'
},