Interface ITexture
Represents a texture provided by a game host.
Inherited Members
Namespace: SadConsole
Assembly: SadConsole.dll
Syntax
public interface ITexture : IDisposable
Properties
Height
The height of the texture.
Declaration
int Height { get; }
Property Value
Type | Description |
---|---|
int |
ResourcePath
The file path to the texture.
Declaration
string ResourcePath { get; }
Property Value
Type | Description |
---|---|
string |
Size
Size of the texture. Generally, the count of pixels.
Declaration
int Size { get; }
Property Value
Type | Description |
---|---|
int |
Width
The width of the texture.
Declaration
int Width { get; }
Property Value
Type | Description |
---|---|
int |
Methods
GetPixel(Point)
Gets a pixel in the texture by x,y coordinate.
Declaration
Color GetPixel(Point position)
Parameters
Type | Name | Description |
---|---|---|
Point | position | The x,y coordinate of the pixel. |
Returns
Type | Description |
---|---|
Color | The color of the pixel. |
GetPixel(int)
Gets a pixel in the texture by index.
Declaration
Color GetPixel(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the pixel. |
Returns
Type | Description |
---|---|
Color | The color of the pixel. |
GetPixels()
Gets an array of colors.
Declaration
Color[] GetPixels()
Returns
Type | Description |
---|---|
Color[] |
SetPixel(Point, Color)
Sets a specific pixel in the texture to a color by x,y coordinate.
Declaration
void SetPixel(Point position, Color color)
Parameters
Type | Name | Description |
---|---|---|
Point | position | The position of the pixel to set. |
Color | color | The color to set. |
SetPixel(int, Color)
Sets a specific pixel in the texture to a color by index. Row-major ordered.
Declaration
void SetPixel(int index, Color color)
Parameters
SetPixels(Color[])
Sets colors in the texture.
Declaration
void SetPixels(Color[] colors)
Parameters
Type | Name | Description |
---|---|---|
Color[] | colors | The individual pixel colors to set. |
SetPixels(ReadOnlySpan<Color>)
Sets colors in the texture.
Declaration
void SetPixels(ReadOnlySpan<Color> colors)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Color> | colors | The individual pixel colors to set. |
ToSurface(TextureConvertMode, int, int, TextureConvertBackgroundStyle, TextureConvertForegroundStyle, Color[]?, ICellSurface?)
Converts the texture into a cell surface based on the specified mode.
Declaration
ICellSurface ToSurface(TextureConvertMode mode, int surfaceWidth, int surfaceHeight, TextureConvertBackgroundStyle backgroundStyle = TextureConvertBackgroundStyle.Pixel, TextureConvertForegroundStyle foregroundStyle = TextureConvertForegroundStyle.Block, Color[]? cachedColorArray = null, ICellSurface? cachedSurface = null)
Parameters
Type | Name | Description |
---|---|---|
TextureConvertMode | mode | The mode used when converting the texture to a surface. |
int | surfaceWidth | How many cells wide the returned surface is. |
int | surfaceHeight | How many cells high the returned surface is. |
TextureConvertBackgroundStyle | backgroundStyle | The style to use when |
TextureConvertForegroundStyle | foregroundStyle | The style to use when |
Color[] | cachedColorArray | When provided, this array is used for color data. It must match the texture's expected GetPixels() bounds. Used with |
ICellSurface | cachedSurface | The cell surface to use instead of creating a new one. Used with |
Returns
Type | Description |
---|---|
ICellSurface | A new surface. |