smoother color blending

This commit is contained in:
Felix Klenner 2021-08-12 11:02:49 +02:00
parent dfa91904e0
commit 846959f313
2 changed files with 9 additions and 8 deletions

View file

@ -12,7 +12,7 @@ public class EffectManager {
private boolean sweep = false; 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 int activeId = 0;
private final TrayIcon trayIcon; private final TrayIcon trayIcon;

View file

@ -4,6 +4,7 @@ import de.zuim.ledcontrol.LEDEffect;
import java.awt.*; import java.awt.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import static de.zuim.ledcontrol.LEDControl.HEIGHT; import static de.zuim.ledcontrol.LEDControl.HEIGHT;
@ -30,17 +31,17 @@ public class ClockEffect implements LEDEffect {
public void render(long timeDelta, Graphics g) { public void render(long timeDelta, Graphics g) {
//fontSwitcher(); //fontSwitcher();
Date date = new Date(); Calendar time = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("H:mm"); String text = new SimpleDateFormat("H:mm").format(time.getTime());
String text = formatter.format(date); String text2 = new SimpleDateFormat("ss").format(time.getTime());
SimpleDateFormat formatter2 = new SimpleDateFormat("ss");
String text2 = formatter2.format(date);
g.setFont(font); 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; //posOffset-=(4*getScale()*timeDelta)/1000000000.0;
g.drawString(text, (int) posOffset, HEIGHT / 2 * getScale()); 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()); g.drawString(text2, 5, HEIGHT * getScale());
if (posOffset < -g.getFontMetrics().stringWidth(text)) if (posOffset < -g.getFontMetrics().stringWidth(text))
posOffset = 0; posOffset = 0;