Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
canvas.c
Go to the documentation of this file.
1 
14 typedef bool PIXEL;
15 class Canvas
16 {
17  int m_SizeX; int m_SizeY;
18 
20 
21  void Canvas(int size_x, int size_y)
22  {
23  m_SizeX = size_x;
24  m_SizeY = size_y;
25  for(int i = 0; i < size_y; i++)
26  {
27  array<PIXEL> x_line = new array<PIXEL>;
28  for(int z = 0; z < size_x;z++)
29  {
30  x_line.Insert(false);
31  }
32  m_Pixels.Insert(x_line);
33 
34  }
35  }
36 
37  void DrawPixel(int x, int y)
38  {
39  if((x > m_SizeX - 1) || (y > m_SizeY - 1))
40  return;
41  //Print("x:" +x+",y:"+y);
42  m_Pixels.Get(y).InsertAt(true, x);
43  }
44 
45  void PrintOut()
46  {
47  string line = "";
48  int y_lines = m_SizeY - 1;
49  for(int i = y_lines; i >= 0; i--)
50  {
51  line = "";
52  for(int z = 0; z < m_SizeX;z++)
53  {
54  if(m_Pixels.Get(i).Get(z))
55  {
56  line += "X";
57  }
58  else
59  {
60  line += " ";
61  }
62  }
63  Print(line);
64  }
65  }
66 
67  void SaveToFile(string filename)
68  {
69  FileHandle file = OpenFile("$profile:"+filename, FileMode.WRITE);
70 
71  string line = "";
72  int y_lines = m_SizeY - 1;
73  for(int i = y_lines; i >= 0; i--)
74  {
75  line = "";
76  for(int z = 0; z < m_SizeX;z++)
77  {
78  if(m_Pixels.Get(i).Get(z))
79  {
80  line += "X";
81  }
82  else
83  {
84  line += " ";
85  }
86  }
87  FPrintln(file, line);
88  }
89  }
90 }
FPrintln
proto void FPrintln(FileHandle file, void var)
Write to file and add new line.
OpenFile
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
y
Icon y
Print
proto void Print(void var)
Prints content of variable to console/log.
FileMode
FileMode
Definition: ensystem.c:382
Canvas
Definition: canvas.c:15
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
x
Icon x
FileHandle
int[] FileHandle
Definition: ensystem.c:390
PIXEL
bool PIXEL
Definition: canvas.c:14