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

Ajout etape 2

parent dd480a20
No related branches found
No related tags found
No related merge requests found
......@@ -14,10 +14,13 @@ City cities[];
int legendsHeight=100;
int minPopulationToDisplay=10000;
boolean redrawInProgress=false;
void setup() {
size(900,900);
colorMode(HSB, 360, 100, 100);
readData();
noLoop();
}
void draw(){
......@@ -46,11 +49,11 @@ void draw(){
if (legendsHeight > 0) {
drawLegend();
}
redrawInProgress=false;
}
void readData() {
redrawInProgress=true;
String[] lines = loadStrings("./villes.tsv");
// check that the file has been loaded
......@@ -99,11 +102,11 @@ void parseInfo(String line) {
}
float mapX(float x) {
return map(x, minX, maxX, 0, 800);
return map(x, minX, maxX, 50, 800);
}
float mapY(float y) {
return map(y, maxY, minY, 0, 800);
return map(y, maxY, minY, 50, 800);
}
void drawLegend() {
......@@ -122,3 +125,21 @@ void drawLegend() {
//drawAltitudeLegend(minAltitude, maxAltitude, distributionX, distributionY, distributionWidth, distributionHeight);
drawDistributionPopulationLegend(minPopulation, maxPopulation, distributionX, distributionY, distributionWidth, distributionHeight, numberOfDiv, populationValues);
}
void keyPressed() {
if(redrawInProgress) {
return;
}
int gap=2;
if (key == '+') {
if (minPopulationToDisplay == 0) {
minPopulationToDisplay = 1;
}
minPopulationToDisplay = minPopulationToDisplay * gap;
readData();
} else if (key == '-') {
minPopulationToDisplay = minPopulationToDisplay / gap;
readData();
}
redraw();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment