class Star ---------- Star(center, radius, numPoints) # center - Point at the center of the star # radius - distance from center Point to any of # the star's points # numPoints - an int where 4 <= numPoint <= 100 draw(graphwin) move(dx, dy) setFill(color) setOutline(color) setWidth(width) undraw() getPoints() # return a list of the Points that make up the star clone()
The following program imports the Zelle graphics library and the Star class, creates an 11-pointed star with radius 100 centered at the point (200, 200), stores this Star in the variable mystar, colors mystar yellow, and then draws it to a graphics window:
""" This program prints an 11-pointed yellow star in the middle of a graphics window. """ from graphics import * from star import * def main(): width = 400 height = 400 window = GraphWin("Yellow star", width, height) mystar = Star(Point(width/2, height/2), width/4, 11) mystar.setFill("yellow") mystar.draw(window) window.getMouse() main()