private void fade(Color from, Color to) throws IOException { for (int i = 0; i <= 1000; i++) { float r = from.red + i * (to.red - from.red) / 1000; float g = from.green + i * (to.green - from.green) / 1000; float b = from.blue + i * (to.blue - from.blue) / 1000; System.out.printf("rgb %1.3f %1.3f %1.3f\r", r, g, b); red.dutyCycle(r); green.dutyCycle(g); blue.dutyCycle(b); try { Thread.sleep(10); } catch (InterruptedException e) { } } }
public void close() throws IOException { red.close(); green.close(); blue.close(); }