Draw Five Pointed Star

#! python                      # windows 10
#!/usr/bin/python3             # linux
# ===================================================================
# draw a five pointed star (points - lines)
# ===================================================================
# try:   6 lines & points
#        7 lines & points
#       12 lines & points
#        6 points and 5 lines
#        5 points and 6 lines
#       draw each line a different color  
# ===================================================================

import numpy as np
import draw_axes as ax
import coordinate_conversion as cc
import user_interface as ui
from graphics import *

points = 5                     # number of points in star
lines  = 5                     # number of lines  in star
radius = 200.0                 # distance from plot origin

# -------------------------------------------------------------------
# ---- draw points
# -------------------------------------------------------------------

def draw_points(win,pts):

    for p in pts:

        c = Circle(p,4)
        c.setFill('black')
        c.draw(win)

# -------------------------------------------------------------------
# ----- draw lines
# -------------------------------------------------------------------

def draw_lines(win,pts):

    i = 0                      # start of line
    j = 2                      # end of line

    for _ in range(lines):

        l = Line(pts[i],pts[j])
        l.setWidth(3)
        l.setFill('black')
        l.draw(win)

        i = (i+1) % points     # do not exceed size of list
        j = (j+1) % points     # do not exceed size of list

# -------------------------------------------------------------------
# ---- calculate star's points
# -------------------------------------------------------------------

def calculate_star_points(win,points):

    angle = 0.0                # starting angle
    pts   = []                 # point list

    for _ in range(points):

        rad = np.deg2rad(angle)

        x = np.sin(rad) * radius
        y = np.cos(rad) * radius

        (wx,wy) = cc.center_to_win_coords(x,y,win.width,win.height)

        pts.append(Point(wx,wy))

        angle += 360.0/points

    return pts

# -------------------------------------------------------------------
# ---- main
# -------------------------------------------------------------------

# ---- start drawing

win = GraphWin("Five Pointed Star", 801, 801)
win.setBackground("white")

ax.draw_xy_axes(win,True)

# ---- calculate star's points

pts = calculate_star_points(win,points)

# ---- draw five pointed star

draw_points(win,pts)

draw_lines(win,pts)

# ---- wait then exit

ui.pause()

win.close()