Guest User

Untitled

a guest
Apr 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. int locX = 200; //set x-axis for text
  2. int locY = 160; //set y-axis for text
  3. int recX = 200; //set x-axis for bar
  4. int recY = 214; //set y-axis for bar
  5. int percentY = 220;
  6. PFont fontA; //declare font object
  7. PImage bg; //declare background image
  8. int g = 0;
  9. int textCounter = 0;
  10. int d = 0;
  11. PImage[] images;
  12. int[] dX = new int[10];
  13. int percentages[] = {
  14. 80, 44, 32, 32, 28, 20, 16, 16, 16, 8
  15. };
  16.  
  17. void setup() {
  18. size(1440, 760); //size of window
  19.  
  20. fontA = loadFont("ArialUnicodeMS-48.vlw"); //give variable to font type
  21.  
  22. // Set the font and its size (in units of pixels)
  23. textFont(fontA, 20);
  24.  
  25. bg = loadImage("GoogleSearch.jpg"); //load background image
  26.  
  27. //array of percentages
  28. // String percentages[] = {
  29. // "80%", "44%", "32%", "32%", "28%", "20%", "16%", "16%", "16%", "8%"
  30. // };
  31.  
  32. // int rectLength[] = {
  33. // 800, 440, 320, 320, 280, 200, 160, 160, 160, 80
  34. // };
  35.  
  36. //display all percentages
  37. bg.resize(1440, 760); //resize image
  38.  
  39. //array of images
  40. images = new PImage[10];
  41. for ( int i = 0; i< images.length; i++ )
  42. {
  43. images[i] = loadImage( "Graph" + i + ".jpg" ); //load images
  44. }
  45. }
  46.  
  47. void draw()
  48. {
  49. background(bg); //show image
  50.  
  51. fill(156, 0, 255);
  52. text("Top November Searches", 223, 75);
  53.  
  54. int increment = 57; //increment for spacing between images and percentages
  55.  
  56. //resizing images
  57. for (int a = 0; a<10; a++) {
  58. image(images[a], locX, locY, 696, 55);
  59. locY += increment; //incrase space between images
  60. }
  61. locY=160;
  62. if (g<80)
  63. {
  64.  
  65. for (int a = 0; a<10; a++) {
  66. if (a==1&&g>43) {
  67. if (g==44) {
  68. dX[a] = d;
  69. }
  70. recY += increment; //incrase space between images
  71. percentY +=increment;
  72. continue;
  73. }
  74. if (a==2&&g>31) {
  75. if (g==32) {
  76. dX[a] = d;
  77. }
  78. recY += increment; //incrase space between images
  79. percentY +=increment;
  80. continue;
  81. }
  82. if (a==3&&g>31) {
  83. if (g==32) {
  84. dX[a] = d;
  85. }
  86. recY += increment; //incrase space between images
  87. percentY +=increment;
  88. continue;
  89. }
  90. if (a==4&&g>27) {
  91. if (g==28) {
  92. dX[a] = d;
  93. }
  94. recY += increment; //incrase space between images
  95. percentY +=increment;
  96. continue;
  97. }
  98. if (a==5&&g>19) {
  99. if (g==20) {
  100. dX[a] = d;
  101. }
  102. recY += increment; //incrase space between images
  103. percentY +=increment;
  104. continue;
  105. }
  106. if (a==6&&g>15) {
  107. if (g==16) {
  108. dX[a] = d;
  109. }
  110. recY += increment; //incrase space between images
  111. percentY +=increment;
  112. continue;
  113. }
  114. if (a==7&&g>15) {
  115. if (g==16) {
  116. dX[a] = d;
  117. }
  118. recY += increment; //incrase space between images
  119. percentY +=increment;
  120. continue;
  121. }
  122. if (a==8&&g>15) {
  123. if (g==16) {
  124. dX[a] = d;
  125. }
  126. recY += increment; //incrase space between images
  127. percentY +=increment;
  128. continue;
  129. }
  130. if (a==9&&g>7) {
  131. if (g==8) {
  132. dX[a] = d;
  133. }
  134. recY += increment; //incrase space between images
  135. percentY +=increment;
  136. continue;
  137. }
  138. if (a==0) {
  139. dX[a] = d;
  140. }
  141. fill(255, 4, 34);
  142. rect(recX, recY, d, 5); //creates rectangles
  143. fill(0); //make text black
  144. text(g+"%", recX + d + 10, percentY);
  145. if (textCounter >= 7)
  146. {
  147. g++;
  148. textCounter = 0;
  149. }
  150.  
  151. recY += increment; //incrase space between images
  152. percentY +=increment;
  153. }
  154. d++;
  155. textCounter++;
  156. }
  157. recY = 214;
  158. if (g>8) {
  159. for(int i =0;i<10;i++){
  160. if(g>=percentages[i]){
  161. fill(255, 4, 34);
  162. rect(recX, recY+(increment*i), dX[i], 5); //creates rectangles
  163. }
  164.  
  165. }
  166. fill(255, 4, 34);
  167. rect(recX, recY, d, 5); //creates rectangles
  168. fill(0); //make text black
  169. text(g+"%", recX + d + 10, percentY);
  170. }
  171.  
  172. recY = 214;
  173. percentY = 220;
  174. // percentY += increment; //increase space between percentages and rectangles
  175. }
Add Comment
Please, Sign In to add comment