Merge pull request #7739 from deathbeam/use-hsl
Use HSB instead of RGBA to generate color from object
This commit is contained in:
@@ -474,7 +474,7 @@ public class PartyPlugin extends Plugin implements KeyListener
|
||||
worldMapManager.add(worldMapPoint);
|
||||
}
|
||||
|
||||
return new PartyData(u, name, worldMapPoint, ColorUtil.fromObject(name, true));
|
||||
return new PartyData(u, name, worldMapPoint, ColorUtil.fromObject(name));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -231,16 +231,12 @@ public class ColorUtil
|
||||
/**
|
||||
* Creates color from passed object hash code
|
||||
* @param object object with hashCode
|
||||
* @param skipAlpha skips alpha
|
||||
* @return color
|
||||
*/
|
||||
public static Color fromObject(@Nonnull final Object object, boolean skipAlpha)
|
||||
public static Color fromObject(@Nonnull final Object object)
|
||||
{
|
||||
int i = object.hashCode();
|
||||
int r = (i >> 24) & 0xFF;
|
||||
int g = (i >> 16) & 0xFF;
|
||||
int b = (i >> 8) & 0xFF;
|
||||
int a = i & 0xFF;
|
||||
return new Color(r, g, b, skipAlpha ? 255 : a);
|
||||
float h = (i % 360) / 360f;
|
||||
return Color.getHSBColor(h, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user