-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c8bec7
commit f4f92d1
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
) |