Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Lähipäivä 2
- from colorama import Fore, Back, Style
- print(Fore.WHITE + 'Eri väristä tekstiä!')
- # jos halutaan resetoida tyylit niin ettei tule rivinvaihtoa, voidaan
- # lisätä RESET_ALL tekstin perällekin!
- print(Back.RED + Fore.BLUE + 'Eri taustavärikin!' + Style.RESET_ALL)
- # UUSI TIEDOSTO
- from colorama import Fore, Back, Style
- number = input("Anna luku (0-10):\n")
- number = int(number)
- # käytetään tehosteväriä riippuen siitä
- # oliko luku ok vai ei
- if 0 <= number <= 10:
- print(Back.GREEN + "Luku OK!")
- else:
- print(Back.RED + "Luku ei ole rajojen sisällä.")
- print(Style.RESET_ALL)
- # UUSI TIEODSTO
- # MUISTA ASENTAA Pillow, mutta käytä sen jälkeen koodissa PIL
- from PIL import Image, ImageDraw
- img = Image.new('RGB', (600, 400), color=(73, 109, 137))
- d = ImageDraw.Draw(img)
- d.text((10, 10), "Hello World", fill=(255, 255, 0))
- # piirretään ympyrä
- d.ellipse((200, 125, 300, 200), fill=(255, 0, 0), outline=(0, 0, 0))
- # piirretään kolmen pisteen polygoni, eli kolmio
- d.polygon([(124, 130), (130, 110), (110, 110)], fill=(120, 200, 120))
- img.save('pil_text.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement