Fix issue 57: Missing refresh in the cross points for the 4-point splines.

Also fixed the display of the bottom-right corner of the spline itself.
Grad rectangle: The vector line is now drawn as XOR: dragging it no longer erases the screen.
SFont.c: Only removed TAB characters in source.


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@418 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2008-12-26 19:38:21 +00:00
parent c55c27bd85
commit df33261b59
3 changed files with 51 additions and 54 deletions

64
SFont.c
View File

@ -74,7 +74,7 @@ SFont_Font* SFont_InitFont(SDL_Surface* Surface)
Uint32 pink;
if (Surface == NULL)
return NULL;
return NULL;
Font = (SFont_Font *) malloc(sizeof(SFont_Font));
Font->Surface = Surface;
@ -83,13 +83,13 @@ SFont_Font* SFont_InitFont(SDL_Surface* Surface)
pink = SDL_MapRGB(Surface->format, 255, 0, 255);
while (x < Surface->w) {
if (GetPixel(Surface, x, 0) == pink) {
Font->CharPos[i++]=x;
while((x < Surface->w) && (GetPixel(Surface, x, 0)== pink))
x++;
Font->CharPos[i++]=x;
}
x++;
if (GetPixel(Surface, x, 0) == pink) {
Font->CharPos[i++]=x;
while((x < Surface->w) && (GetPixel(Surface, x, 0)== pink))
x++;
Font->CharPos[i++]=x;
}
x++;
}
Font->MaxPos = x-1;
@ -107,14 +107,14 @@ void SFont_FreeFont(SFont_Font* FontInfo)
}
void SFont_Write(SDL_Surface *Surface, const SFont_Font *Font,
int x, int y, const char *text)
int x, int y, const char *text)
{
const char* c;
int charoffset;
SDL_Rect srcrect, dstrect;
if(text == NULL)
return;
return;
// these values won't change in the loop
srcrect.y = 1;
@ -122,23 +122,23 @@ void SFont_Write(SDL_Surface *Surface, const SFont_Font *Font,
srcrect.h = dstrect.h = Font->Surface->h - 1;
for(c = text; *c != '\0' && x <= Surface->w ; c++) {
charoffset = ((int) (*c - 33)) * 2 + 1;
// skip spaces and nonprintable characters
if (*c == ' ' || charoffset < 0 || charoffset > Font->MaxPos) {
x += Font->CharPos[2]-Font->CharPos[1];
continue;
}
charoffset = ((int) (*c - 33)) * 2 + 1;
// skip spaces and nonprintable characters
if (*c == ' ' || charoffset < 0 || charoffset > Font->MaxPos) {
x += Font->CharPos[2]-Font->CharPos[1];
continue;
}
srcrect.w = dstrect.w =
(Font->CharPos[charoffset+2] + Font->CharPos[charoffset+1])/2 -
(Font->CharPos[charoffset] + Font->CharPos[charoffset-1])/2;
srcrect.x = (Font->CharPos[charoffset]+Font->CharPos[charoffset-1])/2;
dstrect.x = x - (float)(Font->CharPos[charoffset]
- Font->CharPos[charoffset-1])/2;
srcrect.w = dstrect.w =
(Font->CharPos[charoffset+2] + Font->CharPos[charoffset+1])/2 -
(Font->CharPos[charoffset] + Font->CharPos[charoffset-1])/2;
srcrect.x = (Font->CharPos[charoffset]+Font->CharPos[charoffset-1])/2;
dstrect.x = x - (float)(Font->CharPos[charoffset]
- Font->CharPos[charoffset-1])/2;
SDL_BlitSurface(Font->Surface, &srcrect, Surface, &dstrect);
SDL_BlitSurface(Font->Surface, &srcrect, Surface, &dstrect);
x += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
x += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
}
}
@ -149,17 +149,17 @@ int SFont_TextWidth(const SFont_Font *Font, const char *text)
int width = 0;
if(text == NULL)
return 0;
return 0;
for(c = text; *c != '\0'; c++) {
charoffset = ((int) *c - 33) * 2 + 1;
// skip spaces and nonprintable characters
charoffset = ((int) *c - 33) * 2 + 1;
// skip spaces and nonprintable characters
if (*c == ' ' || charoffset < 0 || charoffset > Font->MaxPos) {
width += Font->CharPos[2]-Font->CharPos[1];
continue;
}
continue;
}
width += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
width += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
}
return width;
@ -171,9 +171,9 @@ int SFont_TextHeight(const SFont_Font* Font)
}
void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font *Font,
int y, const char *text)
int y, const char *text)
{
SFont_Write(Surface, Font, Surface->w/2 - SFont_TextWidth(Font, text)/2,
y, text);
y, text);
}

View File

@ -1427,7 +1427,7 @@ void Tracer_courbe_General(short X1, short Y1,
Y = Min(Min(Y1,Y2),Min(Y3,Y4));
Old_X = Max(Max(X1,X2),Max(X3,X4)) - X;
Old_Y = Max(Max(Y1,Y2),Max(Y3,Y4)) - Y;
Mettre_Ecran_A_Jour(X,Y,Old_X,Old_Y);
Mettre_Ecran_A_Jour(X,Y,Old_X+1,Old_Y+1);
}
// -- Tracer une courbe de Bézier définitivement --

View File

@ -1534,17 +1534,21 @@ void Courbe_Tracer_croix(short Pos_X, short Pos_Y)
else
Fin_Y=3+(Limite_visible_Bas-Pos_Y);
for (i=Debut_X; i<=Fin_X; i++)
if (Debut_X<=Fin_X && Debut_Y<=Fin_Y)
{
Temp=Pos_X+i-3;
Pixel_Preview(Temp,Pos_Y,~Lit_pixel(Temp -Principal_Decalage_X,
Pos_Y-Principal_Decalage_Y));
}
for (i=Debut_Y; i<=Fin_Y; i++)
{
Temp=Pos_Y+i-3;
Pixel_Preview(Pos_X,Temp,~Lit_pixel(Pos_X-Principal_Decalage_X,
Temp -Principal_Decalage_Y));
for (i=Debut_X; i<=Fin_X; i++)
{
Temp=Pos_X+i-3;
Pixel_Preview(Temp,Pos_Y,~Lit_pixel(Temp -Principal_Decalage_X,
Pos_Y-Principal_Decalage_Y));
}
for (i=Debut_Y; i<=Fin_Y; i++)
{
Temp=Pos_Y+i-3;
Pixel_Preview(Pos_X,Temp,~Lit_pixel(Pos_X-Principal_Decalage_X,
Temp -Principal_Decalage_Y));
}
Mettre_Ecran_A_Jour(Pos_X+Debut_X-3,Pos_Y+Debut_Y-3,Fin_X-Debut_X+1,Fin_Y-Debut_Y+1);
}
}
@ -4391,15 +4395,8 @@ void Rectangle_Degrade_12_9(void)
Aff_coords_rel_ou_abs(Debut_X,Debut_Y);
Effacer_ligne_Preview(Debut_X,Debut_Y,Fin_X,Fin_Y);
if (Mouse_K==A_GAUCHE)
{
Tracer_ligne_Preview (Debut_X,Debut_Y,Pinceau_X,Pinceau_Y,Fore_color);
}
else
{
Tracer_ligne_Preview (Debut_X,Debut_Y,Pinceau_X,Pinceau_Y,Back_color);
}
Tracer_ligne_Preview_xor(Debut_X,Debut_Y,Fin_X,Fin_Y,0);
Tracer_ligne_Preview_xor(Debut_X,Debut_Y,Pinceau_X,Pinceau_Y,0);
Operation_PUSH(Debut_X);
Operation_PUSH(Debut_Y);