Paskalabc da grafiklarga oid dastlabki ma'lumotlar Program g 1; uses Graphabc; //1-kurs kt: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod


Download 98.52 Kb.
bet1/5
Sana25.10.2019
Hajmi98.52 Kb.
  1   2   3   4   5

PaskalABC da grafiklarga oid dastlabki ma'lumotlar

Program g_1;
  uses GraphABC;
//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod

// Line (x1,y1,x2,y2) chiziq chizish protsedurasi
//x1,y1 nuqtadan x2,y2 nuqtagacha to'g'ri chiziq chizadi
begin
Line (50,60,120,220)
end.

Program g_2;
  uses GraphABC;
  //setcolor(rang)-rang tanlash protsedurasi
// Line (x1,y1,x2,y2) chiziq chizish protsedurasi
 begin
  Setwindowcaption ('TerDu');
 Line (150,160,220,320);
 end.

Program g_3;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
  //setcolor(rang)-rang tanlash protsedurasi
// Line (x1,y1,x2,y2) chiziq chizish protsedurasi
//Savol:2 ta chiziq o'tkazing
 begin
  Setwindowcaption ('TerDu');
 Line (150,160,220,320);
  Line (450,160,520,20);
 end.

Program g_4;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
  //setcolor(rang)-rang tanlash protsedurasi
// Line (x1,y1,x2,y2) chiziq chizish protsedurasi
//Savol:3 ta parallel chiziqlar o'tkazing
 begin
  Setwindowcaption ('TerDu');
 Line (100,100,400,100);
  Line (100,200,500,200);
  Line (100,300,600,300);
 end.

Program g_5;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
  //setcolor(rang)-rang tanlash protsedurasi
// Line (x1,y1,x2,y2) chiziq chizish protsedurasi
//Savol:3 ta parallel vertikal chiziqlar o'tkazing
 begin
  Setwindowcaption ('TerDu');
 Line (100,100,100,600);
  Line (200,100,200,600);
  Line (300,100,300,600);
 end.

Program g_6;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
  //Rectangle(x1,y1,x2,y2)-to'rtburchak chizish protsedurasi
// Line (x1,y1,x2,y2) chiziq chizish protsedurasi
//Savol:3 ta parallel vertikal chiziqlar o'tkazing
 begin
  Setwindowcaption ('Tuzuvchi:FAXRIDDINOV SHERZOD');
 Rectangle(50,50,300,250);
 end.

Program g_7;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
  //Ellipse(a,b,c,d,e,f)-ellips chizish protsedurasi
  //protsedura markazi (a,b) o'qlari bo'yicha radiuslari c va d
  //ellips e burchagini f gacha buradi
 begin
  Setwindowcaption ('Ellips');
FillEllipse(200,200,50,75);

end.

Program g_8;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
// Line (x1,y1,x2,y2) chiziq chizish protsedurasi
//Savol:Aylana va to'rtburchak
 begin
  Setwindowcaption ('Tuzuvchi:FAXRIDDINOV SHERZOD');
 Rectangle(50,50,250,250);
 Circle(150,150,100);

end.

Program g_9;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
  //Rectangle(x1,y1,x2,y2)-to'rtburchak chizish protsedurasi
// Line (x1,y1,x2,y2) chiziq chizish protsedurasi
//Savol:4 ta chiziqdan to'rtburchak yasang
 begin
  Setwindowcaption ('Tuzuvchi:FAXRIDDINOV SHERZOD');
 Line(100,100,300,100);
  Line(300,100,300,300);
   Line(300,300,100,300);
    Line(100,300,100,100);
 end.

Program g_10;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
// Circle (x,y,r) aylana chizish protsedurasi
//Savol:3 ta ichma-ich aylana yasang
 begin
  Setwindowcaption ('Tuzuvchi:FAXRIDDINOV SHERZOD');
  Circle(200,200,200);
  Circle(200,200,150);
  Circle(200,200,100);
  Circle(200,200,50);
  Circle(200,200,25);
 end.

Program g_11;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
// Rectangle(x1,y1,x2,y2) to'rtburchak chizish protsedurasi
//Savol:5 ta ichma-ich to'rtburchak chizing
 begin
  Setwindowcaption ('Tuzuvchi:FAXRIDDINOV SHERZOD');
  Rectangle(50,50,400,400);
  Rectangle(100,100,350,350);
  Rectangle(150,150,300,300);
  Rectangle(200,200,250,250);
  Rectangle(210,210,240,240);
 end.

Program g_12;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
// Rectangle(x1,y1,x2,y2) to'rtburchak chizish protsedurasi
//Savol:Kvadrat chizing va uning dioganallarini belgilang
 begin
  Setwindowcaption ('Tuzuvchi:FAXRIDDINOV SHERZOD');
  Rectangle(100,100,400,400);
  Line(100,100,400,400);
  Line(400,100,100,400);
 end.

Program g_13;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
// Line(x1,y1,x2,y2) to'rtburchak chizish protsedurasi
//Savol:Qor parchasi nomli dastur tuzing.4 ta chiziq yordamida
 begin
 Setwindowcaption ('Tuzuvchi:FAXRIDDINOV SHERZOD');
  Line(300,100,300,500);
  Line(100,300,500,300);
    Line(200,200,400,400);
     Line(400,200,200,400);

 end.

  Program g_14;
  uses GraphABC;

//1-kurs KT: Informatika va axborot texnologiyalar yo`nalishi talabasi Faxriddinov Sherzod
// Line(x1,y1,x2,y2) to'rtburchak chizish protsedurasi
//Savol:Qor parchasi nomli dastur tuzing.4 ta chiziq yordamida
//ular to'rtburchak ichiga joylashsin
 begin
 Setwindowcaption ('Tuzuvchi:FAXRIDDINOV SHERZOD');
 Rectangle(100,100,500,500);
  Line(300,100,300,500);
  Line(100,300,500,300);
    Line(200,200,400,400);
     Line(400,200,200,400);
 end.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



PascalABC da grafiklarga doir misollar

program grafik10_1;
//TOPSHIRISH.-1)grafik darcha yasang 2)uni ekranning (x,y) nuqtasidan boshlab
//joylashtiring 3)darcha kengligi w va balandligi h gab teng qilib o'rnating
//4)darcha sarlavhasi nomini m o'zgaruvchi qiymatiga teng qilib o'rnating
//x=100; y=200; w=50; h=175; m=’ Mustaqil grafik dastur’;
uses graphABC;  //Grafik modulni kiritamiz
begin
setwindowSize(300,400);
 //grafik darcha o'lchamlari kiritdik
SetWindowPos(250,275);
 //grafik darcha joriy o'rni
SetWindowCaption('Mustaqil grafik dastur') 
//grafik darcha sarlavhasi kiritdik
end.

program grafik10_2;
//ekranga (x,y) pozitsiyadan boshlab eni w balandligi h ga teng bo'lgan grafik
//dartcha chiqaring.Bu amalni n marta m millisekund interval bilan takrorlang.
//x=200, y=100, w=200, h=100, dx=dy=dw=dh=10, n=40, m=333.
uses crt,graphABC;//Grafik modulni kiritdik
var i:integer;
begin
SetWindowCaption('2-grafik dastur');
//grafik darcha sarlavhasini kiritdik
for i:=0 to 40 do   //takrorlanishlar soni
begin
setwindowSize(200+i*10,100+i*10);
//grafik darcha o'lchamlari
SetWindowPos(200+i*10,100+i*10);
//grafik darcha o'rni
delay(333);    //takrorlanish vaqti tanaffus
end;  //Bunda grafik darcha kompilyatsiya davomida 
harakatlanib turadi
end.

program grafik10_3;
//ekranga ixtiyoriy o'lchamli,ixtiyoriy pozitsiyada joylashgan grafik
//darchani har 1000 millisekundda chiqaring va o'zingiz mustaqil ixtiyoriy vaqt
//kirita oladigan dastur tuzing
uses crt,graphABC;//Grafik modulni kiritib oldik
var i:integer;
begin
SetWindowCaption('3-grafik dastur');
//grafik darcha sarlavhasi kiritdik
while true do
begin
setwindowSize(random(screenwidth),random(screenheight));
//grafik darcha o'lchamlarini kiritib oldik
SetWindowPos(random(screenwidth-windowwidth-5),
random(screenheight-windowheight-100));
//grafik darcha o'rnini ham kiritdik
delay(1000);
end;
end.

program grafik10_4;
//ekranga tasodifiy o'lchamli,tasodifiy pozitsiyada joylashgan,tasodifiy
//tanlangan fon rangiga ega grafik darchani xar 1000 millisekundda chiqaradi.Bunda
//barcha grafik darchalar to'laligicha ekranga joylashsin
uses crt,graphABC;//Grafik modulni kiritdik
var i:integer;
begin
SetWindowCaption('4-grafik dastur');
//grafik darcha sarlavhasi kiritdik
while true do
begin
setwindowSize(random(screenwidth-5),
random(screenheight-50));
//grafik darcha o'lchamlari kiritdik
SetWindowPos(random(screenwidth-windowwidth),random(screenheight-windowheight-
50));
//grafik darcha o'rnini kiritdik
floodfill(4,4,random(256*256*256));
delay(1000);//Bunda grafik darcha turli xil ranglarda ekranning har xil tomonlariga
//va har xil vaziyat va o'lchamda chiqariladi
end;
end.

 

program grafik10_5;


  //quyidagi topshiriqni 4-topshiriqni o'lchamdagi to'g'ri to'rtburchak
  //chizish orqali bajarish dasturini tuzing
uses crt,graphABC;//Grafik modulni kiritdik
var i:integer;
begin
SetWindowCaption('5-grafik dastur');
//grafik darcha sarlavhasi
while true do
begin
setwindowSize(random(screenwidth),
random(screenheight));
//grafik darcha o'lchamlarini kiritdik
SetWindowPos(random(screenwidth-windowwidth),random(screenheight-windowheight));
//grafik darcha o'rnini kiritdik
setbrushcolor(random(256*256*256));
fillrect(0,0,windowwidth,windowheight);
delay(1000);
end;
end.

program grafik10_6;
//ekranga eng katta o'lchamli garfik darcha chiqaring.Unga tasodifiy joylashgan
//tasodifiy tanlangan o'lcham va rangga to'g'ri to'rtburchakni ketma-ket dastur
//darchasi yopilguncha qadar chiqariladigan dastur tuzing
uses crt,graphABC;//Grafik modulni kiritdik
var x0,x1,y0,y1:integer;
begin
SetWindowCaption('6-grafik dastur');
//grafik darcha sarlavhasini kiritdik
setwindowSize(screenwidth,screenheight);
//grafik darcha o'lchamlarini kiritdik
SetWindowPos(0,0);
//grafik darcha o'rnini kiritdik
while true do
begin
setbrushcolor(random(256*256*256));
x0:=random(screenwidth);
y0:=random(screenheight);
x1:=random(screenwidth);
y1:=random(screenheight);
fillrect(X0,Y0,X1,Y1);
delay(1);//kompilyatsiya jarayonida har xil rangdagi har xil o'lchamli to'rtburchaklar
//takrorlanib almashinib turadi
end;
end.

program grafik10_7;
//ekranga eng katta o'lchamli grafik darcha chiqaring.Unga tasodifiy joylashgan,
//tasodifiy tanlangan rangga ega piksellarni ketma-ket,dastur darchasi yopilguncha
//qadar chiqaradigan dastur tuzing
uses graphABC;
var x0,y0,color0:integer;
begin
SetWindowCaption('7-grafik dastur');
 //Grafik darchani kiritdik
setwindowSize(screenwidth,screenheight);
SetWindowPos(0,0);
while true do
begin
color0:=random(256*256*256);
x0:=random(screenwidth);
y0:=random(screenheight);
setpixel(X0,Y0,color0);
end;//Bunda darcha butun ekranni qoplaydi va unda piksellar paydo bo'ib
//ko'paya boradi

end.

program grafik10_8;
//ekranga eng katta o'lchamli grafik darcha chiqaring.Undagi har bir pikselni
//tasodifiy tanlangan rangga ketma-ket dastur darchasi yopilguncha qadar chiqaradigan dastur tuzing
uses graphABC;
var x0,y0,color0:integer;
begin
SetWindowCaption('8-grafik dastur');
setwindowSize(screenwidth,screenheight);
SetWindowPos(0,0);
while true do
for x0:=0 to windowwidth-1 do
for y0:=0 to windowheight-1 do
begin
color0:=random(256*256*256);
setpixel(X0,Y0,color0);
end;//Grafik darchada chapdan piksellar bilan to'lgan qator davom etadi

end.

program grafik10_9;
  //ekranga eng katta o'lchamli grafik darcha chiqaring.Piksellarning rangini
  //ketma-ket 0 dan 256*256*256–1=16 777 215 gacha o'zgartirib ekranga ketma-ket
  //chiqaradi
uses graphABC;
var i,x0,y0,color0:integer;
begin
SetWindowCaption('9-grafik dastur');
setwindowSize(screenwidth,screenheight);
SetWindowPos(0,0);
for i:=0 to 256*256*256 do
begin
y0:=i mod Windowheight;
x0:=(i div Windowheight) mod Windowwidth;
setpixel(X0,Y0,i);
end;

end.

program grafik10_10;
//ekranga x1 o'lchamli grafik darcha chiqaring.Grafik darchaning chegara tomonlarining
//har birini i/(n-i) nisbatda bo'luvchi nuqtalarni topib ularning i ning har bir qiymati
//uchun kesmalar bilan birlashtirib chiqaring
uses graphABC;
const
n=100;
l=600;
m=600;
var a,b: integer;
i,j:integer;
begin
setwindowsize(m,l);
for i:=1 to n-1 do
begin
setpencolor(random(256*256*256));
a:=round(l/n*i);
b:=round(m/n*i);
line(0,a,m-b,0);
line(m,a,m-b,l);
line(m,a,b,0);
line(0,l-a,m-b,l);
end;
end.

program grafik10_11;
//ekran o'rtasiga 2RX2R o'lchamli grafik darchani chiqaring.Unga R radiusli
//aylana chizing.Aylanaga ichki chizilgan n burchak yasang.Uning barcha dioganallarini
//chizing R=275  n=30
uses crt,graphABC;
const
n=30;
R=275;
var
i,j:integer;
x,y: array [0..n] of integer;
begin
SetWindowCaption('11-grafik dastur');
setwindowSize(2*r,2*r);
centerWindow;
setpencolor($0000ff);
clearwindow;
textout(3,3,inttostr(n));
circle(r,r,r);
for i:=1 to n do
begin
x[i]:=round(r+r*cos(2*pi/n*i));
y[i]:=round(r+r*sin(2*pi/n*i));
end;
for i:=1 to n-1 do
for j:=i+1 to n do
line(x[i],y[i],x[j],y[j]); 

end.

program grafik10_12;
// ekranga grafik darcha chiqaring.Uning vertikar va gorizontal tomonlarini
//teng bo'laklarga bo'lib hosil bo'lgan nuqtalarni bir-biri bilan tutashtirib chiqing
uses graphABC;
const
k=12;
n=8;
l=700;m=1000;
var x,y:array[0..2*(n+k)] of integer;
i,j:integer;
begin
setwindowsize(m,l);
for i:=0 to n-1 do
begin
x[i]:=0;y[i]:=round((l/n)*i);
x[k+n+i]:=m;y[k+n+i]:=round((l/n)*i);
end;
for i:=0 to k-1 do
begin
y[n+i]:=0;x[n+i]:=round((m/k)*i);
y[n+n+k+i]:=l;x[n+n+k+i]:=round((m/k)*i);
end;
x[n]:=m;y[n]:=l;
setpencolor($0000ff);
for i:=0 to 2*(n+k) do
for j:=i to 2*(n+k) do
line(x[i],y[i],x[j],y[j])
end.

program grafik10_13;
//ichma-ich joylashgan to'g'ri to'rtburchaklarni chizish bilan tasvir hosil qiling
uses graphABC;
const
lm=0.13;
n=21;
l=600;m=600;
var a,b,c,d:array[0..1,0..1] of integer;
i,j:integer;
procedure init;
begin
setwindowsize(2*m,2*l);
a[0,0]:=0;a[0,1]:=0;
b[0,0]:=0;b[0,1]:=l div 2;
c[0,0]:=m div 2;c[0,1]:=l div 2;
d[0,0]:=m div 2;d[0,1]:=0;
setpenwidth(3);
end;
function newP(z1,z2:integer):integer;
begin
newp:=round(lm*z1+(1-lm)*z2);
end;
procedure newrect;
begin
a[1,0]:=newp(a[0,0],b[0,0]);
a[1,1]:=newp(a[0,1],b[0,1]); b[1,0]:=newp(b[0,0],c[0,0]);
b[1,1]:=newp(b[0,1],c[0,1]); c[1,0]:=newp(c[0,0],d[0,0]);
c[1,1]:=newp(c[0,1],d[0,1]); d[1,0]:=newp(d[0,0],a[0,0]);
d[1,1]:=newp(d[0,1],a[0,1]); a[0,0]:=a[1,0];a[0,1]:=a[1,1];
b[0,0]:=b[1,0];b[0,1]:=b[1,1]; c[0,0]:=c[1,0];c[0,1]:=c[1,1];
d[0,0]:=d[1,0];d[0,1]:=d[1,1]; end;
procedure drawl(x1,y1,x2,y2:integer);
begin
line(m div 2 -x1,l div 2 -y1,m div 2 -x2,l div 2 -y2);
line(m div 2 +x1,l div 2 -y1,m div 2 +x2,l div 2 -y2);
line(m div 2 -x1,l div 2 +y1,m div 2 -x2,l div 2 +y2);
line(m div 2 +x1,l div 2 +y1,m div 2 +x2,l div 2 +y2); end;
procedure drawpicture;   begin
setpencolor(i*100000);
drawl(a[0,0],a[0,1],b[0,0],b[0,1]);
drawl(b[0,0],b[0,1],c[0,0],c[0,1]);
drawl(c[0,0],c[0,1],d[0,0],d[0,1]);
drawl(a[0,0],a[0,1],d[0,0],d[0,1]);
floodfill(m div 4 ,l div 4,i*100000);
floodfill(3*m div 4 ,l div 4,i*100000);
floodfill(m div 4 ,3*l div 4,i*100000);
floodfill(3*m div 4 ,3*l div 4,i*100000);
end;   begin    init;
for i:=0 to n-1 do   begin
drawpicture;    newrect;

end;  

end.

program grafik10_14;
  //shaxmat taxtasiga 8 ta bir-birini ura olmaydigan farzinlarni joylashtirish
  //dasturini tuzung
uses crt,graphABC;
var x,y:integer;
s,sf,i,j:integer;
f:array[1..8] of integer;
function shart(i_sh:integer):integer;
var j_sh,s_sh:integer;
begin
s_sh:=1;
for j_sh:=1 to i_sh-1 do
if (f[j_sh]=f[i_sh]) or (abs(f[j_sh]-f[i_sh])=abs(j_sh-i_sh)) then
begin s_sh:=0;break end;
shart:=S_SH;
end;
procedure init_sh;
begin
clearwindow;
setwindowsize(400,400);
centerwindow;
floodfill(100,100,0);
for x:=0 to 7 do
for y:=0 to 7 do
if (x+y) mod 2=0 then
fillrect(x*50,y*50,50+x*50,50+50*y)
end;
procedure show_f;
begin
init_sh;setwindowcaption(inttostr(sf));
setfontsize(30);
for i:=1 to 8 do
textout(f[i]*50-40,(i-1)*50,'O');
delay(5000);
end;
procedure check_f;
var i1,i2, i3,i4,i5,i6,i7,i8:integer;
begin
init_sh;
sf:=0;
for i1:=1 to 8 do
begin f[1]:=i1;
for i2:=1 to 8 do
begin f[2]:=i2; if shart(2)=0 then continue;
for i3:=1 to 8 do
begin f[3]:=i3; if shart(3)=0 then continue;
for i4:=1 to 8 do
begin f[4]:=i4; if shart(4)=0 then continue;
for i5:=1 to 8 do
begin f[5]:=i5; if shart(5)=0 then continue;
for i6:=1 to 8 do
begin f[6]:=i6; if shart(6)=0 then continue;
for i7:=1 to 8 do
begin f[7]:=i7; if shart(7)=0 then continue;
for i8:=1 to 8 do
begin f[8]:=i8; if shart(8)=1 then begin sf:=sf+1;show_f end;
end;end;end;end;end;end;end;end;
writeln(sf);
end;
begin
check_f
end.

+++++++++++++++++++++++++++++++++++++++++

PaskalABC da nuqtalar va to’g’ri to’rtburchaklar bilan ishlash

9.1. Point=record  x,y: integer; end; Rect=record Left,Top,Right,Bottom: integer; end;
program grafik9_1
//Point=record  x,y: integer; end; Rect=record Left,Top,Right,Bottom: integer; end;
 // PointF(x,y: integer): Point;
 //nuqtaning x va y koordinatalari bo'yicha Point turidagi yozuvni qaytaradi;
uses graphABC,pointRect;
var x,y:integer;
PointF(100,100)
End.

9.2. EqualRect(r1,r2: Rect): boolean;
program grafik9_2;
//  EqualRect(r1,r2: Rect): boolean;
//r1 va r2 to'g'ri to'rtburchaklar teng bo'lsa TRUE aks
//holda FALSE ni qaytaradi
uses graphABC, PointRect;
var r1,r2: rect;
i:integer;
procedure drawrect(r0:rect);
begin
rectangle(r0.left,r0.top,r0.right,r0.bottom);
end;
begin
r1:=rectF(100,50,300,200);
r2:=rectF(250,100,450,250);
drawrect(r1);drawrect(r2);setfontsize(12);if equalrect(r1,r2)
then textout(100,270,'r1 va r2 bir xil.')  else textout(100,270,'r1 va r2 har xil.');
end.

9.3. IntersectRect(r1,r2: Rect): boolean;
program grafik9_5;
// IntersectRect(r1,r2: Rect): boolean;
//r1 va r2 to'g'ri to'rtburchaklar kesishmasi bo'sh bo'lmasa TRUE
//aks holda FALSE ni qaytaradi
uses graphABC, PointRect;
var r1,r2: rect;
i:integer;
procedure drawrect(r0:rect);
begin
rectangle(r0.left,r0.top,r0.right,r0.bottom);
end;
begin
r1:=rectF(100,50,300,200);
r2:=rectF(250,100,450,250);
drawrect(r1);
drawrect(r2);
setfontsize(12);
if intersectrect(r1,r2)
then textout(100,270,'r1 va r2 kesishadi.')
else textout(100,270,'r1 va r2 kesishmaydi.');
end.


Do'stlaringiz bilan baham:
  1   2   3   4   5


Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2019
ma'muriyatiga murojaat qiling