Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # mouse handling
- import pygame,sys
- pygame.init()
- global size,color
- fps = 60
- fpsclock = pygame.time.Clock()
- def size():
- global size
- size = int(input('Enter the size of pencil :'))
- def color():
- global color
- print('we use RGB color...')
- R = int(input('Enter part R :'))
- G = int(input('Enter part G :'))
- B = int(input('Enter part B :'))
- color = (R,G,B)
- # set up color
- # R G B
- white = (255,255,255)
- black = ( 0, 0, 0)
- blue = ( 0, 0,255)
- def draw(): # draw line like the legend paint xp
- # set up window
- pygame.display.set_caption('Pencil_Paint_Xp')
- surf = pygame.display.set_mode((640,480))
- pos1 = (0,0)
- pos2 = (1,1)
- surf.fill(black)
- a = 0
- # setting the size of the pencil and color
- size()
- color()
- print('you can change size and color by pressing SPACE button ')
- while True:
- for event in pygame.event.get():
- if event.type == pygame.MOUSEBUTTONDOWN:
- pos1 = event.pos
- a = event.button
- if a == 1:
- pos2 = pygame.mouse.get_pos()
- pygame.draw.line(surf,color,pos1,pos2,size)
- pos1 = pos2
- if event.type == pygame.MOUSEBUTTONUP:
- a = 0
- if event.type == pygame.KEYDOWN:
- if event.unicode == ' ':
- size()
- color()
- #draw line with pos1 and pos2
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- pygame.display.update()
- fpsclock.tick(fps)
- draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement