pygame draw circlex

import pygame

import sys

# 初始化Pygame

pygame.init()

# 设置窗口尺寸

d = 1000

width, height = 1000+5, 1000+5

screen = pygame.display.set_mode((width, height))

pygame.display.set_caption("Solid Circle with Square")

# 设置颜色

black = (0, 0, 0) # 蓝色

white = (255, 255, 255) # 红色

# 主循环

running = True

import time

st = time.time()

while running:

if time.time()-st>3:

running = False

for event in pygame.event.get():

if event.type == pygame.QUIT:

running = False

# 清除屏幕

screen.fill((255, 255, 255))

# 画一个实心的圆环

pygame.draw.circle(screen, black, (width // 2, height // 2), d/2)

pygame.draw.circle(screen, white, (width // 2, height // 2), d*0.85/2)


 

# 画一个实心的圆环

# 在圆环内画一个实心的正方形

square_size = 50

k = d*0.72/2

square_rect = pygame.Rect((width // 2 - k, height // 2 - k/10, 2*k, k/5))

pygame.draw.rect(screen, black, square_rect)


 

square_rect = pygame.Rect((width // 2 - k/10, height // 2 - k, k/5,2*k))

pygame.draw.rect(screen, black, square_rect)

pygame.image.save(screen,'circlex.png')

# pygame.quit()

# 刷新屏幕

pygame.display.flip()

# 退出Pygame

pygame.quit()

sys.exit()

import pygame
import sys

# 初始化Pygame
pygame.init()

# 设置窗口尺寸

d = 1000
width, height = 1000+5, 1000+5
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Solid Circle with Square")

# 设置颜色
black = (0, 0, 0)  # 蓝色
white = (255, 255, 255)  # 红色

# 主循环
running = True
import time
st = time.time()
while running:
    if time.time()-st>3:
        running = False
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    # 清除屏幕
    screen.fill((255, 255, 255))

    # 画一个实心的圆环

    pygame.draw.circle(screen, black, (width // 2, height // 2), d/2)
    pygame.draw.circle(screen, white, (width // 2, height // 2), d*0.85/2)


    # 画一个实心的圆环
    # 在圆环内画一个实心的正方形
    square_size = 50
    k = d*0.72/2
    square_rect = pygame.Rect((width // 2 - k, height // 2 - k/10, 2*k, k/5))
    pygame.draw.rect(screen, black, square_rect)


    square_rect = pygame.Rect((width // 2 - k/10, height // 2 - k, k/5,2*k))
    pygame.draw.rect(screen, black, square_rect)

    pygame.image.save(screen,'circlex.png')
    # pygame.quit()

    # 刷新屏幕
    pygame.display.flip()

# 退出Pygame
pygame.quit()
sys.exit()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值