turtle draw isosceles triangle

 

Use turtle to draw the first example-isosceles triangle

The commands used are:

title sets the title of the turtle drawing

bgcolor sets the background color of the turtle drawing display window

screensize() sets the size of the turtle drawing window

seth() sets the direction of the turtle (actually the same way as when looking at the map: up, north, down, south, left, west, right east, the corresponding angles are 0°, 90°, 180°, 270°)

pensize() sets the thickness of the pen

hideturtle() hide the brush

pendown() The pen drops and starts painting

color() sets the brush color and fill color

begin_fill() to start filling

forward() to move towards

left() turn left

end_fill() end fill

done()

from turtle import *#将turtle海龟画图的全部方法导入到python编程环境中
title('画一个等腰三角形')#设置海龟画图的标题为  画一个等腰三角形
bgcolor('red')#设置海龟画图显示窗口的背景颜色为红色
screensize(800,800)#设置海龟画图窗口的大小为,宽度800,高度800
seth(0)#设置海龟的朝向为0即往右.
pensize(10)#设置画笔的粗细为10
hideturtle()#隐藏画笔
pendown()#画笔落下,开始作画
color('blue','yellow')#设置画笔颜色和填充颜色为蓝色和黄色
begin_fill()#开始填充
forward(300)#向右移动300个像素
left(120)#向左转120°(转的是外角。因为画笔朝向是朝右的,而三角形的内角和为180°,等腰三角的内角为60°,那么就要让画笔转动180°减60°即向左上方转动120°即能保证内角的度数为60°)
forward(300)#向左上方移动300个像素
left(120)#向左转120°
forward(300)#向左下方移动300个像素
end_fill()#结束填充
done()

 

 

Guess you like

Origin blog.csdn.net/weixin_43115314/article/details/114068314