zoukankan      html  css  js  c++  java
  • 使用turtle库画图

    import turtle

    # 设置启动窗体的大小和位置,宽度高度,起始点的位置(后两者可选),不是必须的
    turtle.setup(650,350,200,200)
    # turtle.goto(100,100) 去某个地方,绝对坐标


    turtle.penup()
    turtle.fd(-250) # 正前方向
    # turtle.bk(-100) # 后退方向,左侧
    turtle.pendown()
    turtle.pensize(25)
    turtle.pencolor('purple')
    turtle.seth(-40) # angle 改变海龟的前进方向,只改变方向
    for i in range(4):
    turtle.circle(40,80)
    turtle.circle(-40,80)

    turtle.circle(40,80/2) # 以海龟当前的位置左侧的某个点为圆心,曲线运行angle角度

    # turtle的角度坐标体系 0 90 180 270 360 -90 -180 -270 绝对角度
    turtle.fd(40)
    turtle.circle(16,180)
    turtle.fd(40*2/3)
    turtle.done() # 程序不自动退出

    # turtle.left(angle) 海龟角度坐标
    # turtle.right(angle)
    # turtle.colormode(mode) 1.0位rgb小数255整数值


    # 画笔控制
    # turtle.penup() up()
    # turtle.pendown() pd() 飞行不绘图
    # turtle.pensize() 画笔宽度,海龟腰围
    # turtle.width() 别名,画笔
    # turtle.pencolor(color) 色彩
    # 字符串——‘色彩,小写’
    # 小数值——0.63,0.13,0.94
    # 元祖值——(0.63,0.13,0.94)
    # 运动控制函数
    # turtle.forward(d) fd() # 向前行进
    # turtle.circle(r,extent=None) 根据半径r回执extent角度的弧形
    # r默认圆心在海龟左侧r距离的位置
    # 绘制角度,默认是360度整数圆
    # 方向控制函数
    # turtle.setheading() seth()
    # turtle.left() 左转
    # turtle.right()
  • 相关阅读:
    C++Builder中的异常传递
    lpc1343 usb isp not work in linux and mac
    玩玩Hiweed linux 2.0
    有关 stringWithString 和 initWithString
    Windows mobile 中获取内存使用情况
    玩玩xubuntu 8.10
    升级我的ipaq hx2110到Windows Mobile 6.0
    面试技巧 from IBM
    常用Sql语句
    c#的事件机制示例代码: 猫> 老鼠, 主人
  • 原文地址:https://www.cnblogs.com/Sksitigarbha/p/10152753.html
Copyright © 2011-2022 走看看