(Linux and Windows) Fix missing refresh that happened when zoom was on and you were drawing in the left part of screen.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@411 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
c1af3faac2
commit
7247b83007
252
graph.c
252
graph.c
@ -47,25 +47,25 @@
|
|||||||
// Tient compte du décalage X et Y et du zoom, et fait tous les controles nécessaires
|
// Tient compte du décalage X et Y et du zoom, et fait tous les controles nécessaires
|
||||||
void Mettre_Ecran_A_Jour(short X, short Y, short Largeur, short Hauteur)
|
void Mettre_Ecran_A_Jour(short X, short Y, short Largeur, short Hauteur)
|
||||||
{
|
{
|
||||||
short L_effectif, H_effectif;
|
short L_effectif, H_effectif;
|
||||||
short X_effectif;
|
short X_effectif;
|
||||||
short Y_effectif;
|
short Y_effectif;
|
||||||
short Diff;
|
short Diff;
|
||||||
|
|
||||||
// Première étape, si L ou H est négatif, on doit remettre la zone à l'endroit
|
// Première étape, si L ou H est négatif, on doit remettre la zone à l'endroit
|
||||||
if (Largeur < 0)
|
if (Largeur < 0)
|
||||||
{
|
{
|
||||||
X += Largeur;
|
X += Largeur;
|
||||||
Largeur = - Largeur;
|
Largeur = - Largeur;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hauteur < 0)
|
if (Hauteur < 0)
|
||||||
{
|
{
|
||||||
Y += Hauteur;
|
Y += Hauteur;
|
||||||
Hauteur = - Hauteur;
|
Hauteur = - Hauteur;
|
||||||
}
|
}
|
||||||
|
|
||||||
// D'abord on met à jour dans la zone écran normale
|
// D'abord on met à jour dans la zone écran normale
|
||||||
Diff = X-Principal_Decalage_X;
|
Diff = X-Principal_Decalage_X;
|
||||||
if (Diff<0)
|
if (Diff<0)
|
||||||
{
|
{
|
||||||
@ -89,67 +89,81 @@ void Mettre_Ecran_A_Jour(short X, short Y, short Largeur, short Hauteur)
|
|||||||
Y_effectif = Diff;
|
Y_effectif = Diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalement il ne faudrait pas updater au delà du split quand on est en mode loupe,
|
// Normalement il ne faudrait pas updater au delà du split quand on est en mode loupe,
|
||||||
// mais personne ne devrait demander d'update en dehors de cette limite, même le fill est contraint
|
// mais personne ne devrait demander d'update en dehors de cette limite, même le fill est contraint
|
||||||
// a rester dans la zone visible de l'image
|
// a rester dans la zone visible de l'image
|
||||||
// ...Sauf l'affichage de brosse en preview - yr
|
// ...Sauf l'affichage de brosse en preview - yr
|
||||||
if(Loupe_Mode && X_effectif + L_effectif > Principal_Split)
|
if(Loupe_Mode && X_effectif + L_effectif > Principal_Split)
|
||||||
L_effectif = Principal_Split - X_effectif;
|
L_effectif = Principal_Split - X_effectif;
|
||||||
else if(X_effectif + L_effectif > Largeur_ecran)
|
else if(X_effectif + L_effectif > Largeur_ecran)
|
||||||
L_effectif = Largeur_ecran - X_effectif;
|
L_effectif = Largeur_ecran - X_effectif;
|
||||||
|
|
||||||
if(Y_effectif + H_effectif > Menu_Ordonnee)
|
if(Y_effectif + H_effectif > Menu_Ordonnee)
|
||||||
H_effectif = Menu_Ordonnee - Y_effectif;
|
H_effectif = Menu_Ordonnee - Y_effectif;
|
||||||
/*
|
/*
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
r.x=X_effectif;
|
r.x=X_effectif;
|
||||||
r.y=Y_effectif;
|
r.y=Y_effectif;
|
||||||
r.h=H_effectif;
|
r.h=H_effectif;
|
||||||
r.w=L_effectif;
|
r.w=L_effectif;
|
||||||
SDL_FillRect(Ecran_SDL,&r,3);
|
SDL_FillRect(Ecran_SDL,&r,3);
|
||||||
*/
|
*/
|
||||||
UpdateRect(X_effectif,Y_effectif,L_effectif,H_effectif);
|
UpdateRect(X_effectif,Y_effectif,L_effectif,H_effectif);
|
||||||
|
|
||||||
// Et ensuite dans la partie zoomée
|
// Et ensuite dans la partie zoomée
|
||||||
if(Loupe_Mode)
|
if(Loupe_Mode)
|
||||||
{
|
{
|
||||||
// Clipping en X
|
// Clipping en X
|
||||||
X_effectif = (X-Loupe_Decalage_X)*Loupe_Facteur;
|
X_effectif = (X-Loupe_Decalage_X)*Loupe_Facteur;
|
||||||
Y_effectif = (Y-Loupe_Decalage_Y)*Loupe_Facteur;
|
Y_effectif = (Y-Loupe_Decalage_Y)*Loupe_Facteur;
|
||||||
L_effectif = Largeur * Loupe_Facteur;
|
L_effectif = Largeur * Loupe_Facteur;
|
||||||
H_effectif = Hauteur * Loupe_Facteur;
|
H_effectif = Hauteur * Loupe_Facteur;
|
||||||
|
|
||||||
|
if (X_effectif < 0)
|
||||||
|
{
|
||||||
|
L_effectif+=X_effectif;
|
||||||
|
if (L_effectif<0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (X_effectif < 0)
|
|
||||||
{
|
|
||||||
L_effectif+=X_effectif;
|
|
||||||
X_effectif = Principal_Split + LARGEUR_BARRE_SPLIT*Menu_Facteur_X;
|
X_effectif = Principal_Split + LARGEUR_BARRE_SPLIT*Menu_Facteur_X;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
X_effectif += Principal_Split + LARGEUR_BARRE_SPLIT*Menu_Facteur_X;
|
X_effectif += Principal_Split + LARGEUR_BARRE_SPLIT*Menu_Facteur_X;
|
||||||
Diff = X_effectif+L_effectif-Largeur_ecran;
|
Diff = X_effectif+L_effectif-Largeur_ecran;
|
||||||
if (Diff>0)
|
if (Diff>0)
|
||||||
L_effectif -=Diff;
|
{
|
||||||
|
L_effectif -=Diff;
|
||||||
|
if (L_effectif<0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Clipping en Y
|
// Clipping en Y
|
||||||
if (Y_effectif < 0)
|
if (Y_effectif < 0)
|
||||||
{
|
{
|
||||||
H_effectif+=Y_effectif;
|
H_effectif+=Y_effectif;
|
||||||
|
if (H_effectif<0)
|
||||||
|
return;
|
||||||
Y_effectif = 0;
|
Y_effectif = 0;
|
||||||
}
|
}
|
||||||
Diff = Y_effectif+H_effectif-Menu_Ordonnee;
|
Diff = Y_effectif+H_effectif-Menu_Ordonnee;
|
||||||
if (Diff>0)
|
if (Diff>0)
|
||||||
H_effectif -=Diff;
|
{
|
||||||
|
H_effectif -=Diff;
|
||||||
|
if (H_effectif<0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Très utile pour le debug :)
|
// Très utile pour le debug :)
|
||||||
/*SDL_Rect r;
|
/*SDL_Rect r;
|
||||||
r.x=X_effectif;
|
r.x=X_effectif;
|
||||||
r.y=Y_effectif;
|
r.y=Y_effectif;
|
||||||
r.h=H_effectif;
|
r.h=H_effectif;
|
||||||
r.w=L_effectif;
|
r.w=L_effectif;
|
||||||
SDL_FillRect(Ecran_SDL,&r,3);*/
|
SDL_FillRect(Ecran_SDL,&r,3);*/
|
||||||
|
|
||||||
UpdateRect(X_effectif,Y_effectif,L_effectif,H_effectif);
|
UpdateRect(X_effectif,Y_effectif,L_effectif,H_effectif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -731,14 +745,14 @@ void Remplir(byte Couleur_de_remplissage)
|
|||||||
// Il va maintenant falloir qu'on "turn" ce gros caca "into" un truc qui
|
// Il va maintenant falloir qu'on "turn" ce gros caca "into" un truc qui
|
||||||
// ressemble un peu plus à ce à quoi l'utilisateur peut s'attendre.
|
// ressemble un peu plus à ce à quoi l'utilisateur peut s'attendre.
|
||||||
if (Limite_atteinte_Haut>Limite_Haut)
|
if (Limite_atteinte_Haut>Limite_Haut)
|
||||||
Copier_une_partie_d_image_dans_une_autre(Ecran_backup, // Source
|
Copier_une_partie_d_image_dans_une_autre(Ecran_backup, // Source
|
||||||
Limite_Gauche,Limite_Haut, // Pos X et Y dans source
|
Limite_Gauche,Limite_Haut, // Pos X et Y dans source
|
||||||
(Limite_Droite-Limite_Gauche)+1, // Largeur copie
|
(Limite_Droite-Limite_Gauche)+1, // Largeur copie
|
||||||
Limite_atteinte_Haut-Limite_Haut, // Hauteur copie
|
Limite_atteinte_Haut-Limite_Haut,// Hauteur copie
|
||||||
Principal_Largeur_image, // Largeur de la source
|
Principal_Largeur_image, // Largeur de la source
|
||||||
Principal_Ecran, // Destination
|
Principal_Ecran, // Destination
|
||||||
Limite_Gauche,Limite_Haut, // Pos X et Y destination
|
Limite_Gauche,Limite_Haut, // Pos X et Y destination
|
||||||
Principal_Largeur_image); // Largeur destination
|
Principal_Largeur_image); // Largeur destination
|
||||||
if (Limite_atteinte_Bas<Limite_Bas)
|
if (Limite_atteinte_Bas<Limite_Bas)
|
||||||
Copier_une_partie_d_image_dans_une_autre(Ecran_backup,
|
Copier_une_partie_d_image_dans_une_autre(Ecran_backup,
|
||||||
Limite_Gauche,Limite_atteinte_Bas+1,
|
Limite_Gauche,Limite_atteinte_Bas+1,
|
||||||
@ -1131,9 +1145,9 @@ void Tracer_ellipse_pleine(short Centre_X,short Centre_Y,short Rayon_horizontal,
|
|||||||
|
|
||||||
void Rectifier_coordonnees_a_45_degres(short AX, short AY, short* BX, short* BY)
|
void Rectifier_coordonnees_a_45_degres(short AX, short AY, short* BX, short* BY)
|
||||||
// Modifie BX et BY pour que la ligne AXAY - BXBY soit
|
// Modifie BX et BY pour que la ligne AXAY - BXBY soit
|
||||||
// - une droite horizontale
|
// - une droite horizontale
|
||||||
// - une droite verticale
|
// - une droite verticale
|
||||||
// - une droite avec une pente de 45 degrés
|
// - une droite avec une pente de 45 degrés
|
||||||
{
|
{
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
float tan;
|
float tan;
|
||||||
@ -1147,27 +1161,27 @@ void Rectifier_coordonnees_a_45_degres(short AX, short AY, short* BX, short* BY)
|
|||||||
|
|
||||||
if (tan <= 0.4142 && tan >= -0.4142)
|
if (tan <= 0.4142 && tan >= -0.4142)
|
||||||
{
|
{
|
||||||
// Cas 1 : Lock Y
|
// Cas 1 : Lock Y
|
||||||
*BY = AY;
|
*BY = AY;
|
||||||
}
|
}
|
||||||
else if ( tan > 0.4142 && tan < 2.4142)
|
else if ( tan > 0.4142 && tan < 2.4142)
|
||||||
{
|
{
|
||||||
// Cas 2 : dy=dx
|
// Cas 2 : dy=dx
|
||||||
int nBY = AY - dx;
|
int nBY = AY - dx;
|
||||||
*BY = (*BY + nBY)/2;
|
*BY = (*BY + nBY)/2;
|
||||||
*BX = AX + AY - *BY;
|
*BX = AX + AY - *BY;
|
||||||
}
|
}
|
||||||
else if (tan < -0.4142 && tan >= -2.4142)
|
else if (tan < -0.4142 && tan >= -2.4142)
|
||||||
{
|
{
|
||||||
// Cas 8 : dy = -dx
|
// Cas 8 : dy = -dx
|
||||||
int nBY = AY + dx;
|
int nBY = AY + dx;
|
||||||
*BY = (*BY + nBY)/2;
|
*BY = (*BY + nBY)/2;
|
||||||
*BX = AX - AY + *BY;
|
*BX = AX - AY + *BY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Cas 3 : Lock X
|
// Cas 3 : Lock X
|
||||||
*BX = AX;
|
*BX = AX;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1846,57 +1860,57 @@ void Tracer_rectangle_degrade(short RAX,short RAY,short RBX,short RBY,short VAX,
|
|||||||
// On commence par s'assurer que le rectangle est à l'endroit
|
// On commence par s'assurer que le rectangle est à l'endroit
|
||||||
if(RBX < RAX)
|
if(RBX < RAX)
|
||||||
{
|
{
|
||||||
Pos_X = RBX;
|
Pos_X = RBX;
|
||||||
RBX = RAX;
|
RBX = RAX;
|
||||||
RAX = Pos_X;
|
RAX = Pos_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(RBY < RAY)
|
if(RBY < RAY)
|
||||||
{
|
{
|
||||||
Pos_Y = RBY;
|
Pos_Y = RBY;
|
||||||
RBY = RAY;
|
RBY = RAY;
|
||||||
RAY = Pos_Y;
|
RAY = Pos_Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Correction des bornes d'après les limites
|
// Correction des bornes d'après les limites
|
||||||
if (RAY<Limite_Haut)
|
if (RAY<Limite_Haut)
|
||||||
RAY=Limite_Haut;
|
RAY=Limite_Haut;
|
||||||
if (RBY>Limite_Bas)
|
if (RBY>Limite_Bas)
|
||||||
RBY=Limite_Bas;
|
RBY=Limite_Bas;
|
||||||
if (RAX<Limite_Gauche)
|
if (RAX<Limite_Gauche)
|
||||||
RAX=Limite_Gauche;
|
RAX=Limite_Gauche;
|
||||||
if (RBX>Limite_Droite)
|
if (RBX>Limite_Droite)
|
||||||
RBX=Limite_Droite;
|
RBX=Limite_Droite;
|
||||||
|
|
||||||
if(VBX == VAX)
|
if(VBX == VAX)
|
||||||
{
|
{
|
||||||
// Le vecteur est vertical, donc on évite la partie en dessous qui foirerait avec une division par 0...
|
// Le vecteur est vertical, donc on évite la partie en dessous qui foirerait avec une division par 0...
|
||||||
if (VBY == VAY) return; // L'utilisateur fait n'importe quoi
|
if (VBY == VAY) return; // L'utilisateur fait n'importe quoi
|
||||||
Degrade_Intervalle_total = abs(VBY - VAY);
|
Degrade_Intervalle_total = abs(VBY - VAY);
|
||||||
for(Pos_Y=RAY;Pos_Y<=RBY;Pos_Y++)
|
for(Pos_Y=RAY;Pos_Y<=RBY;Pos_Y++)
|
||||||
for(Pos_X=RAX;Pos_X<=RBX;Pos_X++)
|
for(Pos_X=RAX;Pos_X<=RBX;Pos_X++)
|
||||||
Traiter_degrade(abs(VBY - Pos_Y),Pos_X,Pos_Y);
|
Traiter_degrade(abs(VBY - Pos_Y),Pos_X,Pos_Y);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float a;
|
float a;
|
||||||
float b;
|
float b;
|
||||||
float Distance_X, Distance_Y;
|
float Distance_X, Distance_Y;
|
||||||
|
|
||||||
Degrade_Intervalle_total = sqrt(pow(VBY - VAY,2)+pow(VBX - VAX,2));
|
Degrade_Intervalle_total = sqrt(pow(VBY - VAY,2)+pow(VBX - VAX,2));
|
||||||
a = (float)(VBY - VAY)/(float)(VBX - VAX);
|
a = (float)(VBY - VAY)/(float)(VBX - VAX);
|
||||||
b = VAY - a*VAX;
|
b = VAY - a*VAX;
|
||||||
|
|
||||||
for (Pos_Y=RAY;Pos_Y<=RBY;Pos_Y++)
|
for (Pos_Y=RAY;Pos_Y<=RBY;Pos_Y++)
|
||||||
for (Pos_X = RAX;Pos_X<=RBX;Pos_X++)
|
for (Pos_X = RAX;Pos_X<=RBX;Pos_X++)
|
||||||
{
|
{
|
||||||
// On calcule ou on en est dans le dégradé
|
// On calcule ou on en est dans le dégradé
|
||||||
Distance_X = pow((Pos_Y - VAY),2)+pow((Pos_X - VAX),2);
|
Distance_X = pow((Pos_Y - VAY),2)+pow((Pos_X - VAX),2);
|
||||||
Distance_Y = pow((-a * Pos_X + Pos_Y - b),2)/(a*a+1);
|
Distance_Y = pow((-a * Pos_X + Pos_Y - b),2)/(a*a+1);
|
||||||
|
|
||||||
Traiter_degrade((int)sqrt(Distance_X - Distance_Y),Pos_X,Pos_Y);
|
Traiter_degrade((int)sqrt(Distance_X - Distance_Y),Pos_X,Pos_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mettre_Ecran_A_Jour(RAX,RAY,RBX,RBY);
|
Mettre_Ecran_A_Jour(RAX,RAY,RBX,RBY);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user