Графика в Pascal
Листинг программы Domik
Program Domik;
uses Graph, Crt;
var g,m,d,gd,gm,x,y,i,c,c1,c2:integer;
Procedure cvetok;
begin
For i:=1 to 30 do
begin
x:=random(500)+20;
y:=random(50)+410;
setfillstyle(1,15);
SetColor(15);
PieSlice(x,y,0,360,3);
PieSlice(x-6,y,0,360,3);
PieSlice(x,y+10,0,360,3);
PieSlice(x-6,y+10,0,360,3);
PieSlice(x-8,y+5,0,360,3);
PieSlice(x+2,y+5,0,360,3);
c:=random(14)+1;
setfillstyle(1,c);
SetColor(c);
PieSlice(x-3,y+5,0,360,3);
end;
end;
Procedure okna;
begin
x:=500;
y:=140;
for i:=1 to 4 do
begin
SetColor(0);
SetFillStyle(1,15);
bar(x,y,x+40,y+40);
bar(x+70,y,x+110,y+40);
c:=random(14)+1;
SetColor(c);
SetFillStyle(1,c);
Sector(x,y,270,360,20,30);
Sector(x+40,y,180,270,20,30);
c:=random(6)+9;
SetColor(c);
SetFillStyle(1,c);
Sector(x+70,y,270,360,20,30);
Sector(x+110,y,180,270,20,30);
y:=y+60;
end;
end;
Procedure oblaka;
begin
SetCOlor(9);
SetFillStyle(1,9);
For i:=1 to 5 do
begin
x:=random(450);
y:=random(70)+100;
FillEllipse(x,y,15,10);
PieSlice(x-15,y-10,0,360,10);
PieSlice(x,y-20,0,360,10);
PieSlice(x+15,y-10,0,360,10);
end;
end;
Procedure yabloki;
begin
SetColor(4);
SetFillStyle(1,4);
For i:=1 to 6 do
begin
x:=random(45)+185;
y:=random(90)+230;
PieSlice(x,y,0,360,5);
end;
end;
Procedure solnce;
var x,y,x1,y1,j,dl,xp,yp,xp1,yp1,yp2,xp2,y2,x2:Word;
uu, u:real;
begin
SetColor(Yellow);
SetFillStyle(1, Yellow);
FillEllipse(50, 50, 30, 30);
for j := 0 to 89 do
begin
dl := Random(Random(30));
uu := 0.01*j;
x := Round(35*cos(7*uu )+50);
y := Round(35*sin(7*uu)+50);
x1 := Round((50+1.0*dl)*cos(7*uu )+50);
y1 := Round((50+1.0*dl)*sin(7*uu)+50);
Line( x, y, x1, y1);
end;
end;
Procedure kacheli(c1,c2:integer);
begin
SetFillStyle(1,4);
SetColor(4);
Bar(65,410,75,430);
SetColor(c1);
SetLineStyle(0,1,3);
Line(20,390,120,430);
SetFillStyle(1,c2);
SetColor(c2);
PieSlice(25,390,0,360,7);
PieSlice(115,425,0,360,7);
end;
Procedure kacheli2(c1,c2:integer);
begin
SetFillStyle(1,4);
SetColor(4);
Bar(65,410,75,430);
SetColor(c1);
SetLineStyle(0,1,3);
Line(20,430,120,390);
SetFillStyle(1,c2);
SetColor(c2);
PieSlice(25,425,0,360,7);
PieSlice(115,390,0,360,7);
end;
begin
DetectGraph(d,m);
gd:=9;
gm:=2;
InitGraph(gd,gm,'D:\Pascal\bgi\');
SetGraphMode(2);
SetBkColor(11);
{gazon}
SetfillStyle(1,10);
bar(0,380,639,479);
cvetok;
{dom}
SetColor(7);
SetFillStyle(1,7);
bar(480,120,630,430);
SetLineStyle(1,1,1);
okna;
SetColor(8);
SetFillStyle(1,8);
bar (540,380,570,430);
SetColor(16);
SetFillStyle(1,16);
PieSlice(545,400,0,360,3);
{antena}
SetLineStyle(0,1,3);
SetFillStyle(1,8);
SetColor(8);
Line(570,110,570,120);
Line(570,110,590,90);
Line(570,110,560,100);
PieSlice(590,90,0,360,12);
{kacheli}
SetColor(4);
Line(300,440,320,360);
Line(320,400,320,360);
Line(320,360,360,360);
Line(360,400,360,360);
Line(360,360,380,440);
Line(330,360,330,410);
Line(350,360,350,410);
SetFillStyle(1,14);
SetColor(14);
Bar(325,405,355,415);
{Derevo}
SetFillStyle(1,2);
SetColor(2);
FillEllipse(205,270,35,60);
FillEllipse(220,295,30,20);
FillEllipse(190,295,30,25);
FillEllipse(220,320,20,20);
FillEllipse(190,320,20,20);
FillEllipse(205,325,15,25);
SetFillStyle(1,6);
SetColor(6);
Bar(200,330,210,420);
yabloki;
solnce;
oblaka;
kacheli(4,5);
SetFillStyle(1,4);
SetColor(4);
PieSlice(187,270,0,360,8);
x:=140;
y:=30;
For i:=1 to 639 do
begin
x:=x+1;
SetFillStyle(1,1);
SetColor(1);
PieSlice(x,y,0,360,20);
PieSlice(x+30,y-10,0,360,20);
PieSlice(x+60,y+10,0,360,20);
PieSlice(x+10,y+20,0,360,20);
PieSlice(x+50,y+20,0,360,20);
PieSlice(x+30,y+10,0,360,10);
delay(100);
SetFillStyle(1,11);
SetColor(11);
PieSlice(x,y,0,360,20);
PieSlice(x+30,y-10,0,360,20);
PieSlice(x+60,y+10,0,360,20);
PieSlice(x+10,y+20,0,360,20);
PieSlice(x+50,y+20,0,360,20);
PieSlice(x+30,y+10,0,360,10);
end;
delay(60000);
SetFillStyle(1,2);
SetColor(2);
PieSlice(187,270,0,360,8);
SetFillStyle(1,4);
SetColor(4);
PieSlice(187,405,0,360,8);
While not KeyPressed do
begin
kacheli(4,5);
delay(60000);
delay(60000);
kacheli(10,10);
kacheli2(4,5);
delay(60000);
delay(60000);
kacheli2(10,10);
end;
CloseGraph;
ClearDevice;
end.