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 {
float density;
float altitude;
float radius=0;
boolean isHighlighted=false;
// 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) {
......@@ -28,7 +29,11 @@ class City {
radius=map(this.population, minPopulation, maxPopulation, 3, 100);
// Draw marker
fill(hue, 100, 100);
float alpha = 80;
if(isHighlighted){
alpha=255;
}
fill(hue, 100, 100, alpha);
ellipse(x, y, radius, radius);
}
......
......@@ -146,16 +146,27 @@ void keyPressed() {
}
void mouseMoved() {
//println("(x: " + mouseX + ", y: " + mouseY + ")");
City city = pick(mouseX, mouseY);
if (city != null) {
if (lastCitySelected != city) {
if (lastCitySelected != null) {
lastCitySelected.isHighlighted = false;
}
lastCitySelected = city;
println(city.name);
lastCitySelected.isHighlighted = true;
redraw();
}
} else {
if (lastCitySelected != null) {
lastCitySelected.isHighlighted = false;
lastCitySelected = null;
redraw();
}
}
}
City pick(int px, int py) {
for (int i = totalCount - 1 ; i >= 0; --i) {
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