Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- BASED ON JER THORP's:
- #myrandomnumber Tutorial
- blprnt@blprnt.com
- April, 2010
- */
- //This is the Google spreadsheet manager and the id of the spreadsheet that we want to populate, along with our Google username & password
- SimpleSpreadsheetManager sm;
- String sUrl = "tHN7Rg12OzN1XA_G6s0wN4A";//"t6mq_WLV5c5uj6mUNSryBIA";
- String googleUser = "data.topologies";
- String googlePass = "sciarc2010";
- PFont label;
- void setup() {
- //This code happens once, right when our sketch is launched
- size(500,500);
- background(0);
- smooth();
- //Create the font to make text with
- label = createFont("Helvetica", 24);
- //Ask for the list of numbers
- int[] numbers = getNumbers();
- for (int i=0;i<numbers.length;i++) {
- println(""+numbers[i]);
- }
- //Draw the graph
- barGraph(numbers, 400);
- };
- void barGraph(int[] nums, float y) {
- //Make a list of number counts
- int[] counts = new int[100];
- //Fill it with zeros
- for (int i = 1; i < 100; i++) {
- counts[i] = 0;
- };
- //Tally the counts
- for (int i = 0; i < nums.length; i++) {
- counts[nums[i]] ++;
- };
- //Draw the bar graph
- for (int i = 0; i < counts.length; i++) {
- colorMode(HSB);
- fill(counts[i] * 30, 255, 255);
- rect(i * 8, y, 8, -counts[i] * 10);
- };
- };
- void draw() {
- //This code happens once every frame.
- };
Add Comment
Please, Sign In to add comment