-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht8.lua
261 lines (233 loc) · 5.84 KB
/
t8.lua
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
-- (c) Platin21
-- 2016.12.7
-- version: Beta
--
function PG(cls)
function ERROR(v)
print('Error:'..v);
end
local this = {};
local _HWD_IMAGE = {};
local _HWD_IMAGE_COUNT = 1;
local _HWD_IMAGE_VALUE = 1;
local _HWD_IMAGE_SIZE_W = 0;
local _HWD_IMAGE_SIZE_H = 0;
local _HWD_IMAGE_COLOR = 0;
local _HWD_ACTUAL_IMAGE = 1;
local _HWD_IMAGE_CLEAR_COLOR = cls;
local _HWD_IMAGE_COLOR_BACKGROUND = 0;
local _HWD_IMAGE_COLOR_TABLE = {};
_HWD_IMAGE_COLOR_TABLE[#_HWD_IMAGE_COLOR_TABLE + 1] = 1;
local clr = 1;
for i=0,14 do
clr = clr * 2;
_HWD_IMAGE_COLOR_TABLE[#_HWD_IMAGE_COLOR_TABLE + 1] = clr;
end
clr = nil;
function this._HWD_SET_CLEAR_COLOR(c)
if type(c) == "number" then
if c_7834239045(c) then
_HWD_IMAGE_COLOR = c;
else
-- TODO: ERROR FUNCTION
end
else
-- TODO: ERROR FUNCTION
end
end
function c_2162069189()
end
function c_4162362989(c)
if c == "0" then
return _HWD_IMAGE_COLOR_TABLE[1];
elseif c == "1" then
return _HWD_IMAGE_COLOR_TABLE[2];
elseif c == "2" then
return _HWD_IMAGE_COLOR_TABLE[3];
elseif c == "3" then
return _HWD_IMAGE_COLOR_TABLE[4];
elseif c == "4" then
return _HWD_IMAGE_COLOR_TABLE[5];
elseif c == "5" then
return _HWD_IMAGE_COLOR_TABLE[6];
elseif c == "6" then
return _HWD_IMAGE_COLOR_TABLE[7];
elseif c == "7" then
return _HWD_IMAGE_COLOR_TABLE[8];
elseif c == "8" then
return _HWD_IMAGE_COLOR_TABLE[9];
elseif c == "9" then
return _HWD_IMAGE_COLOR_TABLE[10];
elseif c == "a" then
return _HWD_IMAGE_COLOR_TABLE[11];
elseif c == "b" then
return _HWD_IMAGE_COLOR_TABLE[12];
elseif c == "c" then
return _HWD_IMAGE_COLOR_TABLE[13];
elseif c == "d" then
return _HWD_IMAGE_COLOR_TABLE[14];
elseif c == "e" then
return _HWD_IMAGE_COLOR_TABLE[15];
elseif c == "f" then
return _HWD_IMAGE_COLOR_TABLE[16];
else
-- TODO: ERROR FUNCTION
print("TESTVALUE:",c);
end
end
function CREATE_BUFFER()
_HWD_IMAGE[_HWD_IMAGE_VALUE] = {};
for h = 0,_HWD_IMAGE_SIZE_H do
_HWD_IMAGE[_HWD_IMAGE_VALUE][h] = {};
for w = 0,_HWD_IMAGE_SIZE_W do
_HWD_IMAGE[_HWD_IMAGE_VALUE][h][w] = "1".._HWD_IMAGE_CLEAR_COLOR.." ";
end
end
_HWD_IMAGE_VALUE = _HWD_IMAGE_VALUE + 1;
end
-- GET COLOR OUT OF SEGMENT
function c_3657831591(segment)
_HWD_IMAGE_COLOR = c_4162362989(string.sub(segment,2,2)) or 1;
end
function c_3658832511(segment)
_HWD_IMAGE_COLOR_BACKGROUND = c_4162362989(string.sub(segment,1,1)) or 1;
end
-- GET COLOR OUT OF SEGMENT
function c_7834239045(e)
for i=1,16 do
if e == _HWD_IMAGE_COLOR_TABLE[i] then
return true;
end
end
return false;
end
function this._HWD_IMAGE_WIDHT(w)
if w ~= 0 then
_HWD_IMAGE_SIZE_W = w;
else
-- TODO: ERROR FUNCTION
end
end
function this._HWD_IMAGE_HEIGHT(h)
if h ~= 0 then
_HWD_IMAGE_SIZE_H = h;
else
-- TODO: ERROR FUNCTION
end
end
function this._HWD_IMAGE_GET_HEIGHT()
return _HWD_IMAGE_HEIGHT;
end
function this._HWD_IMAGE_GET_WIDHT()
return _HWD_IMAGE_HEIGHT;
end
function this._HWD_CREATE_IMAGE()
_HWD_IMAGE_COUNT = _HWD_IMAGE_COUNT + 1;
end
function this._HWD_CREATE_IMAGE_BUFFER()
if _HWD_IMAGE_VALUE == _HWD_IMAGE_COUNT then
ERROR("Call _HWD_CREATE_IMAGE");
else
if type(_HWD_IMAGE_SIZE_H) == "number" and type(_HWD_IMAGE_SIZE_W) == "number" then
if _HWD_IMAGE_SIZE_H > 1 and _HWD_IMAGE_SIZE_W > 1 then
CREATE_BUFFER();
else
ERROR(" Invalid size or size not set")
end
else
ERROR(" Invalid type or size not set")
end
end
end
function this._HWD_IMAGE_PLOT(x,y,c)
if y < _HWD_IMAGE_SIZE_H and x < _HWD_IMAGE_SIZE_W then
_HWD_IMAGE[_HWD_ACTUAL_IMAGE][y][x] = c;
end
end
function short(_1,_2)
if _1 < _2 then
return 1;
else
return -1;
end
end
function draw(h,x,y)
c_3657831591(h);
c_3658832511(h);
if string.sub(h,3,3) == " " then
paintutils.drawPixel(x,y,_HWD_IMAGE_COLOR);
else
term.setTextColor(_HWD_IMAGE_COLOR);
term.setBackgroundColor(_HWD_IMAGE_COLOR_BACKGROUND);
term.setCursorPos(x,y);
term.write(string.sub(h,3,3));
term.setTextColor(1);
term.setBackgroundColor(_HWD_IMAGE_CLEAR_COLOR);
end
end
function this._HWD_IMAGE_LINE( x0,y0,x1,y1,c,cb)
local dx = math.abs( x1 - x0 );
local sx = short(x0,x1);
local dy = -math.abs( y1 - y0 );
local sy = short(y0,y1);
local err = dx+dy;
local e2;
while true do
this._HWD_IMAGE_PLOT(x0,y0,c..cb..' ');
if x0 == x1 and y0 == y1 then break; end
e2 = 2*err;
if e2 > dy then err = err + dy; x0 = x0 + sx; end
if e2 < dx then err = err + dx; y0 = y0 + sy; end
end
end
function this._HWD_IMAGE_SAFE_PLOT(x,y,c)
if y < _HWD_IMAGE_SIZE_H and x < _HWD_IMAGE_SIZE_W then
_HWD_IMAGE[_HWD_ACTUAL_IMAGE][y][x] = c;
else
ERROR(" x="..x.." y="..y.." is not in Screen");
end
end
function this._HWD_IMAGE_SWAP()
if _HWD_IMAGE_COUNT-1 == _HWD_ACTUAL_IMAGE then
_HWD_ACTUAL_IMAGE = 1;
else
_HWD_ACTUAL_IMAGE = _HWD_ACTUAL_IMAGE + 1;
end
end
function this.test()
end
function this._HWD_IMAGE_DRAW()
for y=1,_HWD_IMAGE_SIZE_H do
local bf = "";
for x=1,_HWD_IMAGE_SIZE_W do
draw(_HWD_IMAGE[_HWD_ACTUAL_IMAGE][y][x],x,y)
end
end
end
function this._HWD_IMAGE_PRINT(T,colorF,colorB)
for i=1,#T do
this._HWD_IMAGE_PLOT(i,1,colorF..colorB..string.sub(T,i,i));
end
end
return this;
end
local pg = PG('2');
pg._HWD_IMAGE_HEIGHT(15);
pg._HWD_IMAGE_WIDHT(21);
pg._HWD_CREATE_IMAGE();
pg._HWD_CREATE_IMAGE_BUFFER();
pg._HWD_CREATE_IMAGE();
pg._HWD_CREATE_IMAGE_BUFFER();
pg._HWD_IMAGE_LINE(1,1,4,4,'a','a');
pg._HWD_IMAGE_LINE(4,4,5,9,'c','c');
pg._HWD_IMAGE_PRINT("ARMIN",'c','3');
pg._HWD_IMAGE_DRAW();
pg._HWD_IMAGE_SWAP();
pg._HWD_IMAGE_LINE(1,1,4,4,'e','7');
pg._HWD_IMAGE_LINE(4,4,5,9,'c','4');
pg._HWD_IMAGE_PRINT("ARMIN TERZ TERZ",'d','3');
while true do
pg._HWD_IMAGE_SWAP();
pg._HWD_IMAGE_DRAW();
sleep(0.5)
end