Skip to content

ITexture Interface

Represents a texture provided by a game host.

C#
public interface ITexture : IDisposable

The file path to the texture.

C#
string ResourcePath { get; }

The height of the texture.

C#
int Height { get; }

The width of the texture.

C#
int Width { get; }

Size of the texture. Generally, the count of pixels.

C#
int Size { get; }

Gets an array of colors.

C#
Color[] GetPixels()

SadRogue.Primitives.Color[]

Sets colors in the texture.

C#
void SetPixels(Color[] colors)

colors SadRogue.Primitives.Color[]
The individual pixel colors to set.

Sets colors in the texture.

C#
void SetPixels(ReadOnlySpan<Color> colors)

colors ReadOnlySpan<Color>
The individual pixel colors to set.

Sets a specific pixel in the texture to a color by x,y coordinate.

C#
void SetPixel(Point position, Color color)

position SadRogue.Primitives.Point
The position of the pixel to set.

color SadRogue.Primitives.Color
The color to set.

Sets a specific pixel in the texture to a color by index. Row-major ordered.

C#
void SetPixel(int index, Color color)

index int

color SadRogue.Primitives.Color

Gets a pixel in the texture by x,y coordinate.

C#
Color GetPixel(Point position)

position SadRogue.Primitives.Point
The x,y coordinate of the pixel.

SadRogue.Primitives.Color
The color of the pixel.

Gets a pixel in the texture by index.

C#
Color GetPixel(int index)

index int
The index of the pixel.

SadRogue.Primitives.Color
The color of the pixel.

ToSurface(TextureConvertMode, int, int, TextureConvertBackgroundStyle, TextureConvertForegroundStyle, Color[]?, ICellSurface?)

Section titled “ToSurface(TextureConvertMode, int, int, TextureConvertBackgroundStyle, TextureConvertForegroundStyle, Color[]?, ICellSurface?)”

Converts the texture into a cell surface based on the specified mode.

C#
ICellSurface ToSurface(TextureConvertMode mode, int surfaceWidth, int surfaceHeight, TextureConvertBackgroundStyle backgroundStyle = TextureConvertBackgroundStyle.Pixel, TextureConvertForegroundStyle foregroundStyle = TextureConvertForegroundStyle.Block, Color[]? cachedColorArray = null, ICellSurface? cachedSurface = null)

mode TextureConvertMode
The mode used when converting the texture to a surface.

surfaceWidth int
How many cells wide the returned surface is.

surfaceHeight int
How many cells high the returned surface is.

backgroundStyle TextureConvertBackgroundStyle
The style to use when mode is Background.

foregroundStyle TextureConvertForegroundStyle
The style to use when mode is Foreground.

cachedColorArray SadRogue.Primitives.Color[]
When provided, this array is used for color data. It must match the texture’s expected GetPixels() bounds. Used with cachedColorArray.

cachedSurface ICellSurface
The cell surface to use instead of creating a new one. Used with cachedColorArray.

ICellSurface
A new surface.