Class AsciiArt
Renders images as text: shade blocks, ASCII art or Braille dots.
Inherited Members
Namespace: Uniform.Chat.Terminal.Ui.Images
Assembly: Uniform.Chat.dll
Syntax
public static class AsciiArt
Fields
| Edit this page View SourceAsciiRamp
Characters from sparse to dense, the classic 70-step ramp, used by Ascii.
Declaration
public const string AsciiRamp = " .'`^\",:;Il!i><~+_-?][}{1)(|\\/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$"
Field Value
| Type | Description |
|---|---|
| string |
BlockRamp
Shade blocks from empty to full, used by Blocks.
Declaration
public const string BlockRamp = " ░▒▓█"
Field Value
| Type | Description |
|---|---|
| string |
CellAspect
Height of a terminal cell relative to its width; cells are about twice as tall as wide.
Declaration
public const double CellAspect = 2
Field Value
| Type | Description |
|---|---|
| double |
MaxUpscale
Largest upscaling in columns per source pixel, so small images grow with the window but icons do not fill it.
Declaration
public const int MaxUpscale = 2
Field Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceFitCells(int, int, int, int)
Return the cell size of a width×height pixel image fitted into maxColumns×maxRows.
Declaration
public static (int Columns, int Rows) FitCells(int width, int height, int maxColumns, int maxRows)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | |
| int | height | |
| int | maxColumns | |
| int | maxRows |
Returns
| Type | Description |
|---|---|
| (int Pdus, int Edus) |
Render(DecodedImage, int, int, bool, ImagePreviewStyle)
Render image within maxColumns×maxRows cells, keeping its proportions.
Declaration
public static IReadOnlyList<string> Render(DecodedImage image, int maxColumns, int maxRows, bool darkBackground = true, ImagePreviewStyle style = ImagePreviewStyle.Blocks)
Parameters
| Type | Name | Description |
|---|---|---|
| DecodedImage | image | Image to render. |
| int | maxColumns | Widest result in columns. |
| int | maxRows | Tallest result in rows. |
| bool | darkBackground | Whether bright pixels are drawn, as on a dark terminal; otherwise dark pixels are. Transparent pixels stay blank either way. |
| ImagePreviewStyle | style | Shade blocks, ASCII ramp or Braille dots. |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<string> |
Examples
foreach (string line in AsciiArt.Render(image, 120, 30, style: ImagePreviewStyle.Braille)) Console.WriteLine(line);