Introduce contrast logic for text labels on GPX traces

This commit is contained in:
Hardy 2020-03-16 11:49:57 +01:00 committed by GitHub
parent 9d28c87c23
commit e771eade6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -304,6 +304,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
paintInnerRect.setColor(color);
paintInnerRect.setAlpha(179);
paintTextIcon.setColor(txtlabelColor(color));
paintOuterRect.setColor(txtlabelColor(color));
List<GpxDisplayItem> items = groups.get(0).getModifiableList();
drawSplitItems(canvas, tileBox, items, settings);
@ -312,6 +315,14 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
}
}
private int txtlabelColor(int color) {
//Hardy, 2020-03-16: Contrast logic for text labels on tracks
if (((int) Color.red(color) * .299 + Color.green(color) * .587 + Color.blue(color) * .114) > 149) {
return Color.BLACK;
}
return Color.WHITE;
}
private void drawSplitItems(Canvas canvas, RotatedTileBox tileBox, List<GpxDisplayItem> items, DrawSettings settings) {
final QuadRect latLonBounds = tileBox.getLatLonBounds();
int r = (int) (12 * tileBox.getDensity());