python中如何给图形填充颜色


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

import turtle as t

import random as r

def pink():

    color = (1, r.random(), 1)

    return color

def randomrange(min, max):

    return min + (max- min)*r.random()

def moveto(x, y):

    t.penup()

    t.goto(x, y)

    t.pendown()

def heart(r, a):

    factor = 180

    t.seth(a)

    t.circle(-r, factor)

    t.fd(2 * r)

    t.right(90)

    t.fd(2 * r)

    t.circle(-r, factor)

t.setup(800, 800, 200, 200)

t.speed(9)

t.pensize(1)

t.penup()

for i in range(20):

    t.goto(randomrange(-300, 300), randomrange(-300, 300))

    t.begin_fill()

    t.fillcolor(pink())

    heart(randomrange(10, 50), randomrange(0, 90))

    t.end_fill()

moveto(400, -400)

t.done()

结果如下:

1561174801(1).png

以上就是python中如何给图形填充颜色的详细内容,更多文章请关注木庄网络博客!!

返回前面的内容

相关阅读 >>

Python中如何重命名多个文件

Python怎么新建文件夹

Python中del是什么意思?

Python操作mysql代码总结

Python如何创建指定范围的数字列表?(代码示例)

Python怎么判断数据类型

Python语言的特点是什么

聊聊Python装饰器

str Python是什么意思

Python回车不能换行而是执行怎么办

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...