设置画笔形状

import turtle
turtle.shape('turtle')

 自带的形状

import turtle
turtle.getshapes()
['arrow', 'blank', 'circle', 'classic', 'square', 'triangle', 'turtle']

注册形状

1.自定义形状名称,自定义形状

2.导入gif格式图片,形成名称为文件名,注意:图片格式不对需要使用转换格式软件转换

import turtle
print(turtle.getshapes()) # 打印所有形状
turtle.register_shape("001", ((25, -3), (0, 15), (-25, -3))) # 注册自定义形状,名字为001
turtle.register_shape("b.gif")  # 注册形状为图片,名字为b.gif
turtle.shape('b.gif')  #设置画笔形状
print(turtle.getshapes())  # 打印所有形状
turtle.done()
['arrow', 'blank', 'circle', 'classic', 'square', 'triangle', 'turtle']
['001', 'arrow', 'b.gif', 'blank', 'circle', 'classic', 'square', 'triangle', 'turtle']

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐