# GridTweets1.py
# Values drawn in a color grid

# Adapted from Jer Thorp
# http:#blog.blprnt.com/blog/blprnt/your-random-numbers-getting-started-with-processing-and-data-visualization

from Processing import *
window(600,600)
background(0)
stroke(32)

def colorGrid(nums, x, y, s):
	# Make a list of number counts filled with 0's
	counts = [0 for i in range(100)]
 
	# Tally the counts
	for i in range(len(nums)):
		counts[ nums[i] ] += 1
 
	# Move the drawing coordinates to the x,y position specified in the parameters
	pushMatrix()
	translate(x,y)
 
	# Draw the grid   
	for i in range( len(counts) ):
		fill(counts[i] * 30, 0, 0, counts[i] * 20)
		rect((i % 10) * s, floor(i/10) * s, s, s)
 
	popMatrix()

# Load strings and convert to integers
f = open("numbers.txt", "r")
snumbers = f.readlines()
f.close()
numbers = [ int(s) for s in snumbers ]

# Draw the color grid
colorGrid(numbers, 50, 50, 50)
