Python turtle.dot()用法及代码示例 您所在的位置:网站首页 笔画点的作用 Python turtle.dot()用法及代码示例

Python turtle.dot()用法及代码示例

2024-07-05 19:20| 来源: 网络整理| 查看: 265

turtle 模块以面向对象和面向过程的方式提供 turtle 图形基元。由于它使用Tkinter作为基础图形,因此需要安装有Tk支持的Python版本。

turtle .dot()

此函数用于绘制具有特定大小和某种颜色的圆点。如果未指定大小,则使用pensize + 4和2 * pensize的最大值。

用法:

turtle.dot(size=None, *color)

参数:

参数 描述 size > = 1的整数(如果给出) color 颜色字符串或数字颜色元组

下面是上述方法的实现和一些示例:

范例1:

Python3 # import package import turtle       # motion turtle.forward(100)    # dot with # 60 diameter # yellow color turtle.dot(60, color="yellow")

输出:

范例2:

Python3 # import package import turtle       # delay the turtle work speed # for better understandings turtle.delay(500)    # hide the turtle turtle.ht()    # some dots with diameter and color turtle.dot(200, color="red") turtle.dot(180, color="orange") turtle.dot(160, color="yellow") turtle.dot(140, color="green") turtle.dot(120, color="blue") turtle.dot(100, color="indigo") turtle.dot(80, color="violet") turtle.dot(60, color="white")    # write text turtle.write("GFG", align="center",              font=('Verdana', 12, 'bold'))

输出:



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有