Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --(C) Corona 2013
- --DO NOT STEAL THIS CODE!!!
- local ver = 0.36
- function version()
- return ver
- end
- function about()
- print("--------------------------------------------------")
- print("Screen API Version "..version().." (C) Corona 2013")
- print("--------------------------------------------------")
- end
- function drawButton(button,boolCenter)
- xStart=button["x1"]
- xEnd=button["x2"]
- yStart=button["y1"]
- yEnd=button["y2"]
- x=xEnd-xStart
- y=yEnd-yStart
- term.setCursorPos(xStart,yStart)
- if (button["color"] ~= nil) and (term.isColor()) then
- term.setBackgroundColor(button["color"])
- else
- term.setBackgroundColor(colors.white)
- end
- if (button["textcolor"] ~= nil) and (term.isColor()) then
- term.setTextColor(button["textcolor"])
- else
- term.setTextColor(colors.white)
- end
- for j=0,y do
- for i=0,x do
- term.write(" ")
- end
- term.setCursorPos(xStart,yStart+j)
- end
- if (button["text"] ~= nil) and (term.isColor()) then
- if boolCenter then
- textCentery=(yStart+math.floor(y/2))
- textCenterx=(math.ceil((xStart+(x/2)))-math.ceil((string.len(button["text"])/2)))
- term.setCursorPos(textCenterx,textCentery)
- else
- term.setCursorPos(xStart,yStart)
- end
- term.write(button["text"])
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- end
- function drawBox(area)
- x1 = area["x1"]
- x2 = area["x2"]
- y1 = area["y1"]
- y2 = area["y2"]
- xSpan = x2-x1
- ySpan = y2-y1
- cornerCount = 1
- if area["color"] ~= nil and term.isColor() then
- term.setBackgroundColor(area["color"])
- else
- term.setBackgroundColor(colors.white)
- end
- term.setCursorPos(x1,y1)
- for j=1,ySpan do
- for i=0,xSpan do
- if (cornerCount == 1) or (cornerCount == ySpan) or (i == 0) or (i == xSpan) then
- term.write(" ")
- else
- local tx,ty = term.getCursorPos()
- term.setCursorPos(tx+1,ty)
- end
- end
- cornerCount = cornerCount+1
- term.setCursorPos(x1,y1+j)
- end
- end
- function pressed(object,x,y)
- if (object["x2"]-object["x1"]<2) or (object["y2"]-object["y1"]<2) then
- if (object["x1"]-1<=x) and (object["x2"]>=x) and (object["y1"]<=y) and (object["y2"]>=y) then
- return true
- else
- return false
- end
- elseif (object["x2"]-object["x1"]>=2) or (object["y2"]-object["y1"]>=2) then
- if (object["x1"]-1<x) and (object["x2"]>x) and (object["y1"]-1<y) and (object["y2"]-1>y) then
- return true
- else
- return false
- end
- end
- end
- function cls()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- end
- function getFocus(area)
- term.setCursorPos(area["x1"]+1,area["y1"]+1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement