--- a/index.cgi Tue May 05 18:01:44 2009 +0300
+++ b/index.cgi Tue May 05 18:08:48 2009 +0300
@@ -95,7 +95,7 @@
return l
-def build_data (text, chars, line_colors) :
+def build_data (text, chars, line_colors, random_chars, random_text) :
"""
Returns a matrix of (text, color) tuples representing the data to render
@@ -104,9 +104,14 @@
text - list of lines
chars - list of random chars to interpse
line_colors - list of colors to draw the chars in
+ random_chars - randomize the lines the chars go in
+ random_text - randomize the chars in each line
"""
data = []
+
+ if random_chars :
+ chars = randomize(chars)
for line, char, color in itertools.izip_longest(text, chars, line_colors, fillvalue=None) :
# pick position to place char
@@ -114,6 +119,9 @@
if not color :
color = "#000000"
+
+ if random_text :
+ line = ''.join(randomize(line))
# split into three parts
if char :
@@ -258,6 +266,7 @@
OPTIONS = Options(
Option('lang', False, str, Defaults.text_lang, TEXT_BY_LANG.keys()),
Option('text', True, unicode, None, None),
+ Option('random-text', False, arg_bool, False, None),
Option('chars', True, unicode, Defaults.chars, None),
Option('random-chars', False, arg_bool, True, None),
Option('colors', True, arg_color, Defaults.colors, None),
@@ -297,12 +306,8 @@
if opts['font-size'] > FONT_SIZE_MAX :
raise ValueError(opts['font-size'])
- # put the chars in random order by default
- if opts['random-chars'] :
- opts['chars'] = randomize(opts['chars'])
-
# load/prep resources
- data = build_data(opts['text'], opts['chars'], opts['colors'])
+ data = build_data(opts['text'], opts['chars'], opts['colors'], opts['random-chars'], opts['random-text'])
font = load_font(opts['font'], opts['font-size'])
# render the image