SHARE
TWEET

CC: exercise9_3

hevohevo May 19th, 2016 (edited) 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- exercise9_3
  2. -- 簡易ペイントプログラム
  3.  
  4. -- Config
  5. local leftColor = colors.red
  6. local rightColor = colors.black
  7.  
  8. -- Functions
  9. function init()
  10.   term.setTextColor(colors.white)
  11.   term.setBackgroundColor(colors.black)
  12.   term.clear()
  13. end
  14.  
  15. function drawPoint(x,y,color)
  16.   term.setBackgroundColor(color)
  17.   term.setCursorPos(x,y)
  18.   term.write(" ")
  19. end
  20.  
  21. -- Main
  22. init()  -- 画面初期化
  23.  
  24. while true do
  25.   local event, button, x, y = os.pullEvent("mouse_drag")
  26.   if button == 1 then
  27.     drawPoint(x, y, leftColor)
  28.   else
  29.     drawPoint(x,y, rightColor)
  30.   end
  31. end
RAW Paste Data
Top