-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPU.lua
121 lines (108 loc) · 3.38 KB
/
GPU.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
--{ Maded by: GamerJhPlays }--
--{ Graphic api for computercraft 1.80 }--
--{ Free to use }--
function setScreen(side) --Sets default screen
screen = peripheral.wrap(side)
end
function setPixelSize(size) --Sets size of screen pixels and clear screen
screen.setTextScale(size)
clearScreen()
end
function defaultBackground(c) --Sets default background color for use in clearScreen()
dfbg = c
end
function setBackgroundColor(c) --Changes background color
screen.setBackgroundColor(c)
end
function clearScreen() --Clears screen and set to default background color
screen.setBackgroundColor(dfbg)
screen.clear()
end
function getSize() --Returns size of screen
size = screen.getSize()
return size
end
function testScreen() --Tests screen with every colors
screen.setBackgroundColor(colors.white)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.orange)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.magenta)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.lightBlue)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.yellow)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.lime)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.pink)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.gray)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.lightGray)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.cyan)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.purple)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.blue)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.brown)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.green)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.red)
screen.clear()
sleep(1)
screen.setBackgroundColor(colors.black)
screen.clear()
sleep(1)
end
function drawRect(x1,y1,x2,y2,c) --Draw a rectangle in screen (x2 needs be greater then x1 and y2 needs be greater then y1
for x = x1, x2 do
for y = y1, y2 do
screen.setCursorPos(x,y)
screen.setBackgroundColor(c)
screen.write(' ')
screen.setBackgroundColor(dfbg)
end
end
end
function drawPixel(x,y,c) --Draw a single pixel in the specified coodinates
screen.setCursorPos(x,y)
screen.setBackgroundColor(c)
screen.write(' ')
screen.setBackgroundColor(dfbg)
end
function write(x,y,c,msg) --Write a message on screen
screen.setTextColor(c)
screen.setCursorPos(x,y)
screen.write(msg)
end
function getTouch() --Gets touched point in screen
e, s, xPos, yPos = os.pullEvent('monitor_touch')
return xPos, yPos
end
function turnoff() --Clear the screen and end the program
clearScreen()
screen.setCursorPos(1,1)
screen.setTextColor(colors.green)
screen.write('Good bye...')
sleep(0.5)
clearScreen()
exit()
end