""" 绕中心点旋转之五角星 本程序首先算出10个点的坐标,然后把这个形状注册到屏幕的形状字典 """ import math from turtle import * R = 30 r = R * math.sin(math.radians(18))/math.sin(math.radians(36)) points = [] for k in range(5): outx = R * math.cos(math.radians(72*k+36)) outy = R * math.sin(math.radians(72*k+36)) points.append((outx,outy)) innerx = r * math.cos(math.radians(72*k+36+36)) innery = r * math.sin(math.radians(72*k+36+36)) points.append((innerx,innery)) screen = Screen() star = Shape('polygon',points) screen.addshape('star',star) t = Turtle() t.shape('star') while 1: t.right(1)
李兴球
李兴球的博客是Python创意编程原创博客