ВУЗ:
Составители:
ОСНОВЫ КОМПЬЮТЕРНОЙ ГРАФИКИ, часть 1 45
reject:=Reject_Check(outcode1,outcode2);
if reject then done:= true
else
begin {возможно принятие целиком}
accept:=Accept_Check(outcode1,outcode2);
if accept then done:=true
else
begin {разделить отрезок}
{если P1 внутри, то с помощью SWAP сделать снаружи}
if not((outcode1[1])or(outcode1[2])or
(outcode1[3])or(outcode1[4])) then SWAP;
{теперь P1 перемещается в точку пересечения}
if outcode1[1] then
begin {отбросить верхнюю часть}
x1:=x1+(x2-x1)*(ymax-y1)/(y2-y1);
y1:=ymax;
end
else if outcode1[2] then
if outcode1[1] then
begin {отбросить нижнюю часть}
x1:=x1+(x2-x1)*(ymin-y1)/(y2-y1);
y1:=ymin;
end
else if outcode1[3] then
begin {отбросить правую часть}
y1:=x1+(y2-y1)*(ymax-x1)/(x2-x1);
x1:=xmax;
end
else if outcode1[4] then
begin {отбросить левую часть}
y1:=x1+(y2-y1)*(ymin-x1)/(x2-x1);
x1:=xmin;
end;
end;
end;
until done;
if accept then
Line(x1,y1,x2,y2); {нарисовать отрезок}
end;{procedure}
ОСНОВЫ КОМПЬЮТЕРНОЙ ГРАФИКИ, часть 1 45
reject:=Reject_Check(outcode1,outcode2);
if reject then done:= true
else
begin {возможно принятие целиком}
accept:=Accept_Check(outcode1,outcode2);
if accept then done:=true
else
begin {разделить отрезок}
{если P1 внутри, то с помощью SWAP сделать снаружи}
if not((outcode1[1])or(outcode1[2])or
(outcode1[3])or(outcode1[4])) then SWAP;
{теперь P1 перемещается в точку пересечения}
if outcode1[1] then
begin {отбросить верхнюю часть}
x1:=x1+(x2-x1)*(ymax-y1)/(y2-y1);
y1:=ymax;
end
else if outcode1[2] then
if outcode1[1] then
begin {отбросить нижнюю часть}
x1:=x1+(x2-x1)*(ymin-y1)/(y2-y1);
y1:=ymin;
end
else if outcode1[3] then
begin {отбросить правую часть}
y1:=x1+(y2-y1)*(ymax-x1)/(x2-x1);
x1:=xmax;
end
else if outcode1[4] then
begin {отбросить левую часть}
y1:=x1+(y2-y1)*(ymin-x1)/(x2-x1);
x1:=xmin;
end;
end;
end;
until done;
if accept then
Line(x1,y1,x2,y2); {нарисовать отрезок}
end;{procedure}
Страницы
- « первая
- ‹ предыдущая
- …
- 43
- 44
- 45
- 46
- 47
- …
- следующая ›
- последняя »
