Skip to content
Snippets Groups Projects
Commit 6e708748 authored by Lucas Philippe's avatar Lucas Philippe
Browse files

ajout etape 5

parent bf2ab336
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ class City { ...@@ -7,6 +7,7 @@ class City {
float density; float density;
float altitude; float altitude;
float radius=0; float radius=0;
boolean isHighlighted=false;
// put a drawing function in here and call from main drawing loop } // put a drawing function in here and call from main drawing loop }
public City(String postalcode, String name, float x, float y, float population, float surface, float altitude) { public City(String postalcode, String name, float x, float y, float population, float surface, float altitude) {
...@@ -28,7 +29,11 @@ class City { ...@@ -28,7 +29,11 @@ class City {
radius=map(this.population, minPopulation, maxPopulation, 3, 100); radius=map(this.population, minPopulation, maxPopulation, 3, 100);
// Draw marker // Draw marker
fill(hue, 100, 100); float alpha = 80;
if(isHighlighted){
alpha=255;
}
fill(hue, 100, 100, alpha);
ellipse(x, y, radius, radius); ellipse(x, y, radius, radius);
} }
......
...@@ -146,16 +146,27 @@ void keyPressed() { ...@@ -146,16 +146,27 @@ void keyPressed() {
} }
void mouseMoved() { void mouseMoved() {
//println("(x: " + mouseX + ", y: " + mouseY + ")");
City city = pick(mouseX, mouseY); City city = pick(mouseX, mouseY);
if (city != null) { if (city != null) {
if (lastCitySelected != city) { if (lastCitySelected != city) {
if (lastCitySelected != null) {
lastCitySelected.isHighlighted = false;
}
lastCitySelected = city; lastCitySelected = city;
println(city.name); println(city.name);
lastCitySelected.isHighlighted = true;
redraw();
}
} else {
if (lastCitySelected != null) {
lastCitySelected.isHighlighted = false;
lastCitySelected = null;
redraw();
} }
} }
} }
City pick(int px, int py) { City pick(int px, int py) {
for (int i = totalCount - 1 ; i >= 0; --i) { for (int i = totalCount - 1 ; i >= 0; --i) {
if (cities[i].contains(px, py)) { if (cities[i].contains(px, py)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment