python学习turtle(笔控制)
2018-08-13 11:32
253 查看
学习记录,
笔控制
“shown”: True/False
“pendown”: True/False
“pencolor”: color-string or color-tuple
“fillcolor”: color-string or color-tuple
“pensize”: positive number
“speed”: number in range 0..10
“resizemode”: “auto” or “user” or “noresize”
“stretchfactor”: (positive number, positive number)
“outline”: positive number
“tilt”: number
可以是,fillcolor(colorstring)像"violet","#33cc8c";fillcolor((r, g, b));fillcolor(r, g, b)。
配合begin_fill()和end_fill()使用。
运行到turtle.end_fill()填充。
arg要写入的文本,move是否向右移动,align文本对齐,font字体大小,格式...元组。
试画下简单的图;
如图;
笔控制
turtle.
pendown()
turtle.
pd()
turtle.
down(),下笔,移动时绘画。
turtle.
penup()
turtle.
pu()
turtle.
up(),拿起笔,移动时不绘画。
turtle.
pensize(width=None)
turtle.
width(width=None),返回或者设置笔画宽度。
turtle.
pen(pen=None, **pendict),设置笔的属性。
“shown”: True/False
“pendown”: True/False
“pencolor”: color-string or color-tuple
“fillcolor”: color-string or color-tuple
“pensize”: positive number
“speed”: number in range 0..10
“resizemode”: “auto” or “user” or “noresize”
“stretchfactor”: (positive number, positive number)
“outline”: positive number
“tilt”: number
turtle.
isdown(),是否下笔,下笔返回True,提起笔False。
turtle.
fillcolor(*args),返回或设置填充颜色。
可以是,fillcolor(colorstring)像"violet","#33cc8c";fillcolor((r, g, b));fillcolor(r, g, b)。
配合begin_fill()和end_fill()使用。
运行到turtle.end_fill()填充。
turtle.
color(*args),返回或设置笔的颜色和填充的颜色。
color(colorstring1, colorstring2),
color((r1,g1,b1), (r2,g2,b2)),等效于pencolor(colorstring1)和
fillcolor(colorstring2)
turtle.
filling(),返回填充状态,有设置开始填充返回True,否则返回False。
turtle.
begin_fill(),开始填充位置。
turtle.
end_fill(),结束填充位置。
turtle.
reset(),重置,龟返回原点并清除已绘屏,
turtle.
clear(),清除已绘屏,龟当前状态和位置不变。
turtle.
write(arg, move=False, align="left", font=("Arial", 8, "normal")),写入文本。
arg要写入的文本,move是否向右移动,align文本对齐,font字体大小,格式...元组。
试画下简单的图;
import turtle as t t.home() #开始原点 t.fillcolor('violet') #填充颜色 t.penup() #拿起笔 t.begin_fill() #开始填充violet色 t.stamp() #当前位置复制龟图形 t.fd(100) #向前移100 t.setheading(90) #设置指向角度90 t.stamp() t.fd(100) t.lt(90) #向左转90度 t.end_fill() #结束填充 t.fillcolor('cyan') t.stamp() t.begin_fill() t.fd(100) t.lt(90) t.stamp() t.fd(100) t.end_fill() t.home() ##画另一个图 t.setpos(0,-150) #移到坐标0,-150 t.pendown() #放下笔开始绘 t.pencolor('violet') #设笔颜色 for i in range(0,24): t.forward(100) t.left(105) t.stamp()
如图;
相关文章推荐
- python初级学习之基于收发邮件的远程控制程序
- python学习笔记9--用turtle简单绘图2
- Python 学习笔记 (2)—— 流程控制
- python学习笔记1--turtle
- Python 学习从入门到放弃(三)--变量与函数基础、基础控制语句
- Python学习笔记(3)控制结构
- python学习7-流程控制-循环控制
- python基础学习总结——方法、控制语句
- python学习之Turtle 3
- Python 学习笔记之流程控制
- python基础学习4- 控制语句
- [Python学习] Django 权限控制
- Day1 Python基础学习——概述、基本数据类型、流程控制
- Python学习笔记(3)控制结构
- 海龟绘图-python turtle学习笔记2
- python学习笔记二:流程控制
- Python模块学习 ---- threading 多线程控制和处理
- 轻松学习python part2-控制语句
- Python 学习笔记 - 12.流程控制(Control Flow)
- python学习turtle(告诉龟的状态,量度设置)