I'm trying to use some Java Color int values from a database in Javascript. What's the correct way to convert the Java color int (like -2147473665) to an RGB string (like '#ffff00') using Javascript? Converting them straight to hex makes them all dark blue or black...
(Edit) The first answer helped, and I get colors other than black now, but they're still not the right hue. (I know the Google Maps API takes RGB, not HSV, so it's not that...)
function getClients() {
var query = new Parse.Query(Client);
query.each(function(client) {
var clientName = client.get("clientName");
var borderColor = '#' + (-client.get("borderColor")).toString(16);
var fillColor = '#' + (-client.get("fillColor")).toString(16).substr(2);
var outline = client.get("outline");
console.log(client.get("borderColor"));
console.log(client.get("borderColor").toString(16));
console.log(hexToRGB(client.get("borderColor")));
var clientPoly = new google.maps.Polygon({
paths: outline,
strokeColor: borderColor,
strokeOpacity: 1,
strokeWeight: 2,
fillColor: fillColor,
fillOpacity: 0.5
});
clientPoly.setMap(mMap);
});
}
For example, the int -16767233 should be navy blue, but it's showing up as yellow.
-16731137 should be light blue, but it's red
-1218518 should be orange, but it's blue