Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # BASIC COLORAMA TEST
- from colorama import Fore, Back, Style
- print(Fore.YELLOW + Back.LIGHTGREEN_EX + 'Different text color!')
- print(Back.LIGHTWHITE_EX + 'New background color too!')
- # reset all styles and colors to normal
- print(Style.RESET_ALL)
- print('..okay, back to normal.')
- # a fancier example of colorama
- from colorama import Fore, Back, Style
- number = input("Give a number:\n")
- number = int(number)
- if 0 < number <= 10:
- print(Fore.BLACK + Back.LIGHTGREEN_EX + "Number OK!")
- else:
- print(Fore.BLACK + Back.LIGHTRED_EX + "Number not OK.")
- # Pillow example, some test drawing
- from PIL import Image, ImageDraw
- # create a picture
- img = Image.new('RGB', (300, 300), color=(79, 30, 136))
- d = ImageDraw.Draw(img)
- # draw some text to picture
- d.text((10, 10), "Hello World", fill=(255, 255, 0))
- # draw some circle in picture
- # first two numbers = top left coordinate, last two numbers = bottom right coordinate
- # in whole picture, 0, 0 = top left corner
- d.ellipse((50, 50, 100, 100), fill=(255, 0, 0), outline=(0, 0, 0))
- # draw a triangle by using the polygon-feature
- d.polygon([(200,10), (200, 200), (150,50)], fill = 'yellow')
- # save the picture to this file
- img.save('pil_text.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement