What am I missing / doing wrong for my rainbow Color Picker to not saturate correctly?

Viewed 1028

I am trying to create a Color Picker similar to that of MS Paint. Unfortunately, I can't figure out the algorithm for saturation. Whenever I try to implement saturation, it simply will not saturate correctly. I have to be missing some understanding of the saturation effect in the algorithm.

enter image description here

This is what my current algorithm creates. Anytime I try to perform a saturated effect going down on the Y axis, it just makes everything after the first line completely red or black.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML;
using SFML.Graphics;
using SFML.Window;

namespace Source
{
   public ColorWheel()
    {
        for (int y = 0; y < 255; y++)
        {
            for (int z = 0; z < 6; z++)
            {
                for (int x = 0; x < 255; x++)
                {
                    uint ux = (uint)x;
                    uint uy = (uint)y;
                    uint uz = (uint)z;
                    ux = ux + (uz * 255);
                    image.SetPixel(ux, uy, color);

                    //Red 255 - Green 0-254
                    if (z == 0)
                    {
                        color.G += 1;
                    }
                    //Green 255 - Red 255-0
                    else if (z == 1)
                    {
                        color.R -= 1;
                    }
                    //Green 255 - Blue 0-255
                    else if (z == 2)
                    {
                        color.B += 1;
                    }
                    //Blue 255 - Green 255-0
                    else if (z == 3)
                    {
                        color.G -= 1;

                    }
                    //Blue 255 - Red 0-255
                    else if (z == 4)
                    {
                        color.R += 1;
                    }
                    //Red 255 - Blue 255-0
                    else if (z == 5)
                    {
                        color.B -= 1;
                    }

        Texture texture = new Texture(image);
        sprite.Texture = texture;
    }

    public void Update(double dt)
    {
    }

    public void Render(RenderWindow rWindow)
    {
        rWindow.Draw(sprite);
    }

}

}

2 Answers
Related