KgpImageExtensions
Namespace: Hex1b
Assembly: Hex1b.dll
Extension methods for creating and configuring .
public static class KgpImageExtensionsInheritance
Object → KgpImageExtensions
Methods
AboveText(KgpImageWidget)
Sets the z-ordering to above text (image renders on top of text).
Parameters:
widget(KgpImageWidget):
Returns: KgpImageWidget
public static KgpImageWidget AboveText(this KgpImageWidget widget)BelowText(KgpImageWidget)
Sets the z-ordering to below text (image renders behind text).
Parameters:
widget(KgpImageWidget):
Returns: KgpImageWidget
public static KgpImageWidget BelowText(this KgpImageWidget widget)Fill(KgpImageWidget)
Scales the image to completely fill the allocated area while preserving the aspect ratio. Excess portions of the source image are cropped.
Parameters:
widget(KgpImageWidget):
Returns: KgpImageWidget
public static KgpImageWidget Fill(this KgpImageWidget widget)Fit(KgpImageWidget)
Scales the image to fit within the allocated area while preserving the aspect ratio, maximizing one dimension. The image may be smaller than the available space in one dimension. Wrap in to control positioning.
Parameters:
widget(KgpImageWidget):
Returns: KgpImageWidget
public static KgpImageWidget Fit(this KgpImageWidget widget)Height(KgpImageWidget, int)
Sets the display height in character cells.
Parameters:
widget(KgpImageWidget):height(Int32):
Returns: KgpImageWidget
public static KgpImageWidget Height(this KgpImageWidget widget, int height)KgpAnimation<TParent>(WidgetContext<TParent>, IReadOnlyList<KgpAnimationFrame>, int, int, Func<WidgetContext<KgpImageWidget>, Hex1bWidget>)
Creates a KGP image backed by full RGBA32 animation frames.
Parameters:
context(WidgetContext<<TParent>>): The widget context.frames(IReadOnlyList<KgpAnimationFrame>): The full animation frames in display order.pixelWidth(Int32): Width of every frame in pixels.pixelHeight(Int32): Height of every frame in pixels.builder(Func<KgpImageWidget>, Hex1bWidget>): Builds the widget displayed when KGP is not supported.
Returns: KgpImageWidget
A KGP image configured for terminal-native animation playback.
public static KgpImageWidget KgpAnimation<TParent>(this WidgetContext<TParent> context, IReadOnlyList<KgpAnimationFrame> frames, int pixelWidth, int pixelHeight, Func<WidgetContext<KgpImageWidget>, Hex1bWidget> builder) where TParent : Hex1bWidgetKgpImage<TParent>(WidgetContext<TParent>, byte[], int, int, Func<WidgetContext<KgpImageWidget>, Hex1bWidget>, int?, int?)
Creates a with the specified RGBA32 pixel data and fallback builder.
Parameters:
context(WidgetContext<<TParent>>): The widget context.imageData(Byte[]): Raw RGBA32 pixel data.pixelWidth(Int32): Width of the image in pixels.pixelHeight(Int32): Height of the image in pixels.builder(Func<KgpImageWidget>, Hex1bWidget>): Builds the widget displayed when KGP is not supported.width(Nullable<Int32>): Optional width in character cells.height(Nullable<Int32>): Optional height in character cells.
Returns: KgpImageWidget
A new .
public static KgpImageWidget KgpImage<TParent>(this WidgetContext<TParent> context, byte[] imageData, int pixelWidth, int pixelHeight, Func<WidgetContext<KgpImageWidget>, Hex1bWidget> builder, int? width = null, int? height = null) where TParent : Hex1bWidgetNaturalSize(KgpImageWidget)
Displays the image at its natural pixel-to-cell dimensions without scaling.
Parameters:
widget(KgpImageWidget):
Returns: KgpImageWidget
public static KgpImageWidget NaturalSize(this KgpImageWidget widget)Playing(KgpImageWidget, bool)
Starts or stops terminal-native playback for a KGP animation. Stopping playback resets the animation to its first frame.
Parameters:
widget(KgpImageWidget): The KGP image widget.playing(Boolean): Whether the animation should play.
Returns: KgpImageWidget
The configured widget.
public static KgpImageWidget Playing(this KgpImageWidget widget, bool playing = true)Stretch(KgpImageWidget, KgpImageStretch)
Sets the image stretch mode.
Parameters:
widget(KgpImageWidget):stretch(KgpImageStretch):
Returns: KgpImageWidget
public static KgpImageWidget Stretch(this KgpImageWidget widget, KgpImageStretch stretch)Stretched(KgpImageWidget)
Stretches the image to fill the allocated area. Aspect ratio is not preserved. This is the default behavior.
Parameters:
widget(KgpImageWidget):
Returns: KgpImageWidget
public static KgpImageWidget Stretched(this KgpImageWidget widget)Width(KgpImageWidget, int)
Sets the display width in character cells.
Parameters:
widget(KgpImageWidget):width(Int32):
Returns: KgpImageWidget
public static KgpImageWidget Width(this KgpImageWidget widget, int width)