Advertisement
Guest User

test.py

a guest
Jun 25th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. # mouse handling
  2. import pygame,sys
  3. pygame.init()
  4. global size,color
  5. fps = 60
  6. fpsclock = pygame.time.Clock()
  7. def size():
  8. global size
  9. size = int(input('Enter the size of pencil :'))
  10.  
  11. def color():
  12. global color
  13. print('we use RGB color...')
  14. R = int(input('Enter part R :'))
  15. G = int(input('Enter part G :'))
  16. B = int(input('Enter part B :'))
  17. color = (R,G,B)
  18.  
  19.  
  20. # set up color
  21. # R G B
  22. white = (255,255,255)
  23. black = ( 0, 0, 0)
  24. blue = ( 0, 0,255)
  25.  
  26. def draw(): # draw line like the legend paint xp
  27. # set up window
  28.  
  29. pygame.display.set_caption('Pencil_Paint_Xp')
  30. surf = pygame.display.set_mode((640,480))
  31. pos1 = (0,0)
  32. pos2 = (1,1)
  33. surf.fill(black)
  34. a = 0
  35. # setting the size of the pencil and color
  36. size()
  37. color()
  38. print('you can change size and color by pressing SPACE button ')
  39. while True:
  40.  
  41. for event in pygame.event.get():
  42. if event.type == pygame.MOUSEBUTTONDOWN:
  43. pos1 = event.pos
  44.  
  45. a = event.button
  46. if a == 1:
  47. pos2 = pygame.mouse.get_pos()
  48.  
  49.  
  50. pygame.draw.line(surf,color,pos1,pos2,size)
  51. pos1 = pos2
  52. if event.type == pygame.MOUSEBUTTONUP:
  53. a = 0
  54. if event.type == pygame.KEYDOWN:
  55. if event.unicode == ' ':
  56. size()
  57. color()
  58. #draw line with pos1 and pos2
  59.  
  60. if event.type == pygame.QUIT:
  61. pygame.quit()
  62. sys.exit()
  63. pygame.display.update()
  64.  
  65.  
  66. fpsclock.tick(fps)
  67.  
  68. draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement