SHARE
TWEET

triforce_pythonic_colorized

a guest Feb 14th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python3
  2.  
  3. string=''
  4. j=0;
  5. character=''
  6. numbers=10
  7.  
  8. characters='#'*64
  9. #characters='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!-';
  10. number_i=0
  11.  
  12. #this line is to make the text colored yellow.
  13. print("\033[1mCan I haz triforce?! I haz triforce of \033[31;1mPower\033[39;22m,\033[34;1mWisdom\033[39;22m,a and \033[32;1mCourage\033[39;22m\033[93;1m\n")
  14.  
  15. total_characters=0
  16. #draw top triangle.
  17. #Also to make it centered I am shifting it to the right by 2*number_of_lines - current_line
  18. #so that it looks like this.
  19. '''
  20.       #
  21.      ###
  22.     #####
  23.    #######
  24.   #       #
  25.  ###     ###
  26. #####   #####
  27. ####### #######
  28. '''
  29. #I am doing all of the lines of characters.
  30. for i in range(numbers+1):
  31.     #select the chracter from the character list.
  32.     character=characters[i]
  33.     #make string equal to numbers*2 -i plus 1 spaces.
  34.     #in python you can do it like this without a for/while loop. It saves you typing.
  35.     string=' '*(((numbers*2)-i)+1)
  36.     #then we add i*2 plus 1 characters
  37.     string+=character*((i*2)+1)
  38.     #print the string.
  39.     print(string)
  40.  
  41. #then we draw the bottom two together.
  42. for i in range(numbers):
  43.     #make sure the string's empty.
  44.     string=''
  45.     #select the character.
  46.     character=characters[i]
  47.     #instead of having to do the calculation over and over we cache the value.
  48.     number_i=numbers-i
  49.     #add numbers-i spaces to the string.
  50.     string+=' '*number_i
  51.     #then we add i*2 plus 1 characters to the string.
  52.     string+=character*((i*2)+1)
  53.     #now for triangle 3 as it's inline with the second one. We add an additional space.
  54.     string+=' '
  55.     #then we add the number of lines -i times 2 spaces.
  56.     #for j in range((numbers -i) *2 ):
  57.     string+=' '*(number_i*2)
  58.        
  59.     #then we add i*2+1 characters to the string.
  60.     string+='\033[93m'+character*(i*2+1)
  61.     #quick hack to get total character counts.
  62.     total_characters+=len(string)
  63.     #print the generated string.
  64.     print(string)
  65.  
  66. string=''
  67. character=characters[i+1]
  68. for j in range(i*2+3):
  69.     string+=character
  70.  
  71. string+=' '
  72.  
  73. for j in range(i*2+3):
  74.     string+=character
  75.  
  76. total_characters+=len(string)
  77. #this line prints the stirng and also clears the formatting and turns it back into the default one.
  78. print('{}\033[39;22m'.format(string))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top