Skip to content

Commit 0ccdfca

Browse files
authored
Merge pull request microsoft#163551 from microsoft/tyriar/console_image
Add commented out debug helper for logging an image to the console
2 parents 5d48408 + f9415ab commit 0ccdfca

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,40 @@ function getFullBufferLineAsString(lineIndex: number, buffer: IBuffer): { lineDa
6666
return { lineData, lineIndex };
6767
}
6868

69+
70+
// DEBUG: This helper can be used to draw image data to the console, it's commented out as we don't
71+
// want to ship it, but this is very useful for investigating texture atlas issues.
72+
// (console as any).image = (source: ImageData | HTMLCanvasElement, scale: number = 1) => {
73+
// function getBox(width: number, height: number) {
74+
// return {
75+
// string: '+',
76+
// style: 'font-size: 1px; padding: ' + Math.floor(height/2) + 'px ' + Math.floor(width/2) + 'px; line-height: ' + height + 'px;'
77+
// };
78+
// }
79+
// if (source instanceof HTMLCanvasElement) {
80+
// source = source.getContext('2d')?.getImageData(0, 0, source.width, source.height)!;
81+
// }
82+
// const canvas = document.createElement('canvas');
83+
// canvas.width = source.width;
84+
// canvas.height = source.height;
85+
// const ctx = canvas.getContext('2d')!;
86+
// ctx.putImageData(source, 0, 0);
87+
88+
// const sw = source.width * scale;
89+
// const sh = source.height * scale;
90+
// const dim = getBox(sw, sh);
91+
// console.log(
92+
// `Image: ${source.width} x ${source.height}\n%c${dim.string}`,
93+
// `${dim.style}background: url(${canvas.toDataURL()}); background-size: ${sw}px ${sh}px; background-repeat: no-repeat; color: transparent;`
94+
// );
95+
// console.groupCollapsed('Zoomed');
96+
// console.log(
97+
// `%c${dim.string}`,
98+
// `${getBox(sw * 10, sh * 10).style}background: url(${canvas.toDataURL()}); background-size: ${sw * 10}px ${sh * 10}px; background-repeat: no-repeat; color: transparent; image-rendering: pixelated;-ms-interpolation-mode: nearest-neighbor;`
99+
// );
100+
// console.groupEnd();
101+
// };
102+
69103
/**
70104
* Wraps the xterm object with additional functionality. Interaction with the backing process is out
71105
* of the scope of this class.

0 commit comments

Comments
 (0)