pygame画图

# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import time

import airsim

# 公众号:一行数据
import pygame
import sys
import math
from pygame.locals import *


def draw_point():


    pygame.init()

    WHITE = (255, 255, 255)
    BLACK = (0, 0, 0)
    GREEN = (0, 255, 0)
    RED = (255, 0, 0)
    BLUE = (0, 0, 255)

    points = [(200, 175), (300, 125), (400, 175), (450, 125), (450, 225), (400, 175), (300, 225)]

    size = width, height = 640, 1000
    screen = pygame.display.set_mode(size)
    pygame.display.set_caption("Python Demo")

    clock = pygame.time.Clock()

    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                sys.exit()

        screen.fill(WHITE)

        pygame.draw.rect(screen, BLACK, (50, 30, 150, 50), 0)
        pygame.draw.rect(screen, BLACK, (250, 30, 150, 50), 1)
        pygame.draw.rect(screen, BLACK, (450, 30, 150, 50), 10)

        pygame.draw.polygon(screen, GREEN, points, 0)

        pygame.draw.circle(screen, RED, (320, 400), 25, 1)
        pygame.draw.circle(screen, GREEN, (320, 400), 75, 1)
        pygame.draw.circle(screen, BLUE, (320, 400), 125, 1)

        pygame.draw.ellipse(screen, BLACK, (100, 600, 440, 100), 1)
        pygame.draw.ellipse(screen, BLACK, (220, 550, 200, 200), 1)

        pygame.draw.arc(screen, BLACK, (100, 800, 440, 100), 0, math.pi, 1)
        pygame.draw.arc(screen, BLACK, (220, 750, 200, 200), math.pi, math.pi * 2, 1)

        pygame.display.flip()

        clock.tick(10)

def draw_circle(points):
    pygame.init()
    screen = pygame.display.set_mode((320, 240))
    pygame.display.set_caption('keyboard ctrl @FPV')
    screen.fill((0, 0, 0))
    # points = [(120, 100), (125, 100),(130, 100),(135, 100)]


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    # draw_point()

    pygame.init()
    screen = pygame.display.set_mode((320, 240))
    pygame.display.set_caption('keyboard ctrl @FPV')
    screen.fill((0, 0, 0))
    # points = [(120, 100), (125, 100),(130, 100),(135, 100)]
    points = []
    x = 120
    y = 100
    while True:
        x += 5
        points.append((x, y))
    # for i in points:
        # 利用pygame库加载保存的第一视角图像,
        screen_image = pygame.image.load("1.png")
        # 图像坐标系,左上角为(0, 0),在此放置图片
        screen.blit(screen_image, (0, 0))
        for i in points:
            pygame.draw.circle(screen, (255, 0, 0), i, 2, 0)

        pygame.display.flip()
        pygame.display.update()
        time.sleep(1)

    print('PyCharm')

# See PyCharm help at https://www.jetbrains.com/help/pycharm/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值