Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int locX = 200; //set x-axis for text
- int locY = 160; //set y-axis for text
- int recX = 200; //set x-axis for bar
- int recY = 214; //set y-axis for bar
- int percentY = 220;
- PFont fontA; //declare font object
- PImage bg; //declare background image
- int g = 0;
- int textCounter = 0;
- int d = 0;
- PImage[] images;
- int[] dX = new int[10];
- int percentages[] = {
- 80, 44, 32, 32, 28, 20, 16, 16, 16, 8
- };
- void setup() {
- size(1440, 760); //size of window
- fontA = loadFont("ArialUnicodeMS-48.vlw"); //give variable to font type
- // Set the font and its size (in units of pixels)
- textFont(fontA, 20);
- bg = loadImage("GoogleSearch.jpg"); //load background image
- //array of percentages
- // String percentages[] = {
- // "80%", "44%", "32%", "32%", "28%", "20%", "16%", "16%", "16%", "8%"
- // };
- // int rectLength[] = {
- // 800, 440, 320, 320, 280, 200, 160, 160, 160, 80
- // };
- //display all percentages
- bg.resize(1440, 760); //resize image
- //array of images
- images = new PImage[10];
- for ( int i = 0; i< images.length; i++ )
- {
- images[i] = loadImage( "Graph" + i + ".jpg" ); //load images
- }
- }
- void draw()
- {
- background(bg); //show image
- fill(156, 0, 255);
- text("Top November Searches", 223, 75);
- int increment = 57; //increment for spacing between images and percentages
- //resizing images
- for (int a = 0; a<10; a++) {
- image(images[a], locX, locY, 696, 55);
- locY += increment; //incrase space between images
- }
- locY=160;
- if (g<80)
- {
- for (int a = 0; a<10; a++) {
- if (a==1&&g>43) {
- if (g==44) {
- dX[a] = d;
- }
- recY += increment; //incrase space between images
- percentY +=increment;
- continue;
- }
- if (a==2&&g>31) {
- if (g==32) {
- dX[a] = d;
- }
- recY += increment; //incrase space between images
- percentY +=increment;
- continue;
- }
- if (a==3&&g>31) {
- if (g==32) {
- dX[a] = d;
- }
- recY += increment; //incrase space between images
- percentY +=increment;
- continue;
- }
- if (a==4&&g>27) {
- if (g==28) {
- dX[a] = d;
- }
- recY += increment; //incrase space between images
- percentY +=increment;
- continue;
- }
- if (a==5&&g>19) {
- if (g==20) {
- dX[a] = d;
- }
- recY += increment; //incrase space between images
- percentY +=increment;
- continue;
- }
- if (a==6&&g>15) {
- if (g==16) {
- dX[a] = d;
- }
- recY += increment; //incrase space between images
- percentY +=increment;
- continue;
- }
- if (a==7&&g>15) {
- if (g==16) {
- dX[a] = d;
- }
- recY += increment; //incrase space between images
- percentY +=increment;
- continue;
- }
- if (a==8&&g>15) {
- if (g==16) {
- dX[a] = d;
- }
- recY += increment; //incrase space between images
- percentY +=increment;
- continue;
- }
- if (a==9&&g>7) {
- if (g==8) {
- dX[a] = d;
- }
- recY += increment; //incrase space between images
- percentY +=increment;
- continue;
- }
- if (a==0) {
- dX[a] = d;
- }
- fill(255, 4, 34);
- rect(recX, recY, d, 5); //creates rectangles
- fill(0); //make text black
- text(g+"%", recX + d + 10, percentY);
- if (textCounter >= 7)
- {
- g++;
- textCounter = 0;
- }
- recY += increment; //incrase space between images
- percentY +=increment;
- }
- d++;
- textCounter++;
- }
- recY = 214;
- if (g>8) {
- for(int i =0;i<10;i++){
- if(g>=percentages[i]){
- fill(255, 4, 34);
- rect(recX, recY+(increment*i), dX[i], 5); //creates rectangles
- }
- }
- fill(255, 4, 34);
- rect(recX, recY, d, 5); //creates rectangles
- fill(0); //make text black
- text(g+"%", recX + d + 10, percentY);
- }
- recY = 214;
- percentY = 220;
- // percentY += increment; //increase space between percentages and rectangles
- }
Add Comment
Please, Sign In to add comment