C# Класс StdPaint.ConsoleBuffer

Represents a two-dimensional buffer of characters that can be written to the console.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
UnitCount int

Защищенные свойства (Protected)

Свойство Тип Описание
_buffer ].BufferUnitInfo[
_width int

Открытые методы

Метод Описание
Clear ( BufferColor color = BufferColor.Black ) : void

Clears all units in the buffer, optionally specifying a color to fill the buffer with.

ClearBrush ( BufferBrush brush ) : void

Fills the entire buffer with a brush.

Clone ( ) : ConsoleBuffer

Returns a new ConsoleBuffer instance containing a copy of the buffer's contents.

ConsoleBuffer ( int width, int height ) : System

Initializes a new ConsoleBuffer instance with the specified dimensions.

CreateScreenBuffer ( ) : ConsoleBuffer

Creates a buffer whose size matches the current unit dimensions of the console.

DrawBox ( Rectangle rectangle, int thickness, BufferBrush border, BufferBrush fill ) : void

Draws a box from the specified rectangle and brush information.

DrawBox ( int x, int y, int w, int h, BufferBrush brush ) : void

Draws a solid box with the specified dimensions to the buffer.

DrawBox ( int x, int y, int w, int h, BufferColor color ) : void

Draws a solid box with the specified dimensions to the buffer.

DrawBox ( int x, int y, int w, int h, int thickness, BufferBrush border, BufferBrush fill ) : void

Draws a box with the specified border and fill brushes.

DrawBuffer ( ConsoleBuffer buffer, int x, int y, BufferDrawMode drawMode ) : void

Draws the contents of another buffer onto this buffer at the specified location.

DrawCircle ( int x, int y, int radius, BufferBrush brush ) : void

Draws a solid circle to the buffer with the specified attributes.

DrawCircle ( int x, int y, int radius, BufferColor color ) : void

Draws a solid circle to the buffer with the specified attributes.

DrawCircle ( int x, int y, int radius, int thickness, BufferBrush border, BufferBrush fill ) : void

Draws a circle with the specified radius, border thickness, and attributes for both border and fill.

DrawCircle ( int x, int y, int radius, int thickness, BufferColor border, BufferColor fill ) : void

Draws a circle with the specified radius, border thickness, and attributes for both border and fill.

DrawLine ( Point a, Point b, BufferBrush brush ) : void

Draws a line to the buffer with the specified brush.

DrawLine ( Point a, Point b, BufferColor color ) : void

Draws a colored line to the buffer.

DrawLine ( int x, int y, int x2, int y2, BufferBrush brush ) : void

Draws a line to the buffer.

DrawLine ( int x, int y, int x2, int y2, BufferColor color ) : void

Draws a line to the buffer.

DrawString ( int x, int y, Alignment alignment ) : void

Draws a string to the buffer with the specified alignment.

DrawString ( int x, int y, string text, BufferColor color, Alignment alignment = Alignment.Left ) : void

Prints a string to the buffer with the specified attributes and alignment.

DrawTriangle ( Point a, Point b, Point c, BufferBrush brush ) : void

Draws a triangle to the buffer.

DrawTriangle ( Point a, Point b, Point c, BufferColor color ) : void

Draws a triangle to the buffer.

DrawTriangle ( Triangle triangle, BufferBrush brush ) : void

Draws a triangle to the buffer.

DrawTriangle ( Triangle triangle, BufferBrush border, BufferBrush fill ) : void

Draws a triangle with the specified border and fill brushes.

DrawTriangle ( Triangle triangle, BufferColor color ) : void

Draws a triangle to the buffer.

FloodFill ( int x, int y, BufferBrush brush ) : void

Flood fills a closed region containing the specified coordinates with a brush.

FloodFill ( int x, int y, BufferColor color ) : void

Flood fills a closed region containing the specified coordinates with a color.

FromFile ( string path ) : ConsoleBuffer

Loads buffer data from a file and returns it as a ConsoleBuffer object.

GetColorFromUV ( double u, double v, TextureSampleMode mode = TextureSampleMode.Tile ) : BufferColor

Returns the unit background color at the specified texture coordinates.

GetUnitAttributes ( int x, int y ) : BufferUnitAttributes

Returns the attributes for the specified unit.

GetUnitBackColor ( Point point ) : BufferColor

Gets the background color of the specified unit.

GetUnitBackColor ( int x, int y ) : BufferColor

Gets the background color of the specified unit.

GetUnitCharacter ( Point point ) : char

Gets the character in the specified unit.

GetUnitCharacter ( int x, int y ) : char

Gets the character in the specified unit.

GetUnitForeColor ( Point point ) : BufferColor

Gets the foreground color of the specified unit.

GetUnitForeColor ( int x, int y ) : BufferColor

Gets the foreground color of the specified unit.

ResampledCopy ( ConsoleBuffer buffer, int width, int height ) : ConsoleBuffer

Creates a resampled copy of a console buffer using the specified dimensions.

Save ( string path ) : void

Writes the buffer data to a file.

SetUnitAttributes ( Point point, BufferUnitAttributes attributes ) : void

Sets the attributes for a specific unit in the buffer.

SetUnitAttributes ( int x, int y, BufferUnitAttributes attributes ) : void

Sets attributes for a specific unit in the buffer.

SetUnitBackColor ( Point point, BufferColor color ) : void

Sets the background color for a specific unit in the buffer.

SetUnitBackColor ( int x, int y, BufferColor color ) : void

Sets the background color for a specific unit in the buffer.

SetUnitCharacter ( Point p, char c ) : void

Sets the character for a specific unit in the buffer.

SetUnitCharacter ( int x, int y, char c ) : void

Sets the character for a specific unit in the buffer.

SetUnitForeColor ( Point point, BufferColor color ) : void

Sets the foreground color for a specific unit in the buffer.

SetUnitForeColor ( int x, int y, BufferColor color ) : void

Sets the foreground color for a specific unit in the buffer.

Защищенные методы

Метод Описание
InBounds ( Point point ) : bool
InBounds ( int x, int y ) : bool

Приватные методы

Метод Описание
ConsoleBuffer ( int width, int height, BufferUnitInfo bufferData ) : System

Описание методов

Clear() публичный Метод

Clears all units in the buffer, optionally specifying a color to fill the buffer with.
public Clear ( BufferColor color = BufferColor.Black ) : void
color BufferColor The color to fill the buffer with.
Результат void

ClearBrush() публичный Метод

Fills the entire buffer with a brush.
public ClearBrush ( BufferBrush brush ) : void
brush BufferBrush The brush to fill the buffer with.
Результат void

Clone() публичный Метод

Returns a new ConsoleBuffer instance containing a copy of the buffer's contents.
public Clone ( ) : ConsoleBuffer
Результат ConsoleBuffer

ConsoleBuffer() публичный Метод

Initializes a new ConsoleBuffer instance with the specified dimensions.
public ConsoleBuffer ( int width, int height ) : System
width int The width of the buffer, in units.
height int The height of the buffer, in units.
Результат System

CreateScreenBuffer() публичный статический Метод

Creates a buffer whose size matches the current unit dimensions of the console.
public static CreateScreenBuffer ( ) : ConsoleBuffer
Результат ConsoleBuffer

DrawBox() публичный Метод

Draws a box from the specified rectangle and brush information.
public DrawBox ( Rectangle rectangle, int thickness, BufferBrush border, BufferBrush fill ) : void
rectangle Rectangle The bounds of the box to draw.
thickness int The border thickness of the box.
border BufferBrush the border brush of the box.
fill BufferBrush The fill brush of the box.
Результат void

DrawBox() публичный Метод

Draws a solid box with the specified dimensions to the buffer.
public DrawBox ( int x, int y, int w, int h, BufferBrush brush ) : void
x int The X coordinate of the box.
y int The Y coordinate of the box.
w int The width of the box.
h int The height of the box.
brush BufferBrush The brush to draw the box with.
Результат void

DrawBox() публичный Метод

Draws a solid box with the specified dimensions to the buffer.
public DrawBox ( int x, int y, int w, int h, BufferColor color ) : void
x int The X coordinate of the box.
y int The Y coordinate of the box.
w int The width of the box.
h int The height of the box.
color BufferColor The color to draw the box with.
Результат void

DrawBox() публичный Метод

Draws a box with the specified border and fill brushes.
public DrawBox ( int x, int y, int w, int h, int thickness, BufferBrush border, BufferBrush fill ) : void
x int The X position of the box.
y int The Y position of the box.
w int The width of the box.
h int The height of the box.
thickness int The border thickness of the box.
border BufferBrush The brush to draw the border with.
fill BufferBrush The brush to draw the fill with.
Результат void

DrawBuffer() публичный Метод

Draws the contents of another buffer onto this buffer at the specified location.
public DrawBuffer ( ConsoleBuffer buffer, int x, int y, BufferDrawMode drawMode ) : void
buffer ConsoleBuffer The buffer to draw.
x int The X position to begin drawing at.
y int The Y position to begin drawing at.
drawMode BufferDrawMode Specified how the buffer should be drawn.
Результат void

DrawCircle() публичный Метод

Draws a solid circle to the buffer with the specified attributes.
public DrawCircle ( int x, int y, int radius, BufferBrush brush ) : void
x int The X position of the circle, relative to its center.
y int The Y position of the circle, relative to its center.
radius int The radius of the circle.
brush BufferBrush The brush to draw the circle with.
Результат void

DrawCircle() публичный Метод

Draws a solid circle to the buffer with the specified attributes.
public DrawCircle ( int x, int y, int radius, BufferColor color ) : void
x int The X position of the circle, relative to its center.
y int The Y position of the circle, relative to its center.
radius int The radius of the circle.
color BufferColor The color to draw the circle with.
Результат void

DrawCircle() публичный Метод

Draws a circle with the specified radius, border thickness, and attributes for both border and fill.
public DrawCircle ( int x, int y, int radius, int thickness, BufferBrush border, BufferBrush fill ) : void
x int The X position of the circle, relative to its center.
y int The Y position of the circle, relative to its center.
radius int The radius of the circle.
thickness int The border thickness of the circle.
border BufferBrush The border brush for the circle.
fill BufferBrush The fill brush for the circle.
Результат void

DrawCircle() публичный Метод

Draws a circle with the specified radius, border thickness, and attributes for both border and fill.
public DrawCircle ( int x, int y, int radius, int thickness, BufferColor border, BufferColor fill ) : void
x int The X position of the circle, relative to its center.
y int The Y position of the circle, relative to its center.
radius int The radius of the circle.
thickness int The border thickness of the circle.
border BufferColor The border color for the circle.
fill BufferColor The fill color for the circle.
Результат void

DrawLine() публичный Метод

Draws a line to the buffer with the specified brush.
public DrawLine ( Point a, Point b, BufferBrush brush ) : void
a Point The starting point of the line.
b Point The ending point of the line.
brush BufferBrush The brush to draw the line with.
Результат void

DrawLine() публичный Метод

Draws a colored line to the buffer.
public DrawLine ( Point a, Point b, BufferColor color ) : void
a Point The starting point of the line.
b Point The ending point of the line.
color BufferColor The color of the line.
Результат void

DrawLine() публичный Метод

Draws a line to the buffer.
public DrawLine ( int x, int y, int x2, int y2, BufferBrush brush ) : void
x int The starting X coordinate of the line.
y int The starting Y coordinate of the line.
x2 int The ending X coordinate of the line.
y2 int The ending Y coordinate of the line.
brush BufferBrush The brush to draw the line with.
Результат void

DrawLine() публичный Метод

Draws a line to the buffer.
public DrawLine ( int x, int y, int x2, int y2, BufferColor color ) : void
x int The starting X coordinate of the line.
y int The starting Y coordinate of the line.
x2 int The ending X coordinate of the line.
y2 int The ending Y coordinate of the line.
color BufferColor The color of the line.
Результат void

DrawString() публичный Метод

Draws a string to the buffer with the specified alignment.
public DrawString ( int x, int y, Alignment alignment ) : void
x int The X coordinate to start printing at.
y int The Y coordinate to start printing at.
alignment Alignment The alinment to assign to the string.
Результат void

DrawString() публичный Метод

Prints a string to the buffer with the specified attributes and alignment.
public DrawString ( int x, int y, string text, BufferColor color, Alignment alignment = Alignment.Left ) : void
x int The X coordinate to start printing at.
y int The Y coordinate to start printing at.
text string The string to print.
color BufferColor The color to assign to the text.
alignment Alignment The alignment of the string.
Результат void

DrawTriangle() публичный Метод

Draws a triangle to the buffer.
public DrawTriangle ( Point a, Point b, Point c, BufferBrush brush ) : void
a Point The first point of the triangle.
b Point The second point of the triangle.
c Point The third point of the triangle.
brush BufferBrush The brush of the line.
Результат void

DrawTriangle() публичный Метод

Draws a triangle to the buffer.
public DrawTriangle ( Point a, Point b, Point c, BufferColor color ) : void
a Point The first point of the triangle.
b Point The second point of the triangle.
c Point The third point of the triangle.
color BufferColor The color of the line.
Результат void

DrawTriangle() публичный Метод

Draws a triangle to the buffer.
public DrawTriangle ( Triangle triangle, BufferBrush brush ) : void
triangle Triangle The triangle to draw.
brush BufferBrush The brush to draw the triangle with.
Результат void

DrawTriangle() публичный Метод

Draws a triangle with the specified border and fill brushes.
public DrawTriangle ( Triangle triangle, BufferBrush border, BufferBrush fill ) : void
triangle Triangle The triangle to draw.
border BufferBrush The border brush.
fill BufferBrush The fill brush.
Результат void

DrawTriangle() публичный Метод

Draws a triangle to the buffer.
public DrawTriangle ( Triangle triangle, BufferColor color ) : void
triangle Triangle The triangle to draw.
color BufferColor The color to draw the triangle.
Результат void

FloodFill() публичный Метод

Flood fills a closed region containing the specified coordinates with a brush.
public FloodFill ( int x, int y, BufferBrush brush ) : void
x int The X coordinate to begin filling at.
y int The Y coordinate to begin filling at.
brush BufferBrush The brush to fill the region with.
Результат void

FloodFill() публичный Метод

Flood fills a closed region containing the specified coordinates with a color.
public FloodFill ( int x, int y, BufferColor color ) : void
x int The X coordinate to begin filling at.
y int The Y coordinate to begin filling at.
color BufferColor The color to fill the region with.
Результат void

FromFile() публичный статический Метод

Loads buffer data from a file and returns it as a ConsoleBuffer object.
public static FromFile ( string path ) : ConsoleBuffer
path string The path to the buffer file.
Результат ConsoleBuffer

GetColorFromUV() публичный Метод

Returns the unit background color at the specified texture coordinates.
public GetColorFromUV ( double u, double v, TextureSampleMode mode = TextureSampleMode.Tile ) : BufferColor
u double The U coordinate.
v double The V coordinate.
mode TextureSampleMode The sampling mode to use.
Результат BufferColor

GetUnitAttributes() публичный Метод

Returns the attributes for the specified unit.
public GetUnitAttributes ( int x, int y ) : BufferUnitAttributes
x int The X coordinate of the unit.
y int The Y coordinate of the unit.
Результат BufferUnitAttributes

GetUnitBackColor() публичный Метод

Gets the background color of the specified unit.
public GetUnitBackColor ( Point point ) : BufferColor
point Point The location of the unit.
Результат BufferColor

GetUnitBackColor() публичный Метод

Gets the background color of the specified unit.
public GetUnitBackColor ( int x, int y ) : BufferColor
x int The X coordinate of the unit.
y int The Y coordinate of the unit.
Результат BufferColor

GetUnitCharacter() публичный Метод

Gets the character in the specified unit.
public GetUnitCharacter ( Point point ) : char
point Point The location of the unit.
Результат char

GetUnitCharacter() публичный Метод

Gets the character in the specified unit.
public GetUnitCharacter ( int x, int y ) : char
x int The X coordinate of the unit.
y int The Y coordinate of the unit.
Результат char

GetUnitForeColor() публичный Метод

Gets the foreground color of the specified unit.
public GetUnitForeColor ( Point point ) : BufferColor
point Point The location of the unit.
Результат BufferColor

GetUnitForeColor() публичный Метод

Gets the foreground color of the specified unit.
public GetUnitForeColor ( int x, int y ) : BufferColor
x int The X coordinate of the unit.
y int The Y coordinate of the unit.
Результат BufferColor

InBounds() защищенный Метод

protected InBounds ( Point point ) : bool
point Point
Результат bool

InBounds() защищенный Метод

protected InBounds ( int x, int y ) : bool
x int
y int
Результат bool

ResampledCopy() публичный статический Метод

Creates a resampled copy of a console buffer using the specified dimensions.
public static ResampledCopy ( ConsoleBuffer buffer, int width, int height ) : ConsoleBuffer
buffer ConsoleBuffer The buffer to be resampled.
width int The width of the resampled buffer.
height int The height of the resampled buffer.
Результат ConsoleBuffer

Save() публичный Метод

Writes the buffer data to a file.
public Save ( string path ) : void
path string The path to the file.
Результат void

SetUnitAttributes() публичный Метод

Sets the attributes for a specific unit in the buffer.
public SetUnitAttributes ( Point point, BufferUnitAttributes attributes ) : void
point Point The location of the unit.
attributes BufferUnitAttributes The attributes to assign to the unit.
Результат void

SetUnitAttributes() публичный Метод

Sets attributes for a specific unit in the buffer.
public SetUnitAttributes ( int x, int y, BufferUnitAttributes attributes ) : void
x int The X coordinate of the unit.
y int The Y coordinate of the unit.
attributes BufferUnitAttributes The attributes to assign to the unit.
Результат void

SetUnitBackColor() публичный Метод

Sets the background color for a specific unit in the buffer.
public SetUnitBackColor ( Point point, BufferColor color ) : void
point Point The location of the unit.
color BufferColor The background color to set the unit to.
Результат void

SetUnitBackColor() публичный Метод

Sets the background color for a specific unit in the buffer.
public SetUnitBackColor ( int x, int y, BufferColor color ) : void
x int The X coordinate of the unit.
y int The Y coordinate of the unit.
color BufferColor The background color to set the unit to.
Результат void

SetUnitCharacter() публичный Метод

Sets the character for a specific unit in the buffer.
public SetUnitCharacter ( Point p, char c ) : void
p Point The location of the unit.
c char The character to assign to the unit.
Результат void

SetUnitCharacter() публичный Метод

Sets the character for a specific unit in the buffer.
public SetUnitCharacter ( int x, int y, char c ) : void
x int The X coordinate of the unit.
y int The Y coordinate of the unit.
c char The character to assign to the unit.
Результат void

SetUnitForeColor() публичный Метод

Sets the foreground color for a specific unit in the buffer.
public SetUnitForeColor ( Point point, BufferColor color ) : void
point Point The location of the unit.
color BufferColor The foreground color to set the unit to.
Результат void

SetUnitForeColor() публичный Метод

Sets the foreground color for a specific unit in the buffer.
public SetUnitForeColor ( int x, int y, BufferColor color ) : void
x int The X coordinate of the unit.
y int The Y coordinate of the unit.
color BufferColor The foreground color to set the unit to.
Результат void

Описание свойств

UnitCount публичное свойство

The total number of units in this buffer.
public int UnitCount
Результат int

_buffer защищенное свойство

Buffer data
protected BufferUnitInfo[,] _buffer
Результат ].BufferUnitInfo[

_width защищенное свойство

Buffer dimensions
protected int _width
Результат int