Scale an image depending on data (how often a specific number is selected)
in
Contributed Library Questions
•
6 months ago
Hi,
I have been working with processing for a little while but would certainly consider myself a novice.
I currently have created a pde file that pulls in data from google spreadsheets and I have create functions that say if ie., number 1 is selected produce this image/shape at this size at this location.
SimpleSpreadsheetManager sm;
String sUrl = "";
String googleUser = "userName";
String googlePass = "passWord";
PImage imgName1;
PImage imgName2;
PImage imgName3;
PImage imgName4;
PImage imgName5;
PImage imgName6;
void setup() {
size(1200,800);
background(0);
smooth();
imgName1 = loadImage("Name1.png");
imgName2 = loadImage("Name2.png");
imgName3 = loadImage("Name3.png");
imgName4 = loadImage("Name4.png");
imgName5 = loadImage("Name5.png");
imgName6 = loadImage("Name6.png");
int[] choice = getChoice();
String[] page = getPage();
for (int i = 0; i < choice.length; i++) {
if( (page[i].equals("Page.php")) && (choice[i] == 1) ) {
image( imgName1, i*2, 40, imgName1.width/2, imgName1.height/2);
};
if( (page[i].equals("Page.php")) && (choice[i] == 2) ) {
image( imgName2, i*2, 40, imgName2.width/2, imgName2.height/2);
};
if( (page[i].equals("Page.php")) && (choice[i] == 3) ) {
image( imgName3, i*2, 40, imgName3.width/2, imgName3.height/2);
};
if( (page[i].equals("Page.php")) && (choice[i] == 4) ) {
image( imgName4, i*2, 40, imgName4.width/2, imgName4.height/2);
};
if( (page[i].equals("Page.php")) && (choice[i] == 5) ) {
image( imgName5, i*2, 40, imgName5.width/2, imgName5.height/2);
};
if( (page[i].equals("Page.php")) && (choice[i] == 6) ) {
image( imgName6, i*2, 40, imgName6.width/2, imgName6.height/2);
};
};
};
void draw() {
}
I now need to try and get this to scale depending on the number of times an option is selected:
...if choice equals ie., 6, then scale each time it has been chosen...scale by say 10% or something like
The end result being a the selection/series of images on a page at differing sizes depending on their popularity of having been chosen/clicked on.
How can I achieve this? I would like to use the existing code as much as possible as I have got this far myself I would like to continue with it to get the final solution :)
I am looking to have a pde file for each page I have created, not to have all the results of every page on one file.
Hope this makes sense
Thank you so much in advance for any help you have
Emma
I have been working with processing for a little while but would certainly consider myself a novice.
I currently have created a pde file that pulls in data from google spreadsheets and I have create functions that say if ie., number 1 is selected produce this image/shape at this size at this location.
SimpleSpreadsheetManager sm;
String sUrl = "";
String googleUser = "userName";
String googlePass = "passWord";
PImage imgName1;
PImage imgName2;
PImage imgName3;
PImage imgName4;
PImage imgName5;
PImage imgName6;
void setup() {
size(1200,800);
background(0);
smooth();
imgName1 = loadImage("Name1.png");
imgName2 = loadImage("Name2.png");
imgName3 = loadImage("Name3.png");
imgName4 = loadImage("Name4.png");
imgName5 = loadImage("Name5.png");
imgName6 = loadImage("Name6.png");
int[] choice = getChoice();
String[] page = getPage();
for (int i = 0; i < choice.length; i++) {
if( (page[i].equals("Page.php")) && (choice[i] == 1) ) {
image( imgName1, i*2, 40, imgName1.width/2, imgName1.height/2);
};
if( (page[i].equals("Page.php")) && (choice[i] == 2) ) {
image( imgName2, i*2, 40, imgName2.width/2, imgName2.height/2);
};
if( (page[i].equals("Page.php")) && (choice[i] == 3) ) {
image( imgName3, i*2, 40, imgName3.width/2, imgName3.height/2);
};
if( (page[i].equals("Page.php")) && (choice[i] == 4) ) {
image( imgName4, i*2, 40, imgName4.width/2, imgName4.height/2);
};
if( (page[i].equals("Page.php")) && (choice[i] == 5) ) {
image( imgName5, i*2, 40, imgName5.width/2, imgName5.height/2);
};
if( (page[i].equals("Page.php")) && (choice[i] == 6) ) {
image( imgName6, i*2, 40, imgName6.width/2, imgName6.height/2);
};
};
};
void draw() {
}
I now need to try and get this to scale depending on the number of times an option is selected:
...if choice equals ie., 6, then scale each time it has been chosen...scale by say 10% or something like
The end result being a the selection/series of images on a page at differing sizes depending on their popularity of having been chosen/clicked on.
How can I achieve this? I would like to use the existing code as much as possible as I have got this far myself I would like to continue with it to get the final solution :)
I am looking to have a pde file for each page I have created, not to have all the results of every page on one file.
Hope this makes sense
Thank you so much in advance for any help you have
Emma
1