猫史档案馆


【Python作品分享】在鼠标点击的位置画圆 - 副本【作品秀】

用户:宇宙中的星系宇宙中的星系查看:0 回复:0 评论:0 创建时间:2023-08-09T21:30:38


【作品展示】

center_image

 

【作品介绍】

与前者的不同之处在于:能连续性绘画

 

【作品源代码】

import pygame


pygame.init()
screen = pygame.display.set_mode([800,600])
reb = (255,0,0)
keep_going = True
radius = 15
mousebutton = False
pygame.display.set_caption("在点击的位置绘制圆点")
while keep_going:
    for event in pygame.event.get():
        if (event.type == pygame.QUIT):
            keep_going = False
        if (event.type == pygame.MOUSEBUTTONDOWN):
            mousebutton = True
        if (event.type == pygame.MOUSEBUTTONUP):
            mousebutton = False
    if (mousebutton == True):
        spot = pygame.mouse.get_pos()
        pygame.draw.circle(screen,reb,spot,radius)
    pygame.display.update()
pygame.quit()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页