From 846959f31340c47082e0756f57a3f92097d3b118 Mon Sep 17 00:00:00 2001 From: Felix Klenner Date: Thu, 12 Aug 2021 11:02:49 +0200 Subject: [PATCH] smoother color blending --- .../java/de/zuim/ledcontrol/EffectManager.java | 2 +- .../de/zuim/ledcontrol/effects/ClockEffect.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/zuim/ledcontrol/EffectManager.java b/src/main/java/de/zuim/ledcontrol/EffectManager.java index ddc0530..8a51b32 100644 --- a/src/main/java/de/zuim/ledcontrol/EffectManager.java +++ b/src/main/java/de/zuim/ledcontrol/EffectManager.java @@ -12,7 +12,7 @@ public class EffectManager { private boolean sweep = false; - private final LEDEffect[] effects = new LEDEffect[]{new AnalogClockEffect(), new ClockEffect(), new NetworkSpeedEffect(), new AudioVolumeEffect(), new SineEffect(), new AudioFFTEffect(), new ColorSweepEffect()}; + private final LEDEffect[] effects = new LEDEffect[]{new ClockEffect(), new AnalogClockEffect(), new NetworkSpeedEffect(), new AudioVolumeEffect(), new SineEffect(), new AudioFFTEffect(), new ColorSweepEffect()}; private int activeId = 0; private final TrayIcon trayIcon; diff --git a/src/main/java/de/zuim/ledcontrol/effects/ClockEffect.java b/src/main/java/de/zuim/ledcontrol/effects/ClockEffect.java index 14fee4e..2f3391f 100644 --- a/src/main/java/de/zuim/ledcontrol/effects/ClockEffect.java +++ b/src/main/java/de/zuim/ledcontrol/effects/ClockEffect.java @@ -4,6 +4,7 @@ import de.zuim.ledcontrol.LEDEffect; import java.awt.*; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; import static de.zuim.ledcontrol.LEDControl.HEIGHT; @@ -30,17 +31,17 @@ public class ClockEffect implements LEDEffect { public void render(long timeDelta, Graphics g) { //fontSwitcher(); - Date date = new Date(); - SimpleDateFormat formatter = new SimpleDateFormat("H:mm"); - String text = formatter.format(date); - SimpleDateFormat formatter2 = new SimpleDateFormat("ss"); - String text2 = formatter2.format(date); + Calendar time = Calendar.getInstance(); + String text = new SimpleDateFormat("H:mm").format(time.getTime()); + String text2 = new SimpleDateFormat("ss").format(time.getTime()); g.setFont(font); - g.setColor(new Color(0, 10 - date.getMinutes() / 6, date.getMinutes() / 6)); + g.setColor(Color.getHSBColor((time.get(Calendar.MINUTE)+time.get(Calendar.SECOND)/60f)/60f, 1f, 15f / 255f)); + //g.setColor(new Color(0, 10 - date.getMinutes() / 6, date.getMinutes() / 6)); //posOffset-=(4*getScale()*timeDelta)/1000000000.0; g.drawString(text, (int) posOffset, HEIGHT / 2 * getScale()); - g.setColor(new Color(10 - date.getSeconds() / 6, date.getSeconds() / 6, 0)); + //g.setColor(new Color(10 - date.getSeconds() / 6, date.getSeconds() / 6, 0)); + g.setColor(Color.getHSBColor((time.get(Calendar.SECOND)+time.get(Calendar.MILLISECOND)/1000f)/60f, 1f, 15f / 255f)); g.drawString(text2, 5, HEIGHT * getScale()); if (posOffset < -g.getFontMetrics().stringWidth(text)) posOffset = 0;