Filling polygon shapes
in
Programming Questions
•
2 years ago
Dear,
I am trying to render a map from tab delimited file with latitude and longitude coordinates using the following code:
However my fill() instruction seems to be ignored here as the polygons are not filled (instead they have a background color). What goes wrong here?
I am trying to render a map from tab delimited file with latitude and longitude coordinates using the following code:
- void drawMapPolygons() {
- // Dark grey polygon boundaries
- stroke(105, 105, 105);
- strokeWeight(1);
- strokeJoin(ROUND);
- // Sand brown polygon filling
- fill(244, 164, 96);
- int rowCount = mapdata.nrow;
- String region;
- String nextRegion;
- for (int row = 0; row < rowCount - 1; row++) {
- region = mapdata.locations[row];
- nextRegion = mapdata.locations[row + 1];
- if (nextRegion.toLowerCase().equals(region.toLowerCase())) {
- beginShape();
- float X = map(mapdata.getFloat(row, 0), minX, maxX, mapX1,
- mapX2);
- float Y = map(Utils.getMercatorLatitude(mapdata
- .getFloat(row, 1)), minY, maxY, mapY2, mapY1);
- float XEND = map(mapdata.getFloat(row + 1, 0), minX, maxX,
- mapX1, mapX2);
- float YEND = map(Utils.getMercatorLatitude(mapdata.getFloat(
- row + 1, 1)), minY, maxY, mapY2, mapY1);
- vertex(X, Y);
- vertex(XEND, YEND);
- }
- endShape(CLOSE);
- }// END: row loop
- }// END: drawMapPolygons
However my fill() instruction seems to be ignored here as the polygons are not filled (instead they have a background color). What goes wrong here?
1