Advertisement
1nikitas

Untitled

Apr 6th, 2022
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. class MyImageDraw(ImageDraw):
  2.     def regular_polygon(self, center_coords, sides, radius, rotation=0, fill=None,
  3.                         outline=None):
  4.         dots = []
  5.         angle = 0 - rotation
  6.         while angle < 2 * pi - rotation:
  7.             dots.append((int(-sin(angle) * radius + center_coords[0]),
  8.                          int(cos(angle) * radius + center_coords[1])))
  9.             angle += 2 * pi / sides
  10.         self.polygon((*dots,), fill, outline)
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement