fill命令鲜为人用的参数rect_用fill画彩色格子图_pygame image process

"""
   fill命令鲜为人用的参数rect_用fill画彩色格子图。
   这是一个pygame图像处理小程序。
"""
__author__ = "lixingqiu"
import pygame
from random import randint

width,height = 480,360
image = pygame.Surface((width,height))
rows = 10                     # 定义行数
cols = 10                     # 定义列数
row_height = height//rows     # 每行高度
col_width = width//cols       # 每列宽度

for r in range(0,rows):
    for c in range(0,cols):
        x = r * col_width
        y = c * row_height
        rectangle = pygame.Rect(x,y,col_width,row_height)
        啊 = randint(0,255)
        基 = randint(0,255)
        逼 = randint(0,255)
        image.fill((啊,基,逼),rect = rectangle)

pygame.image.save(image,"c:/彩色格子图形.png")
        

彩色格子图形_pygame lixingqiu image process