"""__author__ == Jefferson"""
import pygame
import math
if __name__ == '__main__':
pygame.init()
size = 900
face = {'cir_heart': (size // 2, size // 2),#脸的圆心
'r': size // 2,#脸的半径
'main_color': (235,201,68),#主色
'mouth_rect': (size//2-int(size*120/144/2),int(size*70/144)-int(size*120/144/2),int(size*120/144),int(size*120/144)),#嘴巴矩形
'mouth_color': (180,29,22),#嘴巴颜色
'width': int(size*3/144),#线条宽度
'eye_rect_l': (int(size*3/144),int(size*30/144),int(size*336/720),int(size*126/360)),#左眼上方轮廓矩形
'eye_rect_r': (int(size*75/144),int(size*30/144),int(size*336/720),int(size*126/360)),#右眼上方轮廓矩形
'eye_rect_r_b': (int(size * 90/144), int(size * 233/720), int(size * 19 / 72), int(size * 50 / 360)),#右眼下方轮廓矩形
'eye_rect_l_b': (int(size * 18/144), int(size * 233/720), int(size * 19 / 72), int(size * 50 / 360)),#左眼下方轮廓矩形
'rect':(int(size * 3/144),int(size*271/720),int(size * 696/720),int(size*66/360)),#遮挡眼睛椭圆下半部分的白色
'eye_circle_l': (int(size * 15/720),int(size*220/720),int(size*95/720),int(size*95/720)),#左眼球黑点
'eye_circle_r': (int(size * 375 / 720), int(size * 220 / 720), int(size * 95 / 720), int(size * 95 / 720)),#右眼球黑点
'eye_lr': (int(size * 262 / 720), int(size * 224 / 720), int(size * 90 / 720), int(size * 90 / 720)),#左眼右眼角弧线
'eye_rr': (int(size * 622 / 720), int(size * 224 / 720), int(size * 90 / 720), int(size * 90 / 720)),#右眼右眼角弧线
'eye_lr_white': (int(size * 275 / 720), int(size * 236 / 720), int(size * 63 / 720), int(size * 63 / 720)),#左眼右眼角白色填充
'eye_rr_white': (int(size * 635 / 720), int(size * 236 / 720), int(size * 63 / 720), int(size * 63 / 720))#右眼右眼角白色挺冲
}
screen = pygame.display.set_mode((size,size))
screen.fill((255, 255, 255))
#画出脸和嘴巴
pygame.draw.circle(screen,face['main_color'], face['cir_heart'], face['r'],0)
pygame.draw.arc(screen,face['mouth_color'],face['mouth_rect'],math.pi*(1+1/24),math.pi*(2-1/24),face['width'])
#左眼
pygame.draw.ellipse(screen, (255, 255, 255), face['eye_rect_l'], 0)
pygame.draw.arc(screen,(0,0,0),face['eye_rect_l'],0,math.pi,face['width'])
pygame.draw.ellipse(screen,face['main_color'],face['eye_rect_l_b'],0)
pygame.draw.arc(screen, (0, 0, 0), face['eye_rect_l_b'], 0, math.pi, face['width'])
#右眼
pygame.draw.ellipse(screen, (255, 255, 255), face['eye_rect_r'], 0)
pygame.draw.arc(screen, (0, 0, 0), face['eye_rect_r'], 0, math.pi, face['width'])
pygame.draw.ellipse(screen, face['main_color'], face['eye_rect_r_b'], 0)
pygame.draw.arc(screen, (0, 0, 0), face['eye_rect_r_b'], 0, math.pi, face['width'])
#遮挡矩形
pygame.draw.rect(screen,face['main_color'],face['rect'],0)
#左右眼球
pygame.draw.ellipse(screen,(0,0,0),face['eye_circle_l'],0)
pygame.draw.ellipse(screen, (0, 0, 0), face['eye_circle_r'], 0)
#左右右眼角
pygame.draw.arc(screen,(0,0,0),face['eye_lr'],math.pi*(1+1/160),(2-1/160)*math.pi,face['width'])
pygame.draw.arc(screen, (0, 0, 0), face['eye_rr'], math.pi * (1 + 1 / 160), (2 - 1 / 160) * math.pi, face['width'])
pygame.draw.ellipse(screen, (255, 255, 255), face['eye_lr_white'], 0)
pygame.draw.ellipse(screen, (255, 255, 255), face['eye_rr_white'], 0)
pygame.display.flip()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
效果:
网友评论