From 97df4349399e5ffd56cdc3ca488789beb3aba81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Oberm=C3=BChlner?= Date: Thu, 21 Mar 2019 21:26:13 +0100 Subject: [PATCH] random data colors also ranged in saturation/brightness --- .../main/java/ch/obermuhlner/csv2chart/Application.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ch.obermuhlner.csv2chart/src/main/java/ch/obermuhlner/csv2chart/Application.java b/ch.obermuhlner.csv2chart/src/main/java/ch/obermuhlner/csv2chart/Application.java index ffd0767..886ab4f 100644 --- a/ch.obermuhlner.csv2chart/src/main/java/ch/obermuhlner/csv2chart/Application.java +++ b/ch.obermuhlner.csv2chart/src/main/java/ch/obermuhlner/csv2chart/Application.java @@ -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;