/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.Fx851m3mvhi/rev.2568
*
* authors:
* Amine
*
*
*
* wang
* MadOUA
* Maïk
*
* MadOUA
* Pierre DAL-PRA
*
* Yoann
* Madjid TIZI
*
* Madjid OUARAB
*
*
* Romain
* Amine
* Yoannk
* Youssef
*
*
*
*
*
* Thibault Soudais
*
*
*
*
*
* Thibault Soudais
* madjid
* Clément Smadja
* Christophe
*
*
* toto
*
* Amine
* Khac-dat.PHAM
*
* Mike
* Pierre
*
*
*
*
* Youssef
* Youssef
* DIAO WENWEI
* Alexandre
* frederic.vernier
*
*
* Mike
*
*
* Clément
*
* Madjid
*
* JC
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// For an unknown reason if I don't prefetch an image first the table of data
// do not load !
/* @pjs preload="/static/uploaded_resources/p.2418/logoUPSUD.png"; */
/* @pjs preload="/static/uploaded_resources/p.2418/tstreams4.csv"; */
// data from http://geography.uoregon.edu/GeogR/data/csv/tstreams4.csv
int i = 0;
int index = -1;
int minage, maxage;
float mintaille, maxtaille;
int minpoids, maxpoids;
String[] names = new String[17];
int[] ages = new int[17];
float[] tailles = new float[17];
int[] poids = new int[17];
PFont font;
PImage img;
float data [][];
void setup() { // this is run once.
// loading ressources
font = loadFont("FFScala-32.vlw");
img = loadImage("/static/uploaded_resources/p.2418/logoUPSUD.png");
String lines[] = loadStrings("/static/uploaded_resources/p.2418/tstreams4.csv");
textFont(font);
String premiereligne[] = splitTokens(lines[0], ",\"");
data = new float[lines.length][premiereligne.length];
for (int j=1; j<lines.length; j++){
String iemeligne[] = splitTokens(lines[j], ",\"");
for (int i=0; i<iemeligne.length; i++)
data[j][i] = float(iemeligne[i]);
}
names[0] = "Frederic Vernier";
names[1] = "Mike";
names[2] = "Pierre DAL-PRA";
names[3] = "WHO IS John Doe ? => JC";
names[4] = "Klausz Yoann";
names[5] = "DIAO Wenwei";
names[6] = "Cyrille Broutin";
names[7] = "JC";
names[8] = "Thibault";
names[9] = "wang renjie";
names[10] = "Amine";
names[11] = "MADJID";
names[12] = "Alexandre PRATHOUMVANH";
names[13]= "Romain Grimault";
names[14] = "Clément Smadja";
names[15] = "PHAM";
names[16] = "Youssef";
ages[0] = 38;
ages[1] = 25;
ages[2] = 23;
ages[3] = 22;
ages[4] = 22;
ages[5] = 25;
ages[6] = 23;
ages[7] = 22;
ages[8] = 23;
ages[9] = 27;
ages[10] = 23;
ages[11] = 28;
ages[12] = 23;
ages[13] = 23;
ages[14] = 22;
ages[15] = 25;
ages[16] = 26;
minage = ages[0];
maxage = ages[0];
for (int j=0; j<ages.length; j++){
minage = min(minage, ages[j]);
maxage = max(maxage, ages[j]);
}
tailles[0] = 1.76;
tailles[1] = 1.80;
tailles[2] = 1.83;
tailles[3] = 1.75;
tailles[4] = 1.86;
tailles[5] = 1.80;
tailles[6] = 1.72;
tailles[7] = 1.84;
tailles[8] = 1.79;
tailles[9] = 1.65;
tailles[10] = 1.72;
tailles[11] = 1.75;
tailles[12] = 1.65;
tailles[13] = 1.90;
tailles[14] = 1.75;
tailles[15] = 1.72;
tailles[16] = 1.75;
mintaille = tailles[0];
maxtaille = tailles[0];
for (int j=0; j<tailles.length;j++) {
mintaille = min(mintaille,tailles[j]);
maxtaille = max(maxtaille,tailles[j]);
}
poids[0] = 88;
poids[1] = 77;
poids[2] = 110;
poids[3] = 76;
poids[4] = 78;
poids[5] = 75;
poids[6] = 58;
poids[7] = 100;
poids[8] = 86;
poids[9] = 65;
poids[10] = 64;
poids[11] = 68;
poids[12] = 60;
poids[13] = 77;
poids[14] = 70;
poids[15] = 63;
poids[16] = 72;
minpoids = poids[0];
maxpoids = poids[0];
for (int j=0; j<poids.length; j++){
minpoids = min(minpoids, poids[j]);
maxpoids = max(maxpoids, poids[j]);
}
// set the background color
background(255, 250, 240);
// canvas size (Variable aren't evaluated. Integers only, please.)
size(400, 400);
// smooth edges
smooth();
// limit the number of frames per second
//frameRate(30);
noLoop();
// set the width of the line.
strokeWeight(1);
}
void draw() { // this is run repeatedly.
// set the color
stroke(0);
background(255, 204, 80);
// draw the line
//line(i, 0, 0, random(0, height));
stroke(0, 0, 0);
for (int j=0; j<names.length; j++){
fill(128, 0, 0);
int xx = (poids[j]-minpoids)*width/(maxpoids-minpoids);
int yy = (int)((tailles[j]-mintaille)*height/(maxtaille-mintaille));
ellipse(xx,
yy,
5+(ages[j]-minage)/(maxage-minage)*10,
5+(ages[j]-minage)/(maxage-minage)*10);
if (j==index){
fill(255, 0, 0);
text(names[j], xx-textWidth(names[j])/2, yy);
}
}
fill(0, 255, 0);
for (int j=0; j<data.length; j++){
rect(200*data[j][2]+10,
60*data[j][3]+10,
10,
10);
}
image(img, 0, 0, 80, 40);
}
void mousePressed(){
i =mouseX;
loop();
frameRate(30);
}
void mouseReleased(){
noLoop();
}