Skip to content

Commit

Permalink
random data colors also ranged in saturation/brightness
Browse files Browse the repository at this point in the history
  • Loading branch information
eobermuhlner committed Mar 21, 2019
1 parent 24c99dc commit 97df434
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,14 @@ private static Paint[] createRandomColors(Parameters parameters) {
Random random = new Random(1);
Paint[] paints = new Paint[n];

float alpha = (float) parameters.dataColorAlpha;
float centerSaturation = (float) parameters.dataColorSaturation;
float centerBrightness = (float) parameters.dataColorBrightness;
for (int i = 0; i < n; i++) {
float hue = random.nextFloat();
paints[i] = Colors.ahsbToColor(parameters.dataColorAlpha, hue, parameters.dataColorSaturation, parameters.dataColorBrightness);
float saturation = centerSaturation * (0.9f + random.nextFloat() * 0.2f);
float brightness = centerBrightness * (0.9f + random.nextFloat() * 0.2f);
paints[i] = Colors.ahsbToColor(alpha, hue, saturation, brightness);
}

return paints;
Expand Down

0 comments on commit 97df434

Please sign in to comment.