Color cycling based on the ranges in Grad menu. A speed slider has appeared. The speed data (and all cycling) is loaded from IFF/ILBM images from Deluxe Paint, Amiga and DOS versions. The data is not saved at the moment, so you shouldn't re-save cycling images
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1573 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
1c2ab9aa99
commit
4ea23b3e9a
@ -2477,6 +2477,7 @@ void Button_Gradients(void)
|
|||||||
T_Gradient_array backup_gradients[16];
|
T_Gradient_array backup_gradients[16];
|
||||||
int old_current_gradient;
|
int old_current_gradient;
|
||||||
T_Scroller_button * mix_scroller;
|
T_Scroller_button * mix_scroller;
|
||||||
|
T_Scroller_button * speed_scroller;
|
||||||
short old_mouse_x;
|
short old_mouse_x;
|
||||||
short old_mouse_y;
|
short old_mouse_y;
|
||||||
byte old_mouse_k;
|
byte old_mouse_k;
|
||||||
@ -2491,7 +2492,7 @@ void Button_Gradients(void)
|
|||||||
old_current_gradient=Current_gradient;
|
old_current_gradient=Current_gradient;
|
||||||
memcpy(backup_gradients,Gradient_array,sizeof(T_Gradient_array)*16);
|
memcpy(backup_gradients,Gradient_array,sizeof(T_Gradient_array)*16);
|
||||||
|
|
||||||
Open_window(237,133,"Gradation menu");
|
Open_window(258,133,"Gradation menu");
|
||||||
|
|
||||||
Window_set_palette_button(48,21); // 1
|
Window_set_palette_button(48,21); // 1
|
||||||
// Définition du scrolleur <=> indice du dégradé dans le tableau
|
// Définition du scrolleur <=> indice du dégradé dans le tableau
|
||||||
@ -2508,6 +2509,7 @@ void Button_Gradients(void)
|
|||||||
|
|
||||||
Window_set_normal_button(178,112,51,14,"OK",0,1,SDLK_RETURN); // 6
|
Window_set_normal_button(178,112,51,14,"OK",0,1,SDLK_RETURN); // 6
|
||||||
Window_set_normal_button(123,112,51,14,"Cancel",0,1,KEY_ESC); // 7
|
Window_set_normal_button(123,112,51,14,"Cancel",0,1,KEY_ESC); // 7
|
||||||
|
speed_scroller = Window_set_scroller_button(238,22,88,65,1,64-Gradient_array[Current_gradient].Speed); // 8
|
||||||
|
|
||||||
Print_in_window(5,60,"MIX",MC_Dark,MC_Light);
|
Print_in_window(5,60,"MIX",MC_Dark,MC_Light);
|
||||||
|
|
||||||
@ -2534,6 +2536,8 @@ void Button_Gradients(void)
|
|||||||
old_mouse_k=Mouse_K;
|
old_mouse_k=Mouse_K;
|
||||||
|
|
||||||
clicked_button=Window_clicked_button();
|
clicked_button=Window_clicked_button();
|
||||||
|
if (Input_sticky_control!=8 || !Mouse_K)
|
||||||
|
Allow_colorcycling=0;
|
||||||
|
|
||||||
switch(clicked_button)
|
switch(clicked_button)
|
||||||
{
|
{
|
||||||
@ -2602,6 +2606,10 @@ void Button_Gradients(void)
|
|||||||
mix_scroller->Position=Gradient_array[Current_gradient].Mix;
|
mix_scroller->Position=Gradient_array[Current_gradient].Mix;
|
||||||
Window_draw_slider(mix_scroller);
|
Window_draw_slider(mix_scroller);
|
||||||
|
|
||||||
|
// Update speed
|
||||||
|
speed_scroller->Position=64-Gradient_array[Current_gradient].Speed;
|
||||||
|
Window_draw_slider(speed_scroller);
|
||||||
|
|
||||||
// On raffiche la technique qui va avec
|
// On raffiche la technique qui va avec
|
||||||
Draw_button_gradient_style(8,92,Gradient_array[Current_gradient].Technique);
|
Draw_button_gradient_style(8,92,Gradient_array[Current_gradient].Technique);
|
||||||
|
|
||||||
@ -2635,6 +2643,10 @@ void Button_Gradients(void)
|
|||||||
// On affiche la nouvelle preview
|
// On affiche la nouvelle preview
|
||||||
Draw_gradient_preview(8,112,108,14,Current_gradient);
|
Draw_gradient_preview(8,112,108,14,Current_gradient);
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
|
case 8 : // Speed
|
||||||
|
Gradient_array[Current_gradient].Speed=64-Window_attribute2;
|
||||||
|
Allow_colorcycling=1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Mouse_K)
|
if (!Mouse_K)
|
||||||
@ -2670,7 +2682,7 @@ void Button_Gradients(void)
|
|||||||
clicked_button=6;
|
clicked_button=6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (clicked_button<6);
|
while (clicked_button!=6 && clicked_button!=7);
|
||||||
|
|
||||||
Close_window();
|
Close_window();
|
||||||
// The Grad rect operation uses the same button as Grad menu.
|
// The Grad rect operation uses the same button as Grad menu.
|
||||||
|
|||||||
@ -1572,6 +1572,7 @@ void Open_window(word width,word height, const char * title)
|
|||||||
Cursor_shape=CURSOR_SHAPE_ARROW;
|
Cursor_shape=CURSOR_SHAPE_ARROW;
|
||||||
Paintbrush_hidden_before_window=Paintbrush_hidden;
|
Paintbrush_hidden_before_window=Paintbrush_hidden;
|
||||||
Paintbrush_hidden=1;
|
Paintbrush_hidden=1;
|
||||||
|
Allow_colorcycling=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialisation des listes de boutons de la fenêtre
|
// Initialisation des listes de boutons de la fenêtre
|
||||||
@ -1661,6 +1662,7 @@ void Close_window(void)
|
|||||||
|
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
Display_menu();
|
Display_menu();
|
||||||
|
Allow_colorcycling=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Key=0;
|
Key=0;
|
||||||
|
|||||||
@ -766,6 +766,8 @@ GFX2_GLOBAL long Gradient_bounds_range;
|
|||||||
GFX2_GLOBAL long Gradient_total_range;
|
GFX2_GLOBAL long Gradient_total_range;
|
||||||
/// Amount of randomness to use in gradient (1-256+)
|
/// Amount of randomness to use in gradient (1-256+)
|
||||||
GFX2_GLOBAL long Gradient_random_factor;
|
GFX2_GLOBAL long Gradient_random_factor;
|
||||||
|
/// Gradient speed of cycling (0-64)
|
||||||
|
GFX2_GLOBAL byte Gradient_speed;
|
||||||
/// Pointer to a gradient function, depending on the selected method.
|
/// Pointer to a gradient function, depending on the selected method.
|
||||||
GFX2_GLOBAL Func_gradient Gradient_function;
|
GFX2_GLOBAL Func_gradient Gradient_function;
|
||||||
///
|
///
|
||||||
|
|||||||
@ -134,7 +134,7 @@ void Load_SDL_Image(T_IO_Context *);
|
|||||||
|
|
||||||
// ENUM Name TestFunc LoadFunc SaveFunc PalOnly Comment Layers Ext Exts
|
// ENUM Name TestFunc LoadFunc SaveFunc PalOnly Comment Layers Ext Exts
|
||||||
T_Format File_formats[NB_KNOWN_FORMATS] = {
|
T_Format File_formats[NB_KNOWN_FORMATS] = {
|
||||||
{FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, 0, "", "gif;png;bmp;pcx;pkm;lbm;iff;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;kcf;pal;c64;koa;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico"},
|
{FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, 0, "", "gif;png;bmp;pcx;pkm;lbm;ilbm;iff;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;kcf;pal;c64;koa;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico"},
|
||||||
{FORMAT_ALL_FILES, "(*.*)", NULL, NULL, NULL, 0, 0, 0, "", "*"},
|
{FORMAT_ALL_FILES, "(*.*)", NULL, NULL, NULL, 0, 0, 0, "", "*"},
|
||||||
{FORMAT_GIF, " gif", Test_GIF, Load_GIF, Save_GIF, 0, 1, 1, "gif", "gif"},
|
{FORMAT_GIF, " gif", Test_GIF, Load_GIF, Save_GIF, 0, 1, 1, "gif", "gif"},
|
||||||
#ifndef __no_pnglib__
|
#ifndef __no_pnglib__
|
||||||
@ -143,7 +143,7 @@ T_Format File_formats[NB_KNOWN_FORMATS] = {
|
|||||||
{FORMAT_BMP, " bmp", Test_BMP, Load_BMP, Save_BMP, 0, 0, 0, "bmp", "bmp"},
|
{FORMAT_BMP, " bmp", Test_BMP, Load_BMP, Save_BMP, 0, 0, 0, "bmp", "bmp"},
|
||||||
{FORMAT_PCX, " pcx", Test_PCX, Load_PCX, Save_PCX, 0, 0, 0, "pcx", "pcx"},
|
{FORMAT_PCX, " pcx", Test_PCX, Load_PCX, Save_PCX, 0, 0, 0, "pcx", "pcx"},
|
||||||
{FORMAT_PKM, " pkm", Test_PKM, Load_PKM, Save_PKM, 0, 1, 0, "pkm", "pkm"},
|
{FORMAT_PKM, " pkm", Test_PKM, Load_PKM, Save_PKM, 0, 1, 0, "pkm", "pkm"},
|
||||||
{FORMAT_LBM, " lbm", Test_LBM, Load_LBM, Save_LBM, 0, 0, 0, "lbm", "lbm;iff"},
|
{FORMAT_LBM, " lbm", Test_LBM, Load_LBM, Save_LBM, 0, 0, 0, "lbm", "lbm;iff;ilbm"},
|
||||||
{FORMAT_IMG, " img", Test_IMG, Load_IMG, Save_IMG, 0, 0, 0, "img", "img"},
|
{FORMAT_IMG, " img", Test_IMG, Load_IMG, Save_IMG, 0, 0, 0, "img", "img"},
|
||||||
{FORMAT_SCx, " sc?", Test_SCx, Load_SCx, Save_SCx, 0, 0, 0, "sc?", "sci;scq;scf;scn;sco"},
|
{FORMAT_SCx, " sc?", Test_SCx, Load_SCx, Save_SCx, 0, 0, 0, "sc?", "sci;scq;scf;scn;sco"},
|
||||||
{FORMAT_PI1, " pi1", Test_PI1, Load_PI1, Save_PI1, 0, 0, 0, "pi1", "pi1"},
|
{FORMAT_PI1, " pi1", Test_PI1, Load_PI1, Save_PI1, 0, 0, 0, "pi1", "pi1"},
|
||||||
@ -776,11 +776,14 @@ void Load_image(T_IO_Context *context)
|
|||||||
Main_image_height=1;
|
Main_image_height=1;
|
||||||
|
|
||||||
// Color cyling ranges:
|
// Color cyling ranges:
|
||||||
|
for (i=0; i<16; i++)
|
||||||
|
Gradient_array[i].Speed=0;
|
||||||
for (i=0; i<context->Color_cycles; i++)
|
for (i=0; i<context->Color_cycles; i++)
|
||||||
{
|
{
|
||||||
Gradient_array[i].Start=context->Cycle_range[i].Start;
|
Gradient_array[i].Start=context->Cycle_range[i].Start;
|
||||||
Gradient_array[i].End=context->Cycle_range[i].End;
|
Gradient_array[i].End=context->Cycle_range[i].End;
|
||||||
Gradient_array[i].Inverse=context->Cycle_range[i].Inverse;
|
Gradient_array[i].Inverse=context->Cycle_range[i].Inverse;
|
||||||
|
Gradient_array[i].Speed=context->Cycle_range[i].Speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
84
src/main.c
84
src/main.c
@ -86,39 +86,81 @@
|
|||||||
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int test_colorcycling(void* useless)
|
int Color_cycling(__attribute__((unused)) void* useless)
|
||||||
{
|
{
|
||||||
static byte offset[16]; // static forces init at 0
|
byte offset[16];
|
||||||
int i, color;
|
int i, color;
|
||||||
static SDL_Color PaletteSDL[256];
|
static SDL_Color PaletteSDL[256];
|
||||||
|
int changed; // boolean : true if the palette needs a change in this tick.
|
||||||
|
|
||||||
|
long now;
|
||||||
|
long start;
|
||||||
|
|
||||||
while(!Quitting)
|
while(!Quitting)
|
||||||
{
|
{
|
||||||
SDL_Delay(50);
|
start = SDL_GetTicks();
|
||||||
|
memset(offset, 0, sizeof(offset));
|
||||||
|
|
||||||
// Init palette
|
// Init palette
|
||||||
for(color=0;color<256;color++)
|
while (Allow_colorcycling)
|
||||||
{
|
{
|
||||||
PaletteSDL[color].r=Main_palette[color].R;
|
now = SDL_GetTicks();
|
||||||
PaletteSDL[color].g=Main_palette[color].G;
|
changed=0;
|
||||||
PaletteSDL[color].b=Main_palette[color].B;
|
|
||||||
}
|
|
||||||
for (i=0; i<16; i++)
|
|
||||||
{
|
|
||||||
byte len;
|
|
||||||
|
|
||||||
len=Gradient_array[i].End-Gradient_array[i].Start+1;
|
// Check all cycles for a change at this tick
|
||||||
if (len)
|
for (i=0; i<16; i++)
|
||||||
{
|
{
|
||||||
for(color=Gradient_array[i].Start;color<=Gradient_array[i].End;color++)
|
int len;
|
||||||
|
|
||||||
|
len=Gradient_array[i].End-Gradient_array[i].Start+1;
|
||||||
|
if (len>1 && Gradient_array[i].Speed)
|
||||||
{
|
{
|
||||||
PaletteSDL[color].r=Main_palette[Gradient_array[i].Start+((color-Gradient_array[i].Start+offset[i])%len)].R;
|
int new_offset;
|
||||||
PaletteSDL[color].g=Main_palette[Gradient_array[i].Start+((color-Gradient_array[i].Start+offset[i])%len)].G;
|
|
||||||
PaletteSDL[color].b=Main_palette[Gradient_array[i].Start+((color-Gradient_array[i].Start+offset[i])%len)].B;
|
new_offset=(now-start)/(int)(1000.0/(Gradient_array[i].Speed*0.2856)) % len;
|
||||||
|
if (!Gradient_array[i].Inverse)
|
||||||
|
new_offset=len - new_offset;
|
||||||
|
|
||||||
|
if (new_offset!=offset[i])
|
||||||
|
changed=1;
|
||||||
|
offset[i]=new_offset;
|
||||||
}
|
}
|
||||||
offset[i]= (offset[i]+len-1)%len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
// Initialize the palette
|
||||||
|
for(color=0;color<256;color++)
|
||||||
|
{
|
||||||
|
PaletteSDL[color].r=Main_palette[color].R;
|
||||||
|
PaletteSDL[color].g=Main_palette[color].G;
|
||||||
|
PaletteSDL[color].b=Main_palette[color].B;
|
||||||
|
}
|
||||||
|
for (i=0; i<16; i++)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len=Gradient_array[i].End-Gradient_array[i].Start+1;
|
||||||
|
if (len>1 && Gradient_array[i].Speed)
|
||||||
|
{
|
||||||
|
for(color=Gradient_array[i].Start;color<=Gradient_array[i].End;color++)
|
||||||
|
{
|
||||||
|
PaletteSDL[color].r=Main_palette[Gradient_array[i].Start+((color-Gradient_array[i].Start+offset[i])%len)].R;
|
||||||
|
PaletteSDL[color].g=Main_palette[Gradient_array[i].Start+((color-Gradient_array[i].Start+offset[i])%len)].G;
|
||||||
|
PaletteSDL[color].b=Main_palette[Gradient_array[i].Start+((color-Gradient_array[i].Start+offset[i])%len)].B;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, PaletteSDL,0,256);
|
||||||
|
}
|
||||||
|
SDL_Delay(20);
|
||||||
|
}
|
||||||
|
// Restore normal palette
|
||||||
|
Set_palette(Main_palette);
|
||||||
|
while (!Allow_colorcycling)
|
||||||
|
{
|
||||||
|
SDL_Delay(20);
|
||||||
}
|
}
|
||||||
SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, PaletteSDL,0,256);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -863,10 +905,10 @@ int Init_program(int argc,char * argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
// Color cycling test
|
// Color cycling test
|
||||||
{
|
{
|
||||||
SDL_Thread* t = SDL_CreateThread(test_colorcycling, NULL);
|
SDL_Thread* t = SDL_CreateThread(Color_cycling, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -47,6 +47,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
volatile int Allow_colorcycling=1;
|
||||||
|
|
||||||
/// Sets the new screen/window dimensions.
|
/// Sets the new screen/window dimensions.
|
||||||
void Set_mode_SDL(int *width, int *height, int fullscreen)
|
void Set_mode_SDL(int *width, int *height, int fullscreen)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -65,4 +65,6 @@ void Get_SDL_Palette(const SDL_Palette * sdl_palette, T_Palette palette);
|
|||||||
/// size, eg: 3x3 pixels in 1024x768 leaves 1 column on the right, 0 rows on bottom.
|
/// size, eg: 3x3 pixels in 1024x768 leaves 1 column on the right, 0 rows on bottom.
|
||||||
void Clear_border(byte color);
|
void Clear_border(byte color);
|
||||||
|
|
||||||
|
extern volatile int Allow_colorcycling;
|
||||||
|
|
||||||
#endif // SDLSCREEN_H_INCLUDED
|
#endif // SDLSCREEN_H_INCLUDED
|
||||||
|
|||||||
@ -224,6 +224,7 @@ typedef struct
|
|||||||
dword Inverse; ///< Boolean, true if the gradient goes in descending order
|
dword Inverse; ///< Boolean, true if the gradient goes in descending order
|
||||||
dword Mix; ///< Amount of randomness to add to the mix (0-255)
|
dword Mix; ///< Amount of randomness to add to the mix (0-255)
|
||||||
dword Technique;///< Gradient technique: 0 (no pattern) 1 (dithering), or 2 (big dithering)
|
dword Technique;///< Gradient technique: 0 (no pattern) 1 (dithering), or 2 (big dithering)
|
||||||
|
byte Speed; ///< Speed of cycling. 0 for disabled, 1-64 otherwise.
|
||||||
} T_Gradient_array;
|
} T_Gradient_array;
|
||||||
|
|
||||||
/// Data for one setting of shade. Warning, this one is saved/loaded as binary.
|
/// Data for one setting of shade. Warning, this one is saved/loaded as binary.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user