From a4f7e2d8e9cc679e40a47d29ee977e448fb16f9e Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sun, 24 Jul 2022 13:20:04 -0700 Subject: [PATCH] Fix inverse dim on canvas renderer --- src/browser/renderer/BaseRenderLayer.ts | 1 + src/browser/renderer/TextRenderLayer.ts | 2 -- src/browser/renderer/atlas/DynamicCharAtlas.ts | 14 ++++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/browser/renderer/BaseRenderLayer.ts b/src/browser/renderer/BaseRenderLayer.ts index 0a9b8057..aa9e3ded 100644 --- a/src/browser/renderer/BaseRenderLayer.ts +++ b/src/browser/renderer/BaseRenderLayer.ts @@ -345,6 +345,7 @@ export abstract class BaseRenderLayer implements IRenderLayer { } } + console.log(`draw char ${cell.getChars()} with style`, this._ctx.fillStyle); const atlasDidDraw = hasOverrides ? false : this._charAtlas?.draw(this._ctx, this._currentGlyphIdentifier, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop); if (!atlasDidDraw) { diff --git a/src/browser/renderer/TextRenderLayer.ts b/src/browser/renderer/TextRenderLayer.ts index f62819d0..6771fdb4 100644 --- a/src/browser/renderer/TextRenderLayer.ts +++ b/src/browser/renderer/TextRenderLayer.ts @@ -181,9 +181,7 @@ export class TextRenderLayer extends BaseRenderLayer { // Apply dim to the background, this is relatively slow as the CSS is re-parsed but dim is // rarely used if (nextFillStyle && cell.isDim()) { - console.log('old', nextFillStyle); nextFillStyle = color.multiplyOpacity(css.toColor(nextFillStyle), 0.5).css; - console.log('new', nextFillStyle); } // Get any decoration foreground/background overrides, this must be fetched before the early diff --git a/src/browser/renderer/atlas/DynamicCharAtlas.ts b/src/browser/renderer/atlas/DynamicCharAtlas.ts index 59069879..ea318117 100644 --- a/src/browser/renderer/atlas/DynamicCharAtlas.ts +++ b/src/browser/renderer/atlas/DynamicCharAtlas.ts @@ -225,13 +225,18 @@ export class DynamicCharAtlas extends BaseCharAtlas { // around the anti-aliased edges of the glyph, and it would look too dark. return TRANSPARENT_COLOR; } + let result: IColor; if (glyph.bg === INVERTED_DEFAULT_COLOR) { - return this._config.colors.foreground; + result = this._config.colors.foreground; + } else if (glyph.bg < 256) { + result = this._getColorFromAnsiIndex(glyph.bg); + } else { + result = this._config.colors.background; } - if (glyph.bg < 256) { - return this._getColorFromAnsiIndex(glyph.bg); + if (glyph.dim) { + result = color.blend(this._config.colors.background, color.multiplyOpacity(result, 0.5)); } - return this._config.colors.background; + return result; } private _getForegroundColor(glyph: IGlyphIdentifier): IColor { @@ -274,6 +279,7 @@ export class DynamicCharAtlas extends BaseCharAtlas { if (glyph.dim) { this._tmpCtx.globalAlpha = DIM_OPACITY; } + // Draw the character this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight);