Skip to content

Instantly share code, notes, and snippets.

@rtanglao
Created October 1, 2010 04:58
Show Gist options
  • Select an option

  • Save rtanglao/605765 to your computer and use it in GitHub Desktop.

Select an option

Save rtanglao/605765 to your computer and use it in GitHub Desktop.
vancouverAverageColourFromRolands21000cameraphonePhotos
//Function to get an Array of integers from a Google Spreadsheet
int[] getNumbers() {
String lines[] = loadStrings("coloursForProcessing3.txt");
println("there are " + lines.length + " lines");
int[] returnArray = new int[lines.length];
for (int i=0; i < lines.length; i++) {
println("line:"+i+":"+lines[i]);
returnArray[i] = int(lines[i]);
};
return returnArray;
}
// original code by jer thorpe apri 2010
// hacked by roland tanglao september 2010
void setup() {
//This code happens once, right when our sketch is launched
size(800,600);
background(255);
smooth();
//Ask for the list of numbers
int[] numbers = getNumbers();
noStroke();
for (int i = 0; i < numbers.length; i++) {
println("numbers["+i+"]:"+numbers[i]);
int r, g,b;
b = numbers[i] % 256;
g = (numbers[i] >> 8) % 256;
r = (numbers[i] >> 16) % 256;
fill(r,g,b);
ellipse(((i % 200) * 4)+2, i / 200 + (i / 200 * 4)+2, 4,4);
};
};
void draw() {
//This code happens once every frame.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment