Changeset 9223 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2015-12-30T21:26:57+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ColorHelper.java
r8846 r9223 72 72 return code; 73 73 } 74 75 /** 76 * Determines the correct foreground color (black or white) to use for the given background, 77 * so the text will be readable. 78 * @param bg background color 79 * @return {@code Color#BLACK} or {@code Color#WHITE} 80 * @since 9223 81 */ 82 public static Color getForegroundColor(Color bg) { 83 // http://stackoverflow.com/a/3943023/2257172 84 return (bg.getRed()*0.299 + bg.getGreen()*0.587 + bg.getBlue()*0.114) > 186 ? 85 Color.BLACK : Color.WHITE; 86 } 74 87 }
Note:
See TracChangeset
for help on using the changeset viewer.