Advertisement
tuomasvaltanen

Untitled

Nov 24th, 2021
912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. # BASIC COLORAMA TEST
  2. from colorama import Fore, Back, Style
  3.  
  4. print(Fore.YELLOW + Back.LIGHTGREEN_EX + 'Different text color!')
  5. print(Back.LIGHTWHITE_EX + 'New background color too!')
  6.  
  7. # reset all styles and colors to normal
  8. print(Style.RESET_ALL)
  9. print('..okay, back to normal.')
  10.  
  11. # a fancier example of colorama
  12. from colorama import Fore, Back, Style
  13.  
  14. number = input("Give a number:\n")
  15. number = int(number)
  16.  
  17. if 0 < number <= 10:
  18.     print(Fore.BLACK + Back.LIGHTGREEN_EX + "Number OK!")
  19. else:
  20.     print(Fore.BLACK + Back.LIGHTRED_EX + "Number not OK.")
  21.  
  22. # Pillow example, some test drawing
  23.  
  24. from PIL import Image, ImageDraw
  25.  
  26. # create a picture
  27. img = Image.new('RGB', (300, 300), color=(79, 30, 136))
  28. d = ImageDraw.Draw(img)
  29.  
  30. # draw some text to picture
  31. d.text((10, 10), "Hello World", fill=(255, 255, 0))
  32.  
  33. # draw some circle in picture
  34. # first two numbers = top left coordinate, last two numbers = bottom right coordinate
  35. # in whole picture, 0, 0 = top left corner
  36. d.ellipse((50, 50, 100, 100), fill=(255, 0, 0), outline=(0, 0, 0))
  37.  
  38. # draw a triangle by using the polygon-feature
  39. d.polygon([(200,10), (200, 200), (150,50)], fill = 'yellow')
  40.  
  41. # save the picture to this file
  42. img.save('pil_text.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement