天天看点

python如何画贝塞尔曲线_pygame贝塞尔曲线绘制示例

"""pygame贝塞尔曲线绘制示例"""

import pygame

import pygame.gfxdraw

def main():

pygame.init()

screen = pygame.display.set_mode((500,500))

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

pygame.display.set_caption("pygame贝塞尔曲线绘制示例")

sur = pygame.Surface(screen.get_size(), pygame.SRCALPHA, 32)

# 贝塞尔曲线上的坐标点

points = [(0,0),(10,20),(15,15),(50,5),(60,80),(100,200),(400,100)]

points.extend([(410,200),(300,200),(200,150),(250,250),(400,400),(10,450)])

points.extend([(420,400),(430,40)])

color = (255,0,255)

steps = 10

pygame.gfxdraw.bezier(sur, points,steps,color)

screen.blit(sur, (0, 0))

pygame.display.flip()

while not pygame.event.get(pygame.QUIT):pass

pygame.quit()

if __name__ == '__main__':

main()

python如何画贝塞尔曲线_pygame贝塞尔曲线绘制示例