C# Class StdPaint.ConsoleBuffer

Represents a two-dimensional buffer of characters that can be written to the console.
Mostra file Open project: TheBerkin/StdPaint Class Usage Examples

Public Properties

Property Type Description
UnitCount int

Protected Properties

Property Type Description
_buffer ].BufferUnitInfo[
_width int

Public Methods

Method Description
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.

Protected Methods

Method Description
InBounds ( Point point ) : bool
InBounds ( int x, int y ) : bool

Private Methods

Method Description
ConsoleBuffer ( int width, int height, BufferUnitInfo bufferData ) : System

Method Details

Clear() public method

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.
return void

ClearBrush() public method

Fills the entire buffer with a brush.
public ClearBrush ( BufferBrush brush ) : void
brush BufferBrush The brush to fill the buffer with.
return void

Clone() public method

Returns a new ConsoleBuffer instance containing a copy of the buffer's contents.
public Clone ( ) : ConsoleBuffer
return ConsoleBuffer

ConsoleBuffer() public method

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.
return System

CreateScreenBuffer() public static method

Creates a buffer whose size matches the current unit dimensions of the console.
public static CreateScreenBuffer ( ) : ConsoleBuffer
return ConsoleBuffer

DrawBox() public method

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.
return void

DrawBox() public method

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.
return void

DrawBox() public method

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.
return void

DrawBox() public method

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.
return void

DrawBuffer() public method

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.
return void

DrawCircle() public method

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.
return void

DrawCircle() public method

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.
return void

DrawCircle() public method

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.
return void

DrawCircle() public method

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.
return void

DrawLine() public method

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.
return void

DrawLine() public method

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.
return void

DrawLine() public method

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.
return void

DrawLine() public method

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.
return void

DrawString() public method

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.
return void

DrawString() public method

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.
return void

DrawTriangle() public method

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.
return void

DrawTriangle() public method

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.
return void

DrawTriangle() public method

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.
return void

DrawTriangle() public method

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.
return void

DrawTriangle() public method

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.
return void

FloodFill() public method

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.
return void

FloodFill() public method

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.
return void

FromFile() public static method

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.
return ConsoleBuffer

GetColorFromUV() public method

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.
return BufferColor

GetUnitAttributes() public method

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.
return BufferUnitAttributes

GetUnitBackColor() public method

Gets the background color of the specified unit.
public GetUnitBackColor ( Point point ) : BufferColor
point Point The location of the unit.
return BufferColor

GetUnitBackColor() public method

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.
return BufferColor

GetUnitCharacter() public method

Gets the character in the specified unit.
public GetUnitCharacter ( Point point ) : char
point Point The location of the unit.
return char

GetUnitCharacter() public method

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.
return char

GetUnitForeColor() public method

Gets the foreground color of the specified unit.
public GetUnitForeColor ( Point point ) : BufferColor
point Point The location of the unit.
return BufferColor

GetUnitForeColor() public method

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.
return BufferColor

InBounds() protected method

protected InBounds ( Point point ) : bool
point Point
return bool

InBounds() protected method

protected InBounds ( int x, int y ) : bool
x int
y int
return bool

ResampledCopy() public static method

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.
return ConsoleBuffer

Save() public method

Writes the buffer data to a file.
public Save ( string path ) : void
path string The path to the file.
return void

SetUnitAttributes() public method

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.
return void

SetUnitAttributes() public method

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.
return void

SetUnitBackColor() public method

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.
return void

SetUnitBackColor() public method

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.
return void

SetUnitCharacter() public method

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.
return void

SetUnitCharacter() public method

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.
return void

SetUnitForeColor() public method

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.
return void

SetUnitForeColor() public method

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.
return void

Property Details

UnitCount public_oe property

The total number of units in this buffer.
public int UnitCount
return int

_buffer protected_oe property

Buffer data
protected BufferUnitInfo[,] _buffer
return ].BufferUnitInfo[

_width protected_oe property

Buffer dimensions
protected int _width
return int