diff --git a/TP5/sketch_240321a/City.pde b/TP5/sketch_240321a/City.pde index 287e73eac3af9b125c1617ba01792956db4b839f..1aabf0eb9535fdb4ed33c6e8b8bcd8556a7d33c3 100644 --- a/TP5/sketch_240321a/City.pde +++ b/TP5/sketch_240321a/City.pde @@ -35,6 +35,21 @@ class City { } fill(hue, 100, 100, alpha); ellipse(x, y, radius, radius); + + // Draw city name + if (isHighlighted) { + textSize(16); + textAlign(LEFT, CENTER); + float textWidth = textWidth(name); + float rectWidth = textWidth + 10; + float rectHeight = 20; + fill(255); + rect(x + radius/2 + 5, y - rectHeight/2, rectWidth, rectHeight, 5); + fill(0); + text(name, x + radius/2 + 10, y - 2); + setBasePen(); + } + } boolean contains(int px, int py){ diff --git a/TP5/sketch_240321a/ColorPalette.pde b/TP5/sketch_240321a/ColorPalette.pde index 0db55417eb72e87a99d1b65165a01eaa12cff413..b66f0dfffbe49767efbbb8a1147c365a14371132 100644 --- a/TP5/sketch_240321a/ColorPalette.pde +++ b/TP5/sketch_240321a/ColorPalette.pde @@ -1,3 +1,8 @@ float getColorForAltitude(float altitude) { return map(altitude, 0, 100, 230, -50); } + +void setBasePen() { + fill(0); + textSize(12); +} diff --git a/TP5/sketch_240321a/sketch_240321a.pde b/TP5/sketch_240321a/sketch_240321a.pde index ea8a991437adb24ec72beefe06dd754ce36f93ee..806fc4f6a0863336625b9ea3a618bddf5cd3411a 100644 --- a/TP5/sketch_240321a/sketch_240321a.pde +++ b/TP5/sketch_240321a/sketch_240321a.pde @@ -32,7 +32,7 @@ void draw(){ textSize(20); textAlign(CENTER,CENTER); text("Afficher les populations supérieures à " + minPopulationToDisplay, width/2, 20); - textSize(12); + setBasePen(); for (int i = 0 ; i < totalCount; ++i) { // draw a point at the coordinates of the city @@ -153,7 +153,7 @@ void mouseMoved() { lastCitySelected.isHighlighted = false; } lastCitySelected = city; - println(city.name); + //println(city.name); lastCitySelected.isHighlighted = true; redraw(); }