猫史档案馆


【Python作品分享】现代艺术【作品秀】

用户:开朗的金冠泥lmT-开朗的金冠泥lmT-查看:0 回复:2 评论:0 创建时间:2021-08-17T23:50:13


【作品展示】

center_image

 

【作品介绍】

不错的现代艺术作品。有点像蒙德里安的风格。

 

【作品源代码】

import random
import time
import pygame


def art_1():
    pygame.init()
    screen = pygame.display.set_mode([1200,800])
    screen.fill([255,255,255])
    colors = [(255,0,0), (255,255,0), (0,0,255), (0,0,0)]
    for i in range(400):
        width = random.randint(0, 250)
        height = random.randint(0, 300)
        top = random.randint(0, 800)
        left = random.randint(0, 1200)
        line_width = random.randint(1, 5)
        color_name = random.choice(colors)
        pygame.draw.rect(screen,color_name,[left,top,width,height],line_width)
    pygame.display.flip()
    running = True
    while running:
        for j in pygame.event.get():
            if j.type == pygame.QUIT:
                running = False
    pygame.quit()

def art_2():
    pygame.init()
    screen = pygame.display.set_mode([1200,800])
    colors_2 = [(255,0,0), (255,255,0), (0,0,255), (255,255,255)]
    for i_2 in range(400):
        width_2 = random.randint(0, 250)
        height_2 = random.randint(0, 300)
        top_2 = random.randint(0, 800)
        left_2 = random.randint(0, 1200)
        line_width_2 = random.randint(1, 5)
        color_name_2 = random.choice(colors_2)
        pygame.draw.rect(screen,color_name_2,[left_2,top_2,width_2,height_2],line_width_2)
    pygame.display.flip()
    running = True
    while running:
        for j_2 in pygame.event.get():
            if j_2.type == pygame.QUIT:
                running = False
    pygame.quit()

time.sleep(2)
print('-' * 60)
watch = input('此处有两幅相似的现代艺术作品,你想先看哪幅?(输入数字1或2)')
if watch == '1':
    print('-' * 60)
    art_1()
    print('正在切换另一幅现代艺术作品......')
    time.sleep(3)
    print('-' * 60)
    art_2()
elif watch == '2':
    print('-' * 60)
    art_2()
    print('正在切换另一幅现代艺术作品......')
    time.sleep(3)
    print('-' * 60)
    art_1()
else:
    print('-' * 60)
    print('输入有误,请重新运行程序再试!')
    print('-' * 60)

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
xAkidxxAkidx

低情商:画的什么玩意

高情商:这位崇高的金贵喵站up主画的英美绝伦的世纪大作,是一个非常现代的艺术作品,让鄙人很是捉摸不透呢

我:这(喵喵)不就是作业贴吗,,,,(((())))

点赞0


评论


开朗的金冠泥lmT-开朗的金冠泥lmT-

画着好玩而已......imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%BF%BB%E7%99%BD%E7%9C%BC.gif"alt="emotion_编程猫_翻白眼"

点赞0


评论