Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. pygame.draw.arc(screen, blue, [center[0] - 120, center[1] - 120, 240, 240], pi/2, pi/2+pi*i*koef, 15)
  2. pygame.gfxdraw.aacircle(screen, center[0], center[1], 105, black)
  3. pygame.gfxdraw.aacircle(screen, center[0], center[1], 120, black)
  4.  
  5. import pygame
  6. from pygame.locals import *
  7. import pygame.gfxdraw
  8. import math
  9.  
  10. # Screen size
  11. SCREEN_HEIGHT = 350
  12. SCREEN_WIDTH = 500
  13.  
  14. # Colors
  15. BLACK = (0, 0, 0)
  16. WHITE = (255, 255, 255)
  17. GREY = (150, 150, 150)
  18. RED = (255,0,0)
  19.  
  20.  
  21. # initialisation
  22. pygame.init()
  23. screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
  24. done = False
  25. clock = pygame.time.Clock()
  26.  
  27. # We need this if we want to be able to specify our
  28. # arc in degrees instead of radians
  29. def degreesToRadians(deg):
  30. return deg/180.0 * math.pi
  31.  
  32. # Draw an arc that is a portion of a circle.
  33. # We pass in screen and color,
  34. # followed by a tuple (x,y) that is the center of the circle, and the radius.
  35. # Next comes the start and ending angle on the "unit circle" (0 to 360)
  36. # of the circle we want to draw, and finally the thickness in pixels
  37. def drawCircleArc(screen,color,center,radius,startDeg,endDeg,thickness):
  38. (x,y) = center
  39. rect = (x-radius,y-radius,radius*2,radius*2)
  40. startRad = degreesToRadians(startDeg)
  41. endRad = degreesToRadians(endDeg)
  42.  
  43. pygame.draw.arc(screen,color,rect,startRad,endRad,thickness)
  44.  
  45.  
  46. # fill screen with background
  47. screen.fill(WHITE)
  48. center = [150, 200]
  49. pygame.gfxdraw.aacircle(screen, center[0], center[1], 105, BLACK)
  50. pygame.gfxdraw.aacircle(screen, center[0], center[1], 120, BLACK)
  51.  
  52. pygame.display.update()
  53.  
  54. step = 10
  55. maxdeg = 0
  56.  
  57. while not done:
  58. for event in pygame.event.get():
  59. if event.type == pygame.QUIT:
  60. done = True
  61.  
  62. maxdeg = maxdeg + step
  63. for i in range(min(0,maxdeg-30),maxdeg):
  64. drawCircleArc(screen,RED,(150,200),119,i+90,max(i+10,maxdeg)+90,14)
  65. #+90 will shift it from starting at the right to starting (roughly) at the top
  66. pygame.display.flip()
  67.  
  68. clock.tick(2) # ensures a maximum of 60 frames per second
  69.  
  70. pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement