Advertisement
Guest User

Untitled

a guest
Aug 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.08 KB | None | 0 0
  1.     def test_line_for_gaps(self):
  2.  
  3.         # __doc__ (as of 2008-06-25) for pygame.draw.line:                                                                                              
  4.  
  5.           # pygame.draw.line(Surface, color, start_pos, end_pos, width=1): return Rect                                                                  
  6.           # draw a straight line segment                                                                                                                
  7.  
  8.         # This checks bug Thick Line Bug #448                                                                                                            
  9.  
  10.         def surrounded_pixels_are_white(p):
  11.             x, y = p
  12.             self.assertEqual(surf.get_at((x+1, y)), (255, 255, 255, 255))
  13.             self.assertEqual(surf.get_at((x, y+1)), (255, 255, 255, 255))
  14.             self.assertEqual(surf.get_at((x-1, y)), (255, 255, 255, 255))
  15.             self.assertEqual(surf.get_at((x, y-1)), (255, 255, 255, 255))
  16.             self.assertEqual(surf.get_at((x+1, y+1)), (255, 255, 255, 255))
  17.             self.assertEqual(surf.get_at((x+1, y-1)), (255, 255, 255, 255))
  18.             self.assertEqual(surf.get_at((x-1, y+1)), (255, 255, 255, 255))
  19.             self.assertEqual(surf.get_at((x-1, y+1)), (255, 255, 255, 255))
  20.  
  21.  
  22.         surf = pygame.Surface((200, 200), pygame.SRCALPHA)
  23.  
  24.         surf.fill((0, 0, 0))
  25.         pygame.draw.line(surf, (255, 255, 255), (50, 50), (140, 0), 30)
  26.         pixel = (51, 49)
  27.         self.assertEqual(surf.get_at(pixel), (255, 255, 255, 255))
  28.         surrounded_pixels_are_white(pixel)
  29.  
  30.         surf.fill((0, 0, 0))
  31.         pygame.draw.line(surf, (255, 255, 255), (50, 50), (0, 120), 30)
  32.         pixel = (49, 51)
  33.         self.assertEqual(surf.get_at(pixel), (255, 255, 255, 255))
  34.         surrounded_pixels_are_white(pixel)
  35.  
  36.         surf.fill((0, 0, 0))
  37.         pygame.draw.line(surf, (255, 255, 255), (50, 50), (199, 198), 30)
  38.         pixel = (51, 52)
  39.         self.assertEqual(surf.get_at(pixel), (255, 255, 255, 255))
  40.         surrounded_pixels_are_white(pixel)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement