New: Alpha drawing mode, in 'Translucency'. Drawing AA Text automatically activates it. Fixed a problem in non-AA text that made it pick wrong colors if the current skin wasn't using white and black.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1512 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
ab657b018e
commit
95665a99df
@ -4942,6 +4942,20 @@ void Button_Text()
|
|||||||
Change_paintbrush_shape(PAINTBRUSH_SHAPE_COLOR_BRUSH);
|
Change_paintbrush_shape(PAINTBRUSH_SHAPE_COLOR_BRUSH);
|
||||||
else
|
else
|
||||||
Change_paintbrush_shape(PAINTBRUSH_SHAPE_MONO_BRUSH);
|
Change_paintbrush_shape(PAINTBRUSH_SHAPE_MONO_BRUSH);
|
||||||
|
// Activate alpha mode
|
||||||
|
if (antialias && TrueType_font(selected_font_index))
|
||||||
|
{
|
||||||
|
Shade_mode=0;
|
||||||
|
Quick_shade_mode=0;
|
||||||
|
Smooth_mode=0;
|
||||||
|
Tiling_mode=0;
|
||||||
|
Smear_mode=0;
|
||||||
|
Colorize_mode=1;
|
||||||
|
Colorize_current_mode=3;
|
||||||
|
Effect_function=Effect_alpha_colorize;
|
||||||
|
|
||||||
|
Draw_menu_button(BUTTON_EFFECTS,BUTTON_PRESSED);
|
||||||
|
}
|
||||||
|
|
||||||
Select_button(BUTTON_DRAW,LEFT_SIDE);
|
Select_button(BUTTON_DRAW,LEFT_SIDE);
|
||||||
if (Config.Auto_discontinuous)
|
if (Config.Auto_discontinuous)
|
||||||
|
|||||||
@ -553,6 +553,9 @@ void Button_Colorize_mode(void)
|
|||||||
break;
|
break;
|
||||||
case 2 :
|
case 2 :
|
||||||
Effect_function=Effect_substractive_colorize;
|
Effect_function=Effect_substractive_colorize;
|
||||||
|
break;
|
||||||
|
case 3 :
|
||||||
|
Effect_function=Effect_alpha_colorize;
|
||||||
}
|
}
|
||||||
Shade_mode=0;
|
Shade_mode=0;
|
||||||
Quick_shade_mode=0;
|
Quick_shade_mode=0;
|
||||||
@ -588,6 +591,9 @@ void Button_Colorize_display_selection(int mode)
|
|||||||
break;
|
break;
|
||||||
case 2 : // Méthode soustractive
|
case 2 : // Méthode soustractive
|
||||||
y_pos=74;
|
y_pos=74;
|
||||||
|
break;
|
||||||
|
case 3 : // Méthode alpha
|
||||||
|
y_pos=91;
|
||||||
}
|
}
|
||||||
Print_in_window(4,y_pos,"\020",MC_Black,MC_Light);
|
Print_in_window(4,y_pos,"\020",MC_Black,MC_Light);
|
||||||
Print_in_window(129,y_pos,"\021",MC_Black,MC_Light);
|
Print_in_window(129,y_pos,"\021",MC_Black,MC_Light);
|
||||||
@ -600,7 +606,7 @@ void Button_Colorize_menu(void)
|
|||||||
short clicked_button;
|
short clicked_button;
|
||||||
char str[4];
|
char str[4];
|
||||||
|
|
||||||
Open_window(140,118,"Transparency");
|
Open_window(140,135,"Transparency");
|
||||||
|
|
||||||
Print_in_window(16,23,"Opacity:",MC_Dark,MC_Light);
|
Print_in_window(16,23,"Opacity:",MC_Dark,MC_Light);
|
||||||
Window_set_input_button(87,21,3); // 1
|
Window_set_input_button(87,21,3); // 1
|
||||||
@ -610,9 +616,10 @@ void Button_Colorize_menu(void)
|
|||||||
|
|
||||||
Window_set_normal_button(16,54,108,14,"Additive" ,2,1,SDLK_d); // 3
|
Window_set_normal_button(16,54,108,14,"Additive" ,2,1,SDLK_d); // 3
|
||||||
Window_set_normal_button(16,71,108,14,"Subtractive",1,1,SDLK_s); // 4
|
Window_set_normal_button(16,71,108,14,"Subtractive",1,1,SDLK_s); // 4
|
||||||
|
Window_set_normal_button(16,88,108,14,"Alpha",1,1,SDLK_a); // 4
|
||||||
|
|
||||||
Window_set_normal_button(16,94, 51,14,"Cancel" ,0,1,KEY_ESC); // 5
|
Window_set_normal_button(16,111, 51,14,"Cancel" ,0,1,KEY_ESC); // 5
|
||||||
Window_set_normal_button(73,94, 51,14,"OK" ,0,1,SDLK_RETURN); // 6
|
Window_set_normal_button(73,111, 51,14,"OK" ,0,1,SDLK_RETURN); // 6
|
||||||
|
|
||||||
Num2str(Colorize_opacity,str,3);
|
Num2str(Colorize_opacity,str,3);
|
||||||
Window_input_content(Window_special_button_list,str);
|
Window_input_content(Window_special_button_list,str);
|
||||||
@ -643,9 +650,10 @@ void Button_Colorize_menu(void)
|
|||||||
}
|
}
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
break;
|
break;
|
||||||
case 2: // Méthode interpolée
|
case 2: // Interpolated method
|
||||||
case 3: // Méthode additive
|
case 3: // Additive method
|
||||||
case 4: // Méthode soustractive
|
case 4: // Substractive method
|
||||||
|
case 5: // Alpha method
|
||||||
selected_mode=clicked_button-2;
|
selected_mode=clicked_button-2;
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
Button_Colorize_display_selection(selected_mode);
|
Button_Colorize_display_selection(selected_mode);
|
||||||
@ -654,13 +662,13 @@ void Button_Colorize_menu(void)
|
|||||||
if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
||||||
Window_help(BUTTON_EFFECTS, "TRANSPARENCY");
|
Window_help(BUTTON_EFFECTS, "TRANSPARENCY");
|
||||||
else if (Is_shortcut(Key,SPECIAL_COLORIZE_MENU))
|
else if (Is_shortcut(Key,SPECIAL_COLORIZE_MENU))
|
||||||
clicked_button=6;
|
clicked_button=7;
|
||||||
}
|
}
|
||||||
while (clicked_button<5);
|
while (clicked_button<6);
|
||||||
|
|
||||||
Close_window();
|
Close_window();
|
||||||
|
|
||||||
if (clicked_button==6) // OK
|
if (clicked_button==7) // OK
|
||||||
{
|
{
|
||||||
Colorize_opacity =chosen_opacity;
|
Colorize_opacity =chosen_opacity;
|
||||||
Colorize_current_mode=selected_mode;
|
Colorize_current_mode=selected_mode;
|
||||||
|
|||||||
16
src/misc.c
16
src/misc.c
@ -499,6 +499,22 @@ byte Effect_substractive_colorize(word x,word y,byte color)
|
|||||||
blue<blue_under?blue:blue_under);
|
blue<blue_under?blue:blue_under);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte Effect_alpha_colorize (word x,word y,byte color)
|
||||||
|
{
|
||||||
|
byte color_under = Read_pixel_from_feedback_screen(x,y);
|
||||||
|
byte blue_under=Main_palette[color_under].B;
|
||||||
|
byte green_under=Main_palette[color_under].G;
|
||||||
|
byte red_under=Main_palette[color_under].R;
|
||||||
|
int factor=(Main_palette[color].R*76 +
|
||||||
|
Main_palette[color].G*151 +
|
||||||
|
Main_palette[color].B*28)/255;
|
||||||
|
|
||||||
|
return Best_color(
|
||||||
|
(Main_palette[Fore_color].R*factor + red_under*(255-factor))/255,
|
||||||
|
(Main_palette[Fore_color].G*factor + green_under*(255-factor))/255,
|
||||||
|
(Main_palette[Fore_color].B*factor + blue_under*(255-factor))/255);
|
||||||
|
}
|
||||||
|
|
||||||
void Check_timer(void)
|
void Check_timer(void)
|
||||||
{
|
{
|
||||||
if((SDL_GetTicks()/55)-Timer_delay>Timer_start) Timer_state=1;
|
if((SDL_GetTicks()/55)-Timer_delay>Timer_start) Timer_state=1;
|
||||||
|
|||||||
@ -86,6 +86,7 @@ void Replace_colors_within_limits(byte * replace_table);
|
|||||||
byte Effect_interpolated_colorize (word x,word y,byte color);
|
byte Effect_interpolated_colorize (word x,word y,byte color);
|
||||||
byte Effect_additive_colorize (word x,word y,byte color);
|
byte Effect_additive_colorize (word x,word y,byte color);
|
||||||
byte Effect_substractive_colorize(word x,word y,byte color);
|
byte Effect_substractive_colorize(word x,word y,byte color);
|
||||||
|
byte Effect_alpha_colorize(word x,word y,byte color);
|
||||||
byte Effect_sieve(word x,word y);
|
byte Effect_sieve(word x,word y);
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|||||||
@ -431,6 +431,9 @@ void Transparency_set(byte amount)
|
|||||||
break;
|
break;
|
||||||
case 2 :
|
case 2 :
|
||||||
Effect_function=Effect_substractive_colorize;
|
Effect_function=Effect_substractive_colorize;
|
||||||
|
break;
|
||||||
|
case 3 :
|
||||||
|
Effect_function=Effect_alpha_colorize;
|
||||||
}
|
}
|
||||||
Shade_mode=0;
|
Shade_mode=0;
|
||||||
Quick_shade_mode=0;
|
Quick_shade_mode=0;
|
||||||
|
|||||||
39
src/text.c
39
src/text.c
@ -377,8 +377,8 @@ byte *Render_text_TTF(const char *str, int font_number, int size, int antialias,
|
|||||||
int index;
|
int index;
|
||||||
int style;
|
int style;
|
||||||
|
|
||||||
SDL_Color Couleur_Avant;
|
SDL_Color fg_color;
|
||||||
SDL_Color Couleur_Arriere;
|
SDL_Color bg_color;
|
||||||
|
|
||||||
// Chargement de la fonte
|
// Chargement de la fonte
|
||||||
font=TTF_OpenFont(Font_name(font_number), size);
|
font=TTF_OpenFont(Font_name(font_number), size);
|
||||||
@ -386,6 +386,7 @@ byte *Render_text_TTF(const char *str, int font_number, int size, int antialias,
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Style
|
// Style
|
||||||
style=0;
|
style=0;
|
||||||
if (italic)
|
if (italic)
|
||||||
@ -393,24 +394,18 @@ byte *Render_text_TTF(const char *str, int font_number, int size, int antialias,
|
|||||||
if (bold)
|
if (bold)
|
||||||
style|=TTF_STYLE_BOLD;
|
style|=TTF_STYLE_BOLD;
|
||||||
TTF_SetFontStyle(font, style);
|
TTF_SetFontStyle(font, style);
|
||||||
|
|
||||||
// Couleurs
|
// Couleurs
|
||||||
if (antialias)
|
fg_color.r=fg_color.g=fg_color.b=255;
|
||||||
{
|
bg_color.r=bg_color.g=bg_color.b=0;
|
||||||
Couleur_Avant = Color_to_SDL_color(Fore_color);
|
// The following is alpha, supposedly unused
|
||||||
Couleur_Arriere = Color_to_SDL_color(Back_color);
|
bg_color.unused=fg_color.unused=255;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Couleur_Avant = Color_to_SDL_color(MC_White);
|
|
||||||
Couleur_Arriere = Color_to_SDL_color(MC_Black);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Rendu du texte: crée une surface SDL RGB 24bits
|
// Rendu du texte: crée une surface SDL RGB 24bits
|
||||||
if (antialias)
|
if (antialias)
|
||||||
TexteColore=TTF_RenderText_Shaded(font, str, Couleur_Avant, Couleur_Arriere );
|
TexteColore=TTF_RenderText_Shaded(font, str, fg_color, bg_color );
|
||||||
else
|
else
|
||||||
TexteColore=TTF_RenderText_Solid(font, str, Couleur_Avant);
|
TexteColore=TTF_RenderText_Solid(font, str, fg_color);
|
||||||
if (!TexteColore)
|
if (!TexteColore)
|
||||||
{
|
{
|
||||||
TTF_CloseFont(font);
|
TTF_CloseFont(font);
|
||||||
@ -431,13 +426,17 @@ byte *Render_text_TTF(const char *str, int font_number, int size, int antialias,
|
|||||||
}
|
}
|
||||||
if (!antialias)
|
if (!antialias)
|
||||||
{
|
{
|
||||||
// Mappage des couleurs
|
// Map colors: white->fg, black->bg
|
||||||
for (index=0; index < Texte8Bit->w * Texte8Bit->h; index++)
|
for (index=0; index < Texte8Bit->w * Texte8Bit->h; index++)
|
||||||
{
|
{
|
||||||
if (*(new_brush+index) == MC_Black)
|
int sum;
|
||||||
*(new_brush+index)=Back_color;
|
sum = Main_palette[*(new_brush+index)].R
|
||||||
else if (*(new_brush+index) == MC_White)
|
+ Main_palette[*(new_brush+index)].G
|
||||||
*(new_brush+index)=Fore_color;
|
+ Main_palette[*(new_brush+index)].B;
|
||||||
|
if (sum < 128 * 3)
|
||||||
|
*(new_brush+index)=Back_color;
|
||||||
|
else
|
||||||
|
*(new_brush+index)=Fore_color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*width=Texte8Bit->w;
|
*width=Texte8Bit->w;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user