ok, fixed line drawing. The error in previous commit was my fault, after all :)
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@295 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
31c278813e
commit
221b7cae00
13
graph.c
13
graph.c
@ -4470,35 +4470,36 @@ void Rectifier_coordonnees_a_45_degres(short AX, short AY, short* BX, short* BY)
|
|||||||
{
|
{
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
|
|
||||||
DEBUG("ax",AX);
|
|
||||||
dx = (*BX)-AX;
|
dx = (*BX)-AX;
|
||||||
dy = AY- *BY; // On prend l'opposée car à l'écran les Y sont positifs en bas, et en maths, positifs en haut
|
dy = AY- *BY; // On prend l'opposée car à l'écran les Y sont positifs en bas, et en maths, positifs en haut
|
||||||
|
|
||||||
if (dx==0) return; // On est en lockx et de toutes façons le X n'a pas bougé, on sort tout de suite pour éviter une méchante division par 0
|
if (dx==0) return; // On est en lockx et de toutes façons le X n'a pas bougé, on sort tout de suite pour éviter une méchante division par 0
|
||||||
|
|
||||||
float tan = dy/dx;
|
float tan = (float)dy/(float)dx;
|
||||||
|
|
||||||
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;
|
||||||
DEBUG("horiz",dx);
|
|
||||||
}
|
}
|
||||||
else if ( tan > 0.4142 && tan < 2.4142)
|
else if ( tan > 0.4142 && tan < 2.4142)
|
||||||
{
|
{
|
||||||
// Cas 2 : dy=dx
|
// Cas 2 : dy=dx
|
||||||
DEBUG("PLOP",dx);
|
int nBY = AY - dx;
|
||||||
|
*BY = (*BY + nBY)/2;
|
||||||
|
*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
|
||||||
DEBUG("PLiP",dx);
|
int nBY = AY + dx;
|
||||||
|
*BY = (*BY + nBY)/2;
|
||||||
|
*BX = AX - AY + *BY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Cas 3 : Lock X
|
// Cas 3 : Lock X
|
||||||
*BX = AX;
|
*BX = AX;
|
||||||
DEBUG("vert",dx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
10
operatio.c
10
operatio.c
@ -448,16 +448,14 @@ void Ligne_12_5(void)
|
|||||||
Operation_POP(&Fin_Y);
|
Operation_POP(&Fin_Y);
|
||||||
Operation_POP(&Fin_X);
|
Operation_POP(&Fin_X);
|
||||||
|
|
||||||
|
|
||||||
DEBUG("px ",Pinceau_X);
|
|
||||||
if ((Pinceau_X!=Fin_X) || (Pinceau_Y!=Fin_Y))
|
if ((Pinceau_X!=Fin_X) || (Pinceau_Y!=Fin_Y))
|
||||||
{
|
{
|
||||||
// On corrige les coordonnées de la ligne si la touche shift est appuyée...
|
|
||||||
if(SDL_GetModState() & KMOD_SHIFT)
|
|
||||||
Rectifier_coordonnees_a_45_degres(Debut_X,Debut_Y,&Pinceau_X,&Pinceau_Y);
|
|
||||||
Effacer_curseur();
|
Effacer_curseur();
|
||||||
Operation_POP(&Debut_Y);
|
Operation_POP(&Debut_Y);
|
||||||
Operation_POP(&Debut_X);
|
Operation_POP(&Debut_X);
|
||||||
|
// On corrige les coordonnées de la ligne si la touche shift est appuyée...
|
||||||
|
if(SDL_GetModState() & KMOD_SHIFT)
|
||||||
|
Rectifier_coordonnees_a_45_degres(Debut_X,Debut_Y,&Pinceau_X,&Pinceau_Y);
|
||||||
|
|
||||||
Aff_coords_rel_ou_abs(Debut_X,Debut_Y);
|
Aff_coords_rel_ou_abs(Debut_X,Debut_Y);
|
||||||
|
|
||||||
@ -513,7 +511,7 @@ void Ligne_0_5(void)
|
|||||||
Pixel_figure_Preview (Debut_X,Debut_Y,Lit_pixel_dans_ecran_courant(Debut_X,Debut_Y));
|
Pixel_figure_Preview (Debut_X,Debut_Y,Lit_pixel_dans_ecran_courant(Debut_X,Debut_Y));
|
||||||
Effacer_ligne_Preview (Debut_X,Debut_Y,Fin_X,Fin_Y);
|
Effacer_ligne_Preview (Debut_X,Debut_Y,Fin_X,Fin_Y);
|
||||||
Afficher_pinceau (Debut_X,Debut_Y,Couleur,0);
|
Afficher_pinceau (Debut_X,Debut_Y,Couleur,0);
|
||||||
Tracer_ligne_Definitif(Debut_X,Debut_Y,Pinceau_X,Pinceau_Y,Couleur);
|
Tracer_ligne_Definitif(Debut_X,Debut_Y,Fin_X,Fin_Y,Couleur);
|
||||||
|
|
||||||
if ( (Config.Coords_rel) && (Menu_visible) )
|
if ( (Config.Coords_rel) && (Menu_visible) )
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user