猫史档案馆


【Python作品分享】百变万色笔【求助帖】

用户:XY-NOME——HIMXY-NOME——HIM查看:1 回复:3 评论:1 创建时间:2021-06-05T19:45:05


【作品展示】

center_image

 

【作品介绍】

我不知道哪里出了问题,还请各位大佬指导。图片随便找的不要介意。

 

【作品源代码】

import random
import pgzrun


# 导入库

# 空列表
balls = []

# 鼠标移动模块

def on_mouse_move(pos, rel, buttons):

    # 当鼠标左键按下时
    if (mouse.LEFT in buttons):
        # 设置圆的位置、大小和颜色
        # 设置位置
        pos = (pos[0], pos[1])
        radius = 9.9
        # 设置半径大小
        green = random.randint(0, 225)
        red = random.randint(0, 225)
        blue = random.randint(0, 225)
        color = (red, green, blue)
        # 设置颜色
        # 保存所有圆的信息
        ball = [pos, radius, color]
        balls.append(ball)
    # 画图模块

def draw():

    # 设置背景为白色
    screen.fill("white")
    # 画出所有圆
    for ball in balls:
        # 位置
        pos = ball[0]
        # 半径大小
        radius = ball[1]
        # 颜色
        color = ball[2]
        # 画圆点
        screen.draw.filled_circle(pos, radius, color)

# 开始执行指令
pgzrun.go()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
沉着的狼王蛛Ctm0沉着的狼王蛛Ctm0

radius得是整型

点赞1


评论


lsk666666lsk666666

center_image

没问题啊

 

点赞0


评论


Python-happyyyyPython-happyyyy

莫得问题

点赞0


评论