Move fg rendering into IRenderLayer
This commit is contained in:
@@ -1,42 +1,21 @@
|
||||
import { IRenderLayer } from './Interfaces';
|
||||
import { IBuffer, ICharMeasure, ITerminal } from '../Interfaces';
|
||||
import { CHAR_DATA_ATTR_INDEX } from '../Buffer';
|
||||
import { TANGO_COLORS } from './Color';
|
||||
|
||||
export class BackgroundRenderLayer implements IRenderLayer {
|
||||
private _canvas: HTMLCanvasElement;
|
||||
private _ctx: CanvasRenderingContext2D;
|
||||
|
||||
// TODO: Pull colors into some other class
|
||||
private _colors = [
|
||||
// dark:
|
||||
'#2e3436',
|
||||
'#cc0000',
|
||||
'#4e9a06',
|
||||
'#c4a000',
|
||||
'#3465a4',
|
||||
'#75507b',
|
||||
'#06989a',
|
||||
'#d3d7cf',
|
||||
// bright:
|
||||
'#555753',
|
||||
'#ef2929',
|
||||
'#8ae234',
|
||||
'#fce94f',
|
||||
'#729fcf',
|
||||
'#ad7fa8',
|
||||
'#34e2e2',
|
||||
'#eeeeec'
|
||||
];
|
||||
|
||||
constructor(container: HTMLElement) {
|
||||
this._canvas = document.createElement('canvas');
|
||||
this._canvas.classList.add('xterm-bg-canvas');
|
||||
this._canvas.classList.add('xterm-bg-layer');
|
||||
this._ctx = this._canvas.getContext('2d');
|
||||
this._ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
|
||||
container.appendChild(this._canvas);
|
||||
}
|
||||
|
||||
public resize(canvasWidth: number, canvasHeight: number, charWidth: number, charHeight: number): void {
|
||||
public resize(canvasWidth: number, canvasHeight: number, charWidth: number, charHeight: number, charSizeChanged: boolean): void {
|
||||
this._canvas.width = canvasWidth * window.devicePixelRatio;
|
||||
this._canvas.height = canvasHeight * window.devicePixelRatio;
|
||||
this._canvas.style.width = `${canvasWidth}px`;
|
||||
@@ -58,7 +37,7 @@ export class BackgroundRenderLayer implements IRenderLayer {
|
||||
// TODO: Draw background
|
||||
if (bg < 16) {
|
||||
this._ctx.save();
|
||||
this._ctx.fillStyle = this._colors[bg];
|
||||
this._ctx.fillStyle = TANGO_COLORS[bg];
|
||||
this._ctx.fillRect(x * scaledCharWidth, y * scaledCharHeight, scaledCharWidth, scaledCharHeight);
|
||||
this._ctx.restore();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user