Advertisement
tuomasvaltanen

Untitled

Oct 28th, 2022 (edited)
1,276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.89 KB | None | 0 0
  1. # Python-lisämoduuleja tänään!
  2. print("Tervetuloa!")
  3.  
  4. # UUSI TIEDOSTO
  5.  
  6. from colorama import Fore, Back, Style
  7. print(Fore.CYAN + 'Eri väristä tekstiä!')
  8. print(Back.LIGHTWHITE_EX + 'Eri taustavärikin!')
  9.  
  10. # palautetaan kaikki normaaliksi
  11. print(Style.RESET_ALL)
  12. print('Nyt ollaan taas normaalissa tilassa!')
  13.  
  14. # UUSI TIEDOSTO
  15.  
  16. from colorama import Fore, Back, Style
  17.  
  18. print(Fore.CYAN + 'Eri väristä tekstiä!')
  19. print("Lisää tekstiä, vieläkin sama väri!")
  20. print(Fore.RED + Back.LIGHTCYAN_EX + "Vaihdetaan taustaväri ja väri yhtä aikaa!")
  21. print("Vieläkin on sininen teksti ja taustaväri.")
  22.  
  23. print(Style.RESET_ALL + "Nyt kaikki on normaalisti!")
  24.  
  25. # UUSI TIEDOSTO
  26.  
  27. from colorama import Fore, Back, Style
  28.  
  29. # kysytään numero, -> int()
  30. number = input("Anna jokin numero:\n")
  31. number = int(number)
  32.  
  33. # positiivinen vai negatiivinen luku, väritetään lopputulos
  34. if number >= 0:
  35.     print(Fore.BLACK + Back.LIGHTGREEN_EX + "Positiivinen luku!")
  36. else:
  37.     print(Fore.BLACK + Back.LIGHTRED_EX + "Negatiivinen luku...")
  38.  
  39. # UUSI TIEDOSTO
  40.  
  41. from PIL import Image, ImageDraw
  42.  
  43. img = Image.new('RGB', (100, 30), color = (73, 109, 137))
  44.  
  45. d = ImageDraw.Draw(img)
  46. d.text((10,10), "Hello World", fill=(255,255,0))
  47.  
  48. img.save('pil_text.png')
  49.  
  50. # UUSI TIEDOSTO
  51.  
  52. from PIL import Image, ImageDraw
  53.  
  54. # aloitetaan uusi kuva!
  55. img = Image.new('RGB', (500, 300), color=(73, 109, 137))
  56.  
  57. d = ImageDraw.Draw(img)
  58. # tulostetaan tekstiä vasempaan ylänurkkaan kohtaan 10,10
  59. # huom: kohta 0,0 on vasen ylänurkka!
  60. # fill-parametri on käytössä oleva väri, ja se on RGB-muodossa
  61. # voit hakea Googlella: RGB color picker
  62. d.text((10, 10), "Hello World", fill=(131, 190, 252))
  63.  
  64. # tehdään ympyrä kohtaan 100,100 - 200,200 , eli 100 pikseliä leveä ympyrä!
  65. d.ellipse((100, 100, 200, 200), fill=(255, 0, 0), outline=(0, 0, 0))
  66.  
  67. # tallennetaan lopputulos tiedostoon
  68. img.save('pil_text.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement