DayZ 1.24
Loading...
Searching...
No Matches
Canvas.c
Go to the documentation of this file.
1
14typedef bool PIXEL;
15class Canvas
16{
17 int m_SizeX; int m_SizeY;
18
20
21 void Canvas(int size_x, int size_y)
22 {
25 for (int i = 0; i < size_y; i++)
26 {
28 for (int z = 0; z < size_x; z++)
29 x_line.Insert(false);
30 m_Pixels.Insert(x_line);
31
32 }
33 }
34
35 void DrawPixel(int x, int y)
36 {
37 if ((x > m_SizeX - 1) || (y > m_SizeY - 1))
38 return;
39 //Print("x:" +x+",y:"+y);
40 m_Pixels.Get(y).InsertAt(true, x);
41 }
42
43 void PrintOut()
44 {
45 string line = "";
46 int y_lines = m_SizeY - 1;
47 for (int i = y_lines; i >= 0; i--)
48 {
49 line = "";
50 for (int z = 0; z < m_SizeX; z++)
51 {
52 if (m_Pixels.Get(i).Get(z))
53 line += "X";
54 else
55 line += " ";
56 }
57 Print(line);
58 }
59 }
60
61 void SaveToFile(string filename)
62 {
63 FileHandle file = OpenFile("$profile:" + filename, FileMode.WRITE);
64
65 string line = "";
66 int y_lines = m_SizeY - 1;
67 for (int i = y_lines; i >= 0; i--)
68 {
69 line = "";
70 for (int z = 0; z < m_SizeX; z++)
71 {
72 if (m_Pixels.Get(i).Get(z))
73 line += "X";
74 else
75 line += " ";
76 }
78 }
79 }
80}
bool PIXEL
Definition Canvas.c:14
Icon x
Icon y
ref array< ref array< PIXEL > > m_Pixels
Definition Canvas.c:19
void SaveToFile(string filename)
Definition Canvas.c:61
void Canvas(int size_x, int size_y)
Definition Canvas.c:21
void PrintOut()
Definition Canvas.c:43
int m_SizeY
Definition Canvas.c:17
void DrawPixel(int x, int y)
Definition Canvas.c:35
int m_SizeX
Definition Canvas.c:17
proto void Print(void var)
Prints content of variable to console/log.
FileMode
Definition EnSystem.c:383
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
proto void FPrintln(FileHandle file, void var)
Write to file and add new line.