zoukankan      html  css  js  c++  java
  • 简单图形界面

    import pygame
    import sys
    import math
    from pygame.locals import *
    
    pygame.init()
    WHITE = (255,255,255)
    BLACK = (0,0,0)
    GREEN = (0,255,0)
    points= (100,100)
    RED = (255,0,0)
    BLUE = (0,0,255)
    
    size = width,height = 640,400
    screen = pygame.display.set_mode(size)
    pygame.display.set_caption("Hello!")
    points= [(200,75),(300,25),(400,75),(450,25),(450,125),(400,75),(300,125)]
    position = size[0] //2,size[1]//2
    
    clock = pygame.time.Clock()
    moving = False
    
    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                sys.exit()
    
            if event.type == MOUSEBUTTONDOWN:
                if event.button == 1:
                    moving = True
            if event.type == MOUSEBUTTONUP:
                if event.button == 1:
                    moving = False
    
        if moving:
            position = pygame.mouse.get_pos()
            
                    
        screen.fill(WHITE)
        pygame.draw.rect(screen,BLACK,(50,50,150,50),0)  #矩形
         pygame.draw.polygon(screen,GREEN,points,0)     #
        pygame.draw.circle(screen,RED,position,25,1)    #
        pygame.draw.ellipse(screen,BLACK,(100,100,440,100),1)#椭圆
        pygame.draw.ellipse(screen,BLACK,(220,50,200,200),1)#
        pygame.draw.arc(screen,BLACK,(100,100,440,100),0,math.pi,1) #一条线
        pygame.draw.aaline(screen,BLACK,(100,250),(540,300),1)      #一条斜线
        pygame.draw.arc(screen,BLACK,(220,50,200,200),math.pi,math.pi*2,1)
        pygame.draw.circle(screen,GREEN,position,75,1)
        pygame.draw.circle(screen,BLUE,position,125,1)
        pygame.display.flip()
        clock.tick(100)
  • 相关阅读:
    Callable的Future模式
    并发队列
    并发工具类
    线程池
    并发编程专题
    侧边栏:内有友链,分类等等
    脑残错误记录
    博主的OI流水账
    NOI2019游记
    NOI数论姿势瞎总结(Pi也没有)
  • 原文地址:https://www.cnblogs.com/chenyang920/p/4921911.html
Copyright © 2011-2022 走看看