Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Text To Image Converter

Whoops, didn't realize this was some avant-garde gibbish generator. Here's my mostly debugged and rewritten version. Missing Page
def stringToImage(string, size):
  '''input string, input magic number, output picture'''

  alpha = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7, 'i':8, 'j':9,
           'k':10, 'l':11, 'm':12, 'n':13, 'o':14, 'p':15, 'q':16, 'r':17, 's':18,
           't':19, 'u':20, 'v':21, 'w':22, 'x':23, 'y':24, 'z':25}

  string = string.lower()

  canvas = makePicture(getMediaPath('7inX95in.jpg'))

  x = canvas.getWidth()/2
  y = canvas.getHeight()/2

  inc = (2*pi)/26

  for letter in string:
    if alpha.has_key(letter):
      x0 = x + int((size*cos(alpha[letter]*inc)))
      y0 = y + int((size*sin(alpha[letter]*inc)))
      addLine(canvas, x, y, x0, y0)
      x = x0
      y = y0

  show(canvas)
  return canvas



Takes length of line as input. Try 5-20 for best results. May need to use 2-3 for larger text inputs. Create a document.txt in your JES folder. This file will contain the text you wish to convert.