Advertisement
tuomasvaltanen

Untitled

Nov 15th, 2021 (edited)
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. # Python modules!
  2. print("Welcome!")
  3.  
  4. # remember to install colorama first!
  5. from colorama import Fore, Back, Style
  6. print(Fore.LIGHTYELLOW_EX + 'Different text color!')
  7. print(Back.LIGHTWHITE_EX + 'New background color too!')
  8.  
  9. # reset all styles and colors to normal
  10. print(Style.RESET_ALL)
  11. print('..okay, back to normal.')
  12.  
  13. from colorama import Fore, Back, Style
  14.  
  15. number = input("Give a number:\n")
  16. number = int(number)
  17.  
  18. # number has to be between 0 and 10
  19. if number >= 0 and number <= 10:
  20.     print(Fore.BLACK + Back.GREEN + "Number OK!")
  21. else:
  22.     print(Fore.BLACK + Back.RED + "Number not OK...")
  23.  
  24. # NEW FILE
  25.  
  26. from PIL import Image, ImageDraw
  27.  
  28. # create a new image, 300 x 300 pixels, purple background color (RGB format)
  29. img = Image.new('RGB', (230, 230), color=(195, 119, 189))
  30.  
  31. # initialize the drawing object (d)
  32. d = ImageDraw.Draw(img)
  33.  
  34. # draw text to coordinate 10, 10
  35. d.text((10, 10), "Hello World", fill=(255, 255, 0))
  36.  
  37. # draw circle + triangle
  38. d.ellipse((20, 20, 180, 180), fill = 'blue', outline ='blue')
  39. d.polygon([(200,10), (200, 200), (150,50)], fill = 'yellow')
  40.  
  41. # save to file in same folder as the python script
  42. img.save('pil_text.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement