Wav

drawingTool

Wav
Sep 7th, 2013
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. --[[system.bindMouse("Thewav",true)
  2.  
  3. players={}
  4.  
  5. players["Thewav"]=
  6. {
  7.     firstPoint=nil
  8. }
  9.  
  10. id=1
  11.  
  12. function eventMouse(name,xCursor,yCursor)
  13.     if(not players[name].firstPoint)then
  14.         tfm.exec.chatMessage("First Point set:"..xCursor.."-"..yCursor,name)   
  15.         players[name].firstPoint={x=xCursor,y=yCursor}
  16.     else
  17.         drawLine(players[name].firstPoint,{x=xCursor,y=yCursor},1) 
  18.         players[name].firstPoint = nil
  19.     end
  20. end
  21. --]]
  22.  
  23.  
  24. function drawLine(point1,point2,res)
  25.     a=(point1.y-point2.y)/(point1.x-point2.x)
  26.     b=point1.y-a*point1.x
  27.     if(point1.x>point2.x) then point1,point2=point2,point1 end
  28.     for i=point1.x,point2.x,res do
  29.         ui.addTextArea(id,"",nil,i,a*i+b, 1, 1, "0xF20F0F", "0xF20F0F")
  30.         id=id+1
  31.     end
  32. end
  33.  
  34. function drawCircle(point1,point2)
  35.     r=math.sqrt(math.pow((point1.x-point2.x),2)+math.pow((point1.y-point2.y),2))
  36.     res=1-r*math.pow(10,-2)
  37.     if(res<0.1)then res =0.1 end
  38.     for i=0,2*math.pi,res do
  39.         ui.addTextArea(id,"",nil,point1.x+r*math.cos(i),point1.y+r*math.sin(i), 1, 1, "0xF20F0F", "0xF20F0F")
  40.         id=id+1
  41.     end
  42. end
Advertisement
Add Comment
Please, Sign In to add comment