1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
Procedure TGView.SetTrianglePlein(x1,y1,x2,y2,x3,y3,c:longint);
//----------------------------------------------------------------------- <>
var
i,cpos,dum: longint;
// ligne AB
ABdeltax, ABdeltay, ABnumpixels,
ABd, ABdinc1, ABdinc2,
ABx, ABxinc1, ABxinc2,
ABy, AByinc1, AByinc2,
// ligne AC
ACdeltax, ACdeltay, ACnumpixels,
ACd, ACdinc1, ACdinc2,
ACx, ACxinc1, ACxinc2,
ACy, ACyinc1, ACyinc2,
// Ligne CB
CBdeltax, CBdeltay, CBnumpixels,
CBd, CBdinc1, CBdinc2,
CBx, CBxinc1, CBxinc2,
CBy, CByinc1, CByinc2 : integer;
//
p:pointer;
W,H:longword;
begin
W:=self.p_Buffer.Width; H:=self.p_Buffer.Height;
p:=self.p_PTRBuffer;
// TROUVER L'ORDRE DES POINTS PAR Y CROISSANT
//////////////////////////////////////////////////////////////
if (y1>y2) then begin // 1 est tout le temps A
dum:=y2; Y2:=Y1; Y1:=dum;
dum:=x2; x2:=x1; x1:=dum;
end;
if (y1>y3) then begin // 2 est tout le temps B
dum:=y3; Y3:=Y1; Y1:=dum;
dum:=x3; x3:=x1; x1:=dum;
end;
if (y2<y3) then begin // 3 est tout le temp C
dum:=y3; Y3:=Y2; Y2:=dum;
dum:=x3; x3:=x2; x2:=dum;
end;
//debug
Self.SetText(x1,self.p_Buffer.Height-Y1,$00FFFFFF,'A:'+IntToStr(x1)+','+IntToStr(y1));
Self.SetText(x2,self.p_Buffer.Height-y2,$00FFFFFF,'B:'+IntToStr(x2)+','+IntToStr(y2));
Self.SetText(x3,self.p_Buffer.Height-y3,$00FFFFFF,'C:'+IntToStr(x3)+','+IntToStr(y3));
ABdeltax := abs(x2 - x1);
ABdeltay := abs(y2 - y1);
if ABdeltax >= ABdeltay then
begin
ABnumpixels := ABdeltax + 1;
ABd := (ABdeltay SHl 1) - ABdeltax;
ABdinc1 := ABdeltay Shl 1;
ABdinc2 := (ABdeltay - ABdeltax) shl 1;
ABxinc1 := 1;
ABxinc2 := 1;
AByinc1 := 0;
AByinc2 := 1;
end
else
begin
ABnumpixels := ABdeltay + 1;
ABd := (ABdeltax Shl 1) - ABdeltay;
ABdinc1 := ABdeltax Shl 1;
ABdinc2 := (ABdeltax - ABdeltay) shl 1;
ABxinc1 := 0;
ABxinc2 := 1;
AByinc1 := 1;
AByinc2 := 1;
end;
if x1 > x2 then
begin
ABxinc1 := - ABxinc1;
ABxinc2 := - ABxinc2;
end;
if y1 > y2 then
begin
AByinc1 := - AByinc1;
AByinc2 := - AByinc2;
end;
ABx := x1;
ABy := y1;
///////////////////////////////////////////////////////////
// PRECALC AC
ACdeltax := abs(x3 - x1);
ACdeltay := abs(y3 - y1);
if ACdeltax >= ACdeltay then
begin
ACnumpixels := ACdeltax + 1;
ACd := (ACdeltay SHl 1) - ACdeltax;
ACdinc1 := ACdeltay Shl 1;
ACdinc2 := (ACdeltay - ACdeltax) shl 1;
ACxinc1 := 1;
ACxinc2 := 1;
ACyinc1 := 0;
ACyinc2 := 1;
end
else
begin
ACnumpixels := ACdeltay + 1;
ACd := (ACdeltax Shl 1) - ACdeltay;
ACdinc1 := ACdeltax Shl 1;
ACdinc2 := (ACdeltax - ACdeltay) shl 1;
ACxinc1 := 0;
ACxinc2 := 1;
ACyinc1 := 1;
ACyinc2 := 1;
end;
if x1 > x3 then
begin
ACxinc1 := - ACxinc1;
ACxinc2 := - ACxinc2;
end;
if y1 > y3 then
begin
ACyinc1 := - ACyinc1;
ACyinc2 := - ACyinc2;
end;
ACx := x1;
ACy := y1;
///////////////////////////////////////////////////////////
// PRECALC CB
CBdeltax := abs(x3 - x2);
CBdeltay := abs(y3 - y2);
if CBdeltax >= CBdeltay then
begin
CBnumpixels := CBdeltax + 1;
CBd := (CBdeltay SHl 1) - CBdeltax;
CBdinc1 := CBdeltay Shl 1;
CBdinc2 := (CBdeltay - CBdeltax) shl 1;
CBxinc1 := 1;
CBxinc2 := 1;
CByinc1 := 0;
CByinc2 := 1;
end
else
begin
CBnumpixels := CBdeltay + 1;
CBd := (CBdeltax Shl 1) - CBdeltay;
CBdinc1 := CBdeltax Shl 1;
CBdinc2 := (CBdeltax - CBdeltay) shl 1;
CBxinc1 := 0;
CBxinc2 := 1;
CByinc1 := 1;
CByinc2 := 1;
end;
if x3 > x2 then
begin
CBxinc1 := - CBxinc1;
CBxinc2 := - CBxinc2;
end;
if y3 > y2 then
begin
CByinc1 := - CByinc1;
CByinc2 := - CByinc2;
end;
CBx := x3;
CBy := y3; |
Partager