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:
Adrien Destugues
2008-10-21 13:56:28 +00:00
parent 31c278813e
commit 221b7cae00
2 changed files with 11 additions and 12 deletions

13
graph.c
View File

@@ -4470,35 +4470,36 @@ void Rectifier_coordonnees_a_45_degres(short AX, short AY, short* BX, short* BY)
{
int dx, dy;
DEBUG("ax",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
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)
{
// Cas 1 : Lock Y
*BY = AY;
DEBUG("horiz",dx);
}
else if ( tan > 0.4142 && tan < 2.4142)
{
// 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)
{
// Cas 8 : dy = -dx
DEBUG("PLiP",dx);
int nBY = AY + dx;
*BY = (*BY + nBY)/2;
*BX = AX - AY + *BY;
}
else
{
// Cas 3 : Lock X
*BX = AX;
DEBUG("vert",dx);
}
return;