Color picker can grab from pipette or mixer colors too

This commit is contained in:
Bill Kendrick 2023-03-03 00:29:52 -08:00
parent be6878f6d8
commit c2dfd0c2d1
2 changed files with 50 additions and 15 deletions

View file

@ -102,12 +102,13 @@ https://tuxpaint.org/
* Improvements to Color selectors: * Improvements to Color selectors:
-------------------------------- --------------------------------
* [WIP] Rainbow palette color picker allows you to switch * Rainbow palette color picker allows you to switch to the chosen
to the chosen Tux Paint colors, [WIP] the pipette color selector built-in color, the pipette (color selector) color, or the
color, or [WIP] the color mixer color. color mixer's color.
* [WIP] The color mixer allows you to switch to [WIP] the chosen * [WIP] The color mixer allows you to switch to the chosen built-in
Tux Paint color or [WIP] the rainbow palette color picker color. color, the pipette (color selector) color, or the the rainbow palette
(color picker) color.
* New Starter * New Starter
----------- -----------

View file

@ -25033,6 +25033,12 @@ static int do_color_picker(int prev_color)
color_hexes[NUM_DEFAULT_COLORS][1], color_hexes[NUM_DEFAULT_COLORS][1],
color_hexes[NUM_DEFAULT_COLORS][2])); color_hexes[NUM_DEFAULT_COLORS][2]));
dest.x = pipette_left + (img_back->w - img_color_sel->w) / 2;
dest.y = pipette_top + (img_back->h - img_color_sel->h) / 2;
SDL_BlitSurface(img_color_sel, NULL, screen, &dest);
/* (Mixer) */ /* (Mixer) */
mixer_left = r_final.x + r_final.w - (img_back->w + 2); mixer_left = r_final.x + r_final.w - (img_back->w + 2);
@ -25049,6 +25055,11 @@ static int do_color_picker(int prev_color)
color_hexes[NUM_DEFAULT_COLORS + 2][1], color_hexes[NUM_DEFAULT_COLORS + 2][1],
color_hexes[NUM_DEFAULT_COLORS + 2][2])); color_hexes[NUM_DEFAULT_COLORS + 2][2]));
dest.x = mixer_left + (img_back->w - img_color_mix->w) / 2;
dest.y = mixer_top + (img_back->h - img_color_mix->h) / 2;
SDL_BlitSurface(img_color_mix, NULL, screen, &dest);
/* Show "Back" button */ /* Show "Back" button */
@ -25229,19 +25240,42 @@ static int do_color_picker(int prev_color)
chose = 0; chose = 0;
done = 1; done = 1;
} }
else if (event.button.x >= prev_color_left && else if ((event.button.x >= prev_color_left &&
event.button.x < prev_color_left + img_back->w && event.button.x < prev_color_left + img_back->w &&
event.button.y >= prev_color_top && event.button.y >= prev_color_top &&
event.button.y < prev_color_top + img_back->h && event.button.y < prev_color_top + img_back->h &&
prev_color != -1 && prev_color < NUM_DEFAULT_COLORS) prev_color != -1 && prev_color < NUM_DEFAULT_COLORS) ||
(event.button.x >= pipette_left &&
event.button.x < pipette_left + img_back->w &&
event.button.y >= pipette_top &&
event.button.y < pipette_top + img_back->h) ||
(event.button.x >= mixer_left &&
event.button.x < mixer_left + img_back->w &&
event.button.y >= mixer_top &&
event.button.y < mixer_top + img_back->h))
{ {
int c;
float h, s, v; float h, s, v;
/* Switch to the chosen bucket color */ if (event.button.x >= prev_color_left &&
event.button.x < prev_color_left + img_back->w &&
event.button.y >= prev_color_top &&
event.button.y < prev_color_top + img_back->h) {
/* Switch to the chosen bucket color */
c = prev_color;
} else if (event.button.x >= pipette_left &&
event.button.x < pipette_left + img_back->w &&
event.button.y >= pipette_top &&
event.button.y < pipette_top + img_back->h) {
/* Pipette */
c = NUM_DEFAULT_COLORS;
} else {
/* Mixer */
c = NUM_DEFAULT_COLORS + 2;
}
rgbtohsv(color_hexes[prev_color][0], /* Conver the chosen color to HSV & reposition crosshairs */
color_hexes[prev_color][1], rgbtohsv(color_hexes[c][0], color_hexes[c][1], color_hexes[c][2],
color_hexes[prev_color][2],
&h, &s, &v); &h, &s, &v);
color_picker_v = (img_color_picker_val->h * (1.0 - v)); color_picker_v = (img_color_picker_val->h * (1.0 - v));