How to gradient this color preview

i want to make my color previewer will display the gradient black at bottom the gradient white at the top right corner, once i click the color slider into red .. the top left corner will display the color that i picked

float _barWidth=500.0;
float _hueVal=_barWidth;
boolean gradient = false;
float gradient_colors = new float[4];

void setup() {
size(500, 500);
colorMode(HSB);
}
void draw() {
_hueVal= drawSlider(0, 0.0, _barWidth, 50.0, >_hueVal);
stroke(_hueVal,255,255);
rect(0,50, 500, 500);
}
float drawSlider(float xPos, float yPos, float >sWidth, float sHeight, float hueVal) {
fill(255);
noStroke();
rect(xPos-5, yPos-10, sWidth+30, sHeight+50);

float sliderPos=map(hueVal, 0.0, 255.0, 0.0, >sWidth);
for (int i=0; i<sWidth; i++) {
float hueValue= map(i, 0.0, sWidth, 0.0, 255.0);
stroke(hueValue, 255, 255);
line(xPos+i, yPos, xPos+i, yPos+sHeight);
}

if (mousePressed && mouseX>xPos && >mouseX<(xPos+sWidth) && mouseY>yPos && >mouseY <yPos+sHeight)
{
sliderPos=mouseX-xPos;
hueVal = map(sliderPos, 0.0, sWidth, 0.0, 255.0);
}

stroke(255);
for(int x=50; x<width; x++)
{
for(int y=50; y<height; y++){
float distanceFromTopLeft = dist(x, y, height, 90);
fill(hueVal,x,y);
}
}

rect(sliderPos+xPos-3, yPos-5, 6, sHeight+7);

return hueVal;
}


images (6)

1 Like

please help me to fix this.... i want to make my color previewer will display the gradient black at bottom the gradient white at the top right corner, once i click the color slider into red .. the top left corner will display the color that i picked

Processing.org/reference/get_.html

1 Like

the color previewer belongs to the other thread…

:wink: