绘制圆形
# 绘制圆形import pygame
import sys
from pygame.locals import *
pygame.init()
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREY = (128, 128, 128)
YELLOW = (255, 255, 0)
BLUE = (0, 0, 255)
GREEN = (0, 128, 0)
size = width, height = 640, 200
screen = pygame.display.set_mode(size)
pygame.display.set_caption('FishC Demo')
position = size//2, size//2
radius = 50
clock = pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()
screen.fill(WHITE)
pygame.draw.circle(screen, RED, position, radius, 1)
pygame.display.flip()
clock.tick(10)
------------------------------------------
Windows 10 专业版 | Python 3.7.6
------------------------------------------
【我的问题】
1、position = size//2, size//2是否等同于position = width // 2, height // 2,都是定义圆形的中心点(即圆心)?
2、此时若想打印圆心的坐标,应如何写代码呢? position = size//2, size//2 这不就是坐标? ba21 发表于 2022-7-12 23:26
position = size//2, size//2 这不就是坐标?
哦,谢谢大神。那position = size//2, size//2是否等同于position = width // 2, height // 2,都是定义圆形的中心点(即圆心)的坐标? lzb1001 发表于 2022-7-13 08:25
哦,谢谢大神。那position = size//2, size//2是否等同于position = width // 2, height // 2, ...
是的 ba21 发表于 2022-7-13 09:08
是的
谢谢大神的指点
页:
[1]