4 ms·
//fix the sine wave amplitude and offset static final float CHANNEL_MUL = 127.5f; static final float OFFSET_R = 0f; static final float OFFSET_G = (f
by yarg 4y ago
//fix the sine wave amplitude and offset
static final float CHANNEL_MUL = 127.5f;
static final float OFFSET_R = 0f;
static final float OFFSET_G = (float)(TWO_PI/3);
static final float OFFSET_B = 2 * OFFSET_G;
public int buildColour(float theta){
final int r = round(CHANNEL_MUL * (1f + sin(theta + OFFSET_R)));
final int g = round(CHANNEL_MUL * (1f + sin(theta + OFFSET_G)));
final int b = round(CHANNEL_MUL * (1f + sin(theta + OFFSET_B)));
return 0xFF000000 | (r << 0x10) | (g << 0x08) | b;
}