Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions mcdevitt_le_tour_de_france_oop/City.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@


class City
{
// properties

int id;
String name;
float lon;
float lat;

// constructors

City(){}

City(int id, String name, float lat, float lon)
{
this.id = id;
this.name = name;
this.lon = lon;
this.lat = lat;
}

// general methods

void display(){}

// setters and getters (mutators and accessors)

void set_lon(float lon){this.lon = lon;}
float get_lon() {return lon;}

void set_lat(float lat){this.lat = lat;}
float get_lat() {return lat;}

void set_name(String name){this.name = name;}
String get_name() {return name;}
}
86 changes: 86 additions & 0 deletions mcdevitt_le_tour_de_france_oop/Country.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@


class Country
{
// properties

int id;
String name;
Table outline;
Table cities;

// constructors

Country(){}

Country(int id, String name, Table outline, Table cities)
{
this.id = id;
this.name = name;
this.outline = outline;
this.cities = cities;
}

// general methods

void display_outline()
{
float[] p = new float[2];
float[] q = new float[2];
float x1, x2, y1, y2;

/* ... outline map */

for (int ipt = 0; ipt < n_france_rows-1; ipt++)
{
p[0] = outline.getFloat(ipt, 2);
p[1] = outline.getFloat(ipt+1, 2);

q[0] = outline.getFloat(ipt, 1);
q[1] = outline.getFloat(ipt+1, 1);

x1 = gps_2_sketch(1, q[0]);
y1 = gps_2_sketch(0, p[0]);
x2 = gps_2_sketch(1, q[1]);
y2 = gps_2_sketch(0, p[1]);

strokeWeight(1);
stroke(80);
noFill();

line(x1, y1, x2, y2);
}
}

/* ... city display method */

void display_cities()
{
float p, q;
float x1, y1;

/* ... outline map */

for (int ivl = 0; ivl < n_villes_d_etapes-1; ivl++)
{
p = cities.getFloat(ivl, 2);
q = cities.getFloat(ivl, 3);

x1 = gps_2_sketch(1, q);
y1 = gps_2_sketch(0, p);

strokeWeight(1);
stroke(60, 60, 60);
noFill();

ellipse(x1, y1, 2, 2);
}

}


// setters and getters (mutators and accessors)

void set_name(String name){this.name = name;}
String get_name() {return name;}
}
51 changes: 51 additions & 0 deletions mcdevitt_le_tour_de_france_oop/Gadget.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@


class Crank
{
// properties

PImage crank_img;
int decade;

// constructors

Crank(){}

Crank(PImage crank_img, int decade)
{
this.crank_img = crank_img;
this.decade = decade;
}

// general methods

void update(int decade)
{
int x = width/6;
int y = height/5;
float ang, deg;

deg = (decade - 1) * 360 / 12;
ang = deg * PI / 180;

pushMatrix();
translate(x, y);
face();
rotate(ang);
image(crank_img, 0, 0);
popMatrix();
}

void face()
{
float x, y;

for(int i = 0; i < 12; i++)
{
x = width/12 * cos(float(i) / 12 * 2 * PI);
y = width/12 * sin(float(i) / 12 * 2 * PI);
ellipse(x, y, 15, 15);
}
}

}
72 changes: 72 additions & 0 deletions mcdevitt_le_tour_de_france_oop/Scoreboard.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@



PFont f_title, f_body, f_logo_1, f_logo_2;

class Scoreboard
{
// properties

float[] metric_value;
String[] metric;

// constructors

Scoreboard(){}

Scoreboard(float[] metric_value, String[] metric)
{
this.metric_value = metric_value;
this.metric = metric;
}

// general methods

void update(float[] metric_value)
{
f_title = createFont("Ubuntu", 35, true);
f_body = createFont("Ubuntu", 50, true);
f_logo_1 = createFont("Ubuntu", 100, true);
f_logo_2 = createFont("Ubuntu", 45, true);

smooth();
char bullet = '•';

textFont(f_title);
textAlign(RIGHT);
textLeading(0);
fill(50, 50, 50);
// text(description[0], width/4, height/6);

textFont(f_body);
textAlign(LEFT);
textLeading(20);

for (int iqx = 0; iqx < metric.length; iqx++)
{
fill(50);
text(metric[iqx], width/20, height/2 + iqx * 60);
}

textFont(f_title);
textAlign(RIGHT);
for (int iqx = 0; iqx < metric.length; iqx++)
{
fill(30);
stroke(30);
rect(width/4-20, height/2 + iqx * 60-50 + 5, 200, 50);

fill(40, 40, 40, 50);
rect(width/4-20, height/2 + iqx * 60-50 + 5, 150, 50);

fill(60);
text(str(int(metric_value[iqx])), width/3, height/2 + iqx * 60);
}

}

// setters and getters (mutators and accessors)

float[] get_metric_value() {return metric_value;}

}
84 changes: 84 additions & 0 deletions mcdevitt_le_tour_de_france_oop/Stage.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@


class Stage
{
// properties

int year;
int ietape;
City depart_;
City arrivee_;
float distance;
String winner;

// constructors

Stage(){}

Stage(int year, int ietape, City depart_, City arrivee_, float distance, String winner)
{
this.year = year;
this.ietape = ietape;
this.depart_ = depart_;
this.arrivee_ = arrivee_;
this.distance = distance;
this.winner = winner;
}

// general methods

int realize(int ian, int iet, color clr, int lwidth)
{
float[] p = new float[2];
float[] q = new float[2];
float x1, x2, y1, y2;
float paris_lat = 46;
float paris_lon = 2.5;
float z1, z2;


p[0] = depart_.lat;
p[1] = arrivee_.lat;

q[0] = depart_.lon;
q[1] = arrivee_.lon;

x1 = gps_2_sketch(1, q[0]);
y1 = gps_2_sketch(0, p[0]);
x2 = gps_2_sketch(1, q[1]);
y2 = gps_2_sketch(0, p[1]);
z1 = gps_2_sketch(1, paris_lon);
z2 = gps_2_sketch(0, paris_lat);

noFill();

/* ... departure city */

strokeWeight(3);
stroke(100);
ellipse(x1, y1, 5, 5);

/* ... connnective curve */

strokeWeight(lwidth);
stroke(clr);
// curveTightness(0);
curve(z1, z2, x1, y1, x2, y2, z1, z2);

/* ... arrival city */

strokeWeight(3);
stroke(100);
ellipse(x2, y2, 5, 5);

return 1;
}

// setters and getters (mutators and accessors)

void set_distance(float distance){this.distance = distance;}
float get_distance() {return distance;}

void set_winner(String winner){this.winner = winner;}
String get_winner() {return winner;}
}
Loading