Skip to content

Commit

Permalink
draw circle and concentric circles
Browse files Browse the repository at this point in the history
  • Loading branch information
idling-mind committed Jul 29, 2020
1 parent 2c8bec7 commit f4f92d1
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions draw_shapes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

def draw_circle(ic, x, y, r, color):
"""Function to draw a circle at given center with given
radius and colour
Args:
ic (Draw Object): The Draw object on which the drawing should
be done.
x, y (int): Center of the circle
r (int): Radius of the circle
color: The color of the circle
Returns:
None
"""
x, y, r = int(x), int(y), int(r) # Converting possible floats to int
ic.ellipse([x-r, y-r, x+r, y+r], fill=color)

def concentric_circles(ic, x, y, max_r, circle_count, color, max_opacity):
"""Function to draw concentric circles
Args:
ic: Draw object to which to draw
x, y (int): Center of circles
max_r (int): Max radius of circles
circle_count (int): Number of required circles
color: color of the circle in RGB
max_opacity (int): The max opacity for the innermost circle
Returns:
None
"""
for i in range(circle_count):
draw_circle(
ic,
x, y,
max_r*(circle_count-i)/circle_count,
(*color, int(max_opacity*i/circle_count))
)

0 comments on commit f4f92d1

Please sign in to comment.