Skip to main content

Picture class

Namespace: Arlecchino.Widgets.Pictures · Assembly: Arlecchino

An image drawn in cells, two pixels to each, or in a graphics protocol where Picture.Protocol names one. The pixels are handed over rather than read from a file, since decoding belongs to the application.

private readonly Picture _preview = new();

_preview.Show(pixels, width, height);
_preview.Draw(region);

public sealed class Picture : IArlecchinoWidget

Implements IArlecchinoWidget

Constructors

MemberSummary
Picture()

Properties

MemberSummary
BackgroundWhat to draw behind the picture where the region is wider or taller than the picture fits. The terminal's own background when left alone.
DetailHow many pixels a protocol that hands pixels over may write at most, whatever the pane comes to. The ceiling trades a little sharpness for a picture that appears at once; nought lifts it.
IsEmptyWhether there is anything to draw.
PixelHeightHow tall the picture is, in pixels.
PixelWidthHow wide the picture is, in pixels.
ProtocolHow the picture reaches the terminal. The application's own setting — Glyphs.Picture — when left alone, so one pane can differ without every other one being told.

Methods

MemberSummary
Clear()Forgets the picture, leaving the region to whatever draws next. What the terminal was handed as pixels is undrawn on the next frame — see how Surface.Passthrough takes a payload back — so this needs no more than forgetting them.
Draw(SurfaceRegion)Draws the picture as large as it goes inside the region without stretching it, centered, and returns an empty region: a picture fills what it is given, so hand over the pane it belongs in.
Show(ReadOnlySpan<Rgb>, int, int)Hands over the pixels to draw, row by row from the top left. They are copied, so the caller is free to reuse its buffer.

Constructors in detail

Picture()

public Picture();

Properties in detail

Background

public IArlecchinoColor? Background { get; init; }

What to draw behind the picture where the region is wider or taller than the picture fits. The terminal's own background when left alone.

Type IArlecchinoColor

Detail

public int Detail { get; set; }

How many pixels a protocol that hands pixels over may write at most, whatever the pane comes to. The ceiling trades a little sharpness for a picture that appears at once; nought lifts it.

Type int

IsEmpty

public bool IsEmpty { get; }

Whether there is anything to draw.

Type bool

PixelHeight

public int PixelHeight { get; }

How tall the picture is, in pixels.

Type int

PixelWidth

public int PixelWidth { get; }

How wide the picture is, in pixels.

Type int

Protocol

public Nullable<ImageProtocol> Protocol { get; set; }

How the picture reaches the terminal. The application's own setting — Glyphs.Picture — when left alone, so one pane can differ without every other one being told.

Type Nullable<T><ImageProtocol>

Methods in detail

Clear()

public void Clear();

Forgets the picture, leaving the region to whatever draws next. What the terminal was handed as pixels is undrawn on the next frame — see how Surface.Passthrough takes a payload back — so this needs no more than forgetting them.

Draw(SurfaceRegion)

public SurfaceRegion Draw(SurfaceRegion region);

Draws the picture as large as it goes inside the region without stretching it, centered, and returns an empty region: a picture fills what it is given, so hand over the pane it belongs in.

Parameters

NameTypeDescription
regionSurfaceRegionWhere to draw.

Returns SurfaceRegion — An empty region.

Show(ReadOnlySpan<Rgb>, int, int)

public void Show(ReadOnlySpan<Rgb> pixels, int width, int height);

Hands over the pixels to draw, row by row from the top left. They are copied, so the caller is free to reuse its buffer.

Parameters

NameTypeDescription
pixelsReadOnlySpan<T><Rgb>The pixels, width × height of them.
widthintHow wide the picture is.
heightintHow tall the picture is.