单摆模拟_turtle版

"""
   单摆模拟.py
   本程序用海龟画图来模拟一个单摆
"""

__author__ = "李兴球"
__date__ = "2018年9月"

import turtle

turtle.pensize(5)               # 画笔宽度为5
turtle.left(90)                 # 左转90度
turtle.begin_poly()             # 开始记录顶点
turtle.fd(200)                  # 前进200
turtle.right(90)                # 右转90
turtle.circle(20)               # 画圆
turtle.end_poly()               # 结束记录顶点
p = turtle.get_poly()           # 获取顶点元组

screen = turtle.getscreen()
screen.addshape("db",p)         # 添加形状到字典
screen.mode("logo")             # 设来logo模式
screen.delay(2)                 # 延时为2豪秒
turtle.shape("db")              # 形状为db
turtle.clear()                  # 清掉自己所画的
turtle.seth(90)                 # 设置方向为90度
turtle.color("blue")            # 设颜色为蓝色
angle = 0                       # 初始angle为0

You must log in to read the rest of this article. Please log in or register as a user.