Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dial(name, value, vmin, vmax, size)
- local t = {}
- t.name,t.value,t.vmin,t.vmax,t.size = name,value,vmin,vmax, size
- t.lX,t.lY,t.lW,t.lH = 0,0,0,0
- t.showValue = false
- function t.draw(x,y)
- if(t.size == nil or t.size == 0) then t.size = 5 end
- cSize = t.size
- screen.setColor(15,15,15,255)
- screen.drawCircleF(x+cSize,y+cSize,cSize)
- screen.setColor(200,200,200,255)
- screen.drawCircle(x+cSize,y+cSize,cSize)
- grVmax = vmax - vmin
- norValue = t.value / grVmax
- angle = norValue * math.pi * 2 - math.pi/2
- screen.setColor(255,150,0,255)
- screen.drawLine(x+cSize, y+cSize, x+cSize+ math.cos(angle) * cSize,y+cSize + math.sin(angle) * cSize)
- if(t.name ~= nil and t.name ~= "") then
- if(t.showValue == true) then
- textWidth = string.len(t.value) * 4
- screen.setColor(0,0,0,255)
- screen.drawRectF(x + (cSize - textWidth/2) - 1,y+cSize-1, textWidth, 7)
- screen.setColor(200,200,200,255)
- screen.drawText(x + (cSize - textWidth/2) - 1,y+cSize,t.value)
- end
- textWidth = string.len(t.name) * 4
- screen.drawText(x + (cSize - textWidth/2) - 1,y+cSize*2,t.name)
- end
- t.lX, t.lY, t.lW, t.lH = x, y, cSize*2, cSize*2+5
- end
- return t
- end
- function artHorizon(colorR, colorG, colorB, colorA, brightness)
- local t = {}
- t.color = {}
- t.color.r, t.color.g, t.color.b, t.color.a = colorR, colorG, colorB, colorA
- t.brightness = brightness
- t.rValue = 0
- t.pValue = 0
- function t.draw(x,y)
- --dX = math.cos(radValue)+0.5
- --dY = math.sin(radValue)+0.5
- --radValue = t.rValue * (math.pi * 2)
- --rX = math.cos(radValue)
- --rY = math.sin(radValue)
- --screen.drawLine(screen.getWidth()/2, screen.getHeight()/2, screen.getWidth()/2 + rX * 10, screen.getHeight()/2 + rY*10)
- --screen.drawText(0, 0, radValue * (180 / math.pi))
- dY = t.rValue / 0.5
- if(dY < 0) then dYi = dY*-1 else dYi = dY end
- --dYi = math.sin(dYi*(math.pi*2))
- pY = t.pValue / 0.5 + 1
- x1 = screen.getWidth()/4
- y1 = (screen.getHeight()/2)*pY+(screen.getHeight()/2)*((dY*-1)/2)
- x2 = screen.getWidth()/4*3
- y2 = (screen.getHeight()/2)*pY+(screen.getHeight()/2)*dY/2
- y1s = (screen.getHeight()/2)*pY+(screen.getHeight()/2)*(((dY/2)*-1)/2)
- y2s = (screen.getHeight()/2)*pY+(screen.getHeight()/2)*(dY/2)/2
- --x1 = screen.getWidth()/4+(5*rX)
- --y1 = (screen.getHeight()/2)*pY+(10*rY*-1)
- --x2 = screen.getWidth()/4*3-(5*rX-1)
- --y2 = (screen.getHeight()/2)*pY+(10*rY)
- --screen.setColor(209, 95, 43, 100)
- --screen.drawTriangleF(x1, y1, x2, y2, 0, screen.getHeight())
- --screen.drawTriangleF(0, screen.getHeight(), x2, y2, screen.getWidth(), screen.getHeight())
- --screen.setColor(63, 137, 200, 100)
- --screen.drawTriangleF(x1, y1, x2, y2, 0, 0)
- --screen.drawTriangleF(0, 0, x2, y2, screen.getWidth(), 0)
- screen.setColor(t.color.r*t.brightness/2, t.color.g*t.brightness/2, t.color.b*t.brightness/2, t.color.a/t.brightness/2)
- if(t.brightness == 0) then return end
- screen.drawLine(screen.getWidth()/4, screen.getHeight()/2, screen.getWidth()/4*2, screen.getHeight()/2-3)
- screen.drawLine(screen.getWidth()/4, screen.getHeight()/2, screen.getWidth()/4*2, screen.getHeight()/2+3)
- screen.drawLine(screen.getWidth()/4*3, screen.getHeight()/2, screen.getWidth()/4*2, screen.getHeight()/2-3)
- screen.drawLine(screen.getWidth()/4*3, screen.getHeight()/2, screen.getWidth()/4*2, screen.getHeight()/2+3)
- screen.drawCircle(screen.getWidth()/2, (screen.getHeight()/2), 3)
- small = false
- numLines = 20
- for i=0,numLines do
- a = (i-(numLines/2))/(numLines/2)
- if(a < 0) then a = a*-1 end
- a = (a-1)*-1
- a = a*t.brightness+0.1
- screen.setColor(t.color.r * a, t.color.g * a, t.color.b * a, t.color.a * a)
- y1lp = y1-(i-(numLines/2))/numLines*130
- y2lp = y2-(i-(numLines/2))/numLines*130
- y1lps = y1s-(i-(numLines/2))/numLines*130
- y2lps = y2s-(i-(numLines/2))/numLines*130
- if(numLines/2 == i) then
- screen.drawCircle(screen.getWidth()/2, (screen.getHeight()/2)*pY-(i-(numLines/2))/numLines*130, 2)
- screen.drawLine(
- screen.getWidth()/2,
- (screen.getHeight()/2)*pY-(i-(numLines/2))/numLines*130-2,
- screen.getWidth()/2,
- (screen.getHeight()/2)*pY-(i-(numLines/2))/numLines*130+2)
- end
- if(small) then
- screen.drawLine(x1+x1/2, y1lps, x2-(screen.getWidth()-x2)/2, y2lps)
- else
- screen.drawLine(x1, y1lp, x2, y2lp)
- end
- small = not small
- end
- end
- return t
- end
- function isInRect(x,y,w,h,px,py)
- return px>=x and px<=x+w and py>=y and py<=y+h
- end
- dial1 = dial("Vel", 0.5, 0, 1, 10)
- dial2 = dial("Alt", 0.5, 0, 1, 10)
- artHorizon1 = artHorizon(0,255,0,255,1)
- autopilotOn = false
- function onTick()
- -- your code
- dial1.value = input.getNumber(7)
- dial1.vmax = input.getNumber(8)
- dial2.value = input.getNumber(9)
- dial1.vmax = input.getNumber(10)
- artHorizon1.rValue = input.getNumber(11)
- artHorizon1.pValue = input.getNumber(12)
- artHorizon1.brightness = input.getNumber(13)
- autopilotOn = input.getBool(3)
- end
- function onDraw()
- -- your code
- screen.setColor(200,0,0,255)
- artHorizon1.draw(0,0)
- dial1.draw(0,screen.getHeight()-dial1.size*2-5)
- dial2.draw(screen.getWidth()-dial2.size*2,screen.getHeight()-dial2.size*2-5)
- artHorizon1.draw(0,0)
- if(autopilotOn) then
- screen.setColor(0,0,0,255)
- screen.drawRectF(screen.getWidth()/4, screen.getHeight()-10, screen.getWidth()/2, 7)
- screen.setColor(255,150,0,255)
- screen.drawRect(screen.getWidth()/4, screen.getHeight()-10, screen.getWidth()/2, 7)
- screen.drawTextBox(screen.getWidth()/4, screen.getHeight()-10, screen.getWidth()/2, 7, "AP On", 0, 0)
- end
- screen.setColor(255,150,0,255)
- screen.drawTextBox(1, 1, screen.getWidth()/4-1, screen.getHeight()-dial1.size*2-5-1, ""..math.floor(dial1.value).."", -1, -1)
- screen.drawTextBox(screen.getWidth()/4*3+1, 1, screen.getWidth()/4-1, screen.getHeight()-dial2.size*2-5-1, ""..math.floor(dial2.value).."", 1, -1)
Add Comment
Please, Sign In to add comment