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学习笔记之open()函数打开文件路径报错问题

Python判断一个集合是否为另一个集合的子集方法

r语言处理数据比Python慢吗

Python中tuple和list的区别

如何调试Python代码

Python的序列之列表的通用方法

Python中eval有什么用

Python怎么把两个列表合并

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




打赏

取消

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

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

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

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

评论

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