Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Python-lisämoduuleja tänään!
- print("Tervetuloa!")
- # UUSI TIEDOSTO
- from colorama import Fore, Back, Style
- print(Fore.CYAN + 'Eri väristä tekstiä!')
- print(Back.LIGHTWHITE_EX + 'Eri taustavärikin!')
- # palautetaan kaikki normaaliksi
- print(Style.RESET_ALL)
- print('Nyt ollaan taas normaalissa tilassa!')
- # UUSI TIEDOSTO
- from colorama import Fore, Back, Style
- print(Fore.CYAN + 'Eri väristä tekstiä!')
- print("Lisää tekstiä, vieläkin sama väri!")
- print(Fore.RED + Back.LIGHTCYAN_EX + "Vaihdetaan taustaväri ja väri yhtä aikaa!")
- print("Vieläkin on sininen teksti ja taustaväri.")
- print(Style.RESET_ALL + "Nyt kaikki on normaalisti!")
- # UUSI TIEDOSTO
- from colorama import Fore, Back, Style
- # kysytään numero, -> int()
- number = input("Anna jokin numero:\n")
- number = int(number)
- # positiivinen vai negatiivinen luku, väritetään lopputulos
- if number >= 0:
- print(Fore.BLACK + Back.LIGHTGREEN_EX + "Positiivinen luku!")
- else:
- print(Fore.BLACK + Back.LIGHTRED_EX + "Negatiivinen luku...")
- # UUSI TIEDOSTO
- from PIL import Image, ImageDraw
- img = Image.new('RGB', (100, 30), color = (73, 109, 137))
- d = ImageDraw.Draw(img)
- d.text((10,10), "Hello World", fill=(255,255,0))
- img.save('pil_text.png')
- # UUSI TIEDOSTO
- from PIL import Image, ImageDraw
- # aloitetaan uusi kuva!
- img = Image.new('RGB', (500, 300), color=(73, 109, 137))
- d = ImageDraw.Draw(img)
- # tulostetaan tekstiä vasempaan ylänurkkaan kohtaan 10,10
- # huom: kohta 0,0 on vasen ylänurkka!
- # fill-parametri on käytössä oleva väri, ja se on RGB-muodossa
- # voit hakea Googlella: RGB color picker
- d.text((10, 10), "Hello World", fill=(131, 190, 252))
- # tehdään ympyrä kohtaan 100,100 - 200,200 , eli 100 pikseliä leveä ympyrä!
- d.ellipse((100, 100, 200, 200), fill=(255, 0, 0), outline=(0, 0, 0))
- # tallennetaan lopputulos tiedostoon
- img.save('pil_text.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement