• Lumen Armiger
Light Bringer
  • Lumen Armiger

Draw a 3d frame with a shadow

# Letter Frame with Shadow
import sys
import os

def Clear_screen():
 Operating_system = os.name
 if Operating_system == "posix":
  command = "clear"
 else:
  command = "cls"
 os.system(command)

def Frame_text(message):
 Clear_screen()
 print "\n"
 length = len(message)
 length +=2  # Adds whitespace at the beginning and end of the message
 top_row = [ 32,32,32,201]   # 3 spaces, top left corner
 mid_row = [32,32,32,186,32]   # 3 spaces, left side of frame, single space (whitespace)
 bottom = [32,186,222,10,32,32,32,200]# 1 space, right side of frame, right shadow, end line,
          # 3 spaces, bottom left corner
 shadow = [188,222,10,32,32,32]  #Bottom right corner, right shadow, end line, 3 spaces
 count = 0
 for letter in top_row:
  sys.stdout.write(chr(letter))
 while count < length:
  sys.stdout.write(chr(205)) # Horizontal line with length of message
  count+=1
 sys.stdout.write(chr(187)) # Top right corner
 sys.stdout.write(chr(10))  # End line 
 
 for letter in mid_row:
  sys.stdout.write(chr(letter))
 for ch in message:
  sys.stdout.write(chr(ord(ch))) # Displays message
 
 for letter in bottom:
  sys.stdout.write(chr(letter))
  count = 0
 while count < length:
  sys.stdout.write(chr(205)) # Horizontal line with length of message
  count+=1
 for letter in shadow:
  sys.stdout.write(chr(letter))
 
 shadow = 1
 while shadow < count+4:
  sys.stdout.write(chr(223)) # Bottom shadow
  shadow+=1
 print "\n"

message = raw_input("Enter message: ")
Frame_text(message)

Wednesday 09.25.13
Posted by Benjamin Chilton
Newer / Older

Powered by Squarespace 6