Guest User

Untitled

a guest
Aug 1st, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. /*
  2.  
  3. BASED ON JER THORP's:
  4. #myrandomnumber Tutorial
  5. blprnt@blprnt.com
  6. April, 2010
  7.  
  8. */
  9.  
  10. //This is the Google spreadsheet manager and the id of the spreadsheet that we want to populate, along with our Google username & password
  11. SimpleSpreadsheetManager sm;
  12. String sUrl = "tHN7Rg12OzN1XA_G6s0wN4A";//"t6mq_WLV5c5uj6mUNSryBIA";
  13. String googleUser = "data.topologies";
  14. String googlePass = "sciarc2010";
  15.  
  16. PFont label;
  17.  
  18. void setup() {
  19. //This code happens once, right when our sketch is launched
  20. size(500,500);
  21. background(0);
  22. smooth();
  23.  
  24. //Create the font to make text with
  25. label = createFont("Helvetica", 24);
  26.  
  27. //Ask for the list of numbers
  28. int[] numbers = getNumbers();
  29. for (int i=0;i<numbers.length;i++) {
  30. println(""+numbers[i]);
  31. }
  32.  
  33. //Draw the graph
  34. barGraph(numbers, 400);
  35. };
  36. void barGraph(int[] nums, float y) {
  37. //Make a list of number counts
  38. int[] counts = new int[100];
  39. //Fill it with zeros
  40. for (int i = 1; i < 100; i++) {
  41. counts[i] = 0;
  42. };
  43. //Tally the counts
  44. for (int i = 0; i < nums.length; i++) {
  45. counts[nums[i]] ++;
  46. };
  47.  
  48. //Draw the bar graph
  49. for (int i = 0; i < counts.length; i++) {
  50. colorMode(HSB);
  51. fill(counts[i] * 30, 255, 255);
  52. rect(i * 8, y, 8, -counts[i] * 10);
  53. };
  54. };
  55.  
  56. void draw() {
  57. //This code happens once every frame.
  58. };
Add Comment
Please, Sign In to add comment