-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPixel.cs
60 lines (55 loc) · 1.58 KB
/
Pixel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma warning disable IDE1006 // Naming Styles
namespace TerminalEngine
{
public class Pixel(char c, int index, ConsoleColor color)
{
public char c { get; set; } = c;
public int index { get; internal set; } = index;
public ConsoleColor color { get; set; } = color;
public const char DEFAULT_FULL = '\u2588';
public const char DEFAULT_EMPTY = ' ';
public int row
{
get
{
GetRowAndColumn(index, Canvas.Width, out int row, out _);
return row;
}
}
public int column
{
get
{
GetRowAndColumn(index, Canvas.Width, out _, out int column);
return column;
}
}
public Position position
{
get
{
GetRowAndColumn(index, Canvas.Width, out int row, out int column);
return new Position(column, row);
}
}
private static void GetRowAndColumn(int index, int width, out int row, out int column)
{
row = index / width;
column = index % width;
}
public void Fill()
{
Fill(DEFAULT_FULL);
}
public void Fill(char c)
{
this.c = c;
Canvas.PixelActions.Enqueue(this);
}
public override string ToString()
{
return $"Pixel:{{ c:\"{c}\", index:\"{index}\", position:{{ {position} }} }}";
}
}
}
#pragma warning restore IDE1006 // Naming Styles