Introduce contrast logic for text labels on GPX traces
This commit is contained in:
parent
9d28c87c23
commit
e771eade6d
1 changed files with 11 additions and 0 deletions
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue