fix: correction de la fonction trianglefill

This commit is contained in:
Nicolas Hordé 2018-08-22 20:43:21 +02:00
parent 36185af660
commit 647050d22e
2 changed files with 8 additions and 16 deletions

View File

@ -80,12 +80,14 @@ void trianglefilled(vertex2d *AA, vertex2d *BB, vertex2d *CC, u8 color) {
A=AA;
B=BB;
C=CC;
if (A->y > B->y)
swapvertex(A,B);
if (B->y > C->y)
swapvertex(B,C);
if (A->y > C->y)
swapvertex(A,C);
while(A->y > B->y || B->y > C->y || A->y == C->y) {
if (A->y > B->y)
swapvertex(A,B);
if (B->y > C->y)
swapvertex(B,C);
if (A->y > C->y)
swapvertex(A,C);
}
if(A->y == C->y) { //meme ligne
a = b = A->x;
if(B->x < a) a = B->x;

View File

@ -94,14 +94,6 @@ void test2d() {
setvmode(0x84);
fill(0x00);
struct vertex2d a,b,c;
a.x=230;
a.y=157;
b.x=375;
b.y=29;
c.x=278;
c.y=276;
trianglefilled(&a,&b,&c,random(0, 16));
triangle(&a,&b,&c,2);
randomize();
for(int i=0;i<3200;i++)
{
@ -113,8 +105,6 @@ void test2d() {
c.y=random(0, 600);
trianglefilled(&a,&b,&c,random(0, 16));
triangle(&a,&b,&c,2);
printf("\r\nA:%d,%d B:%d,%d C:%d,%d",a.x,a.y,b.x,b.y,c.x,c.y);
waitascii();
}
}