Commit | Line | Data |
---|---|---|
eca6fd31 TW |
1 | package kaka.cakelight.mode; |
2 | ||
fa013e4b | 3 | import kaka.cakelight.Color; |
fa013e4b | 4 | import kaka.cakelight.LedFrame; |
eca6fd31 TW |
5 | import kaka.cakelight.util.SimplexNoise3D; |
6 | ||
7 | public class TwoColorNoiseMode extends AmbientMode { | |
8 | private final Color primary, secondary; | |
9 | private SimplexNoise3D noise = new SimplexNoise3D(0); | |
10 | ||
eca6fd31 TW |
11 | public TwoColorNoiseMode(Color primary, Color secondary) { |
12 | this.primary = primary; | |
13 | this.secondary = secondary; | |
14 | } | |
15 | ||
16 | @Override | |
17 | protected void updateFrame(LedFrame frame, long time, int count) { | |
18 | for (int i = 0; i < config.leds.getCount(); i++) { | |
19 | double x = frame.xOf(i); | |
20 | double y = frame.yOf(i); | |
21 | double v = Math.pow(Math.min(1, Math.max(0, noise.getr(0.0, 1.0, 1, x, y, time / 7000.0))), 1.5); | |
22 | frame.setLedColor(i, primary.interpolate(secondary, v)); | |
23 | } | |
24 | } | |
25 | } |