‘pygame.draw.aalines()’
is used to draw a connected sequence of antialiased lines.
Syntax
aalines(Surface,
color, closed, pointlist, blend=1)
Draws a
sequence on a surface. You must pass at least two points in the sequence of
points. The closed argument is a simple Boolean and if true, a line will be
draw between the first and last points. The Boolean blend argument set to true
will blend the shades with existing shades instead of overwriting them. This
function accepts floating point values for the end points.
#import pygame import pygame #initialize game engine pygame.init() #Open a window size = (500, 500) screen = pygame.display.set_mode(size) #Set title to the window pygame.display.set_caption("Hello World") dead=False #Initialize values for color (RGB format) WHITE=(255,255,255) RED=(255,0,0) clock = pygame.time.Clock() while(dead==False): for event in pygame.event.get(): if event.type == pygame.QUIT: dead = True screen.fill(WHITE) lines=[[50,50], [450, 450], [450,50], [50, 450] ] pygame.draw.aalines(screen, RED, True, lines, 3) pygame.display.flip() clock.tick(60) #Shutdown display module pygame.display.quit()
Run above
program, you will get following output.
No comments:
Post a Comment