Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Python modules!
- print("Welcome!")
- # remember to install colorama first!
- from colorama import Fore, Back, Style
- print(Fore.LIGHTYELLOW_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.')
- from colorama import Fore, Back, Style
- number = input("Give a number:\n")
- number = int(number)
- # number has to be between 0 and 10
- if number >= 0 and number <= 10:
- print(Fore.BLACK + Back.GREEN + "Number OK!")
- else:
- print(Fore.BLACK + Back.RED + "Number not OK...")
- # NEW FILE
- from PIL import Image, ImageDraw
- # create a new image, 300 x 300 pixels, purple background color (RGB format)
- img = Image.new('RGB', (230, 230), color=(195, 119, 189))
- # initialize the drawing object (d)
- d = ImageDraw.Draw(img)
- # draw text to coordinate 10, 10
- d.text((10, 10), "Hello World", fill=(255, 255, 0))
- # draw circle + triangle
- d.ellipse((20, 20, 180, 180), fill = 'blue', outline ='blue')
- d.polygon([(200,10), (200, 200), (150,50)], fill = 'yellow')
- # save to file in same folder as the python script
- img.save('pil_text.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement