News for hackers. Stuff that matters.
Re:Show HN: Penumbra, a perceptually optimized color palette... by yarg on Friday August 05, 2022 @02:35AM (#32352530)

    //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;
    }

There are no comments on this comment yet.