B. J. Boltayev, A. R. Azamatov, G. A. Azamatova, B. S. Xurramov nazariya, algoritm, dastur toshkent 2013


eStyle(F,P,Q) protsedurasi, bo‘yash uchun SetFillStyle


Download 372.89 Kb.
bet64/68
Sana02.11.2023
Hajmi372.89 Kb.
#1740971
1   ...   60   61   62   63   64   65   66   67   68
Bog'liq
Algoritmlash va dasturlash asoslari seriyasidan Kitob – II b. J.-fayllar.org

eStyle(F,P,Q) protsedurasi, bo‘yash uchun SetFillStyle(usul,rang); protsedurasi
yordamida tanlanadi. Matn rangi SetColor(Rang) protsedurasi, shrifti ko‘rinishi
usuli SetTextStyle(F,Y,T) protsedurasi yordamida tanlanadi. Moveto(X,Y) yur-
gich joyini belgilaydi.
Dasturi:
Uses graph;
Var gd,gm:integer;
Begin gd:=0; Initgraph(gd,gm,''); Setbkcolor(2);
Setlinestyle(0,0,3); Setcolor(13); Setfillstyle(11,13); Fillellipse(320,100,77,77);
Setcolor(4); Setfillstyle(10,4); Moveto(220,180); Lineto(420,180);
Lineto(520,450); Lineto(120,450); Lineto(220,180); Floodfill(320,250,4);
Moveto(200,250); SetColor(11); SetTextStyle(1, 0, 5);Outtext('O`ZBEKISTON');
Moveto(180,320); SetColor(13); SetTextStyle(1, 0, 5);
Outtext('RESPUBLIKASI');
Readln; Closegraph;
End.

159*. O‘zbekiston bayrog‘i rasmini (oy va yulduzlarsiz) chizing.

Yechim:
Bayroq rasmi to‘g‘ri to‘rtburchaklar birlashmasi ko‘rinishida tasvirlanadi.
To‘g‘ri to‘rtburchaklar chizish uchun Bar(X1,Y1,X2,Y2); protsedurasidan,
bo‘yash uchun SetFillStyle(usul,rang); protsedurasidan foydalanish qulay.
Dasturi:
Uses graph;
Var gd, gm:integer;
Begin
gd := 0; InitGraph(gd, gm, '');
setfillstyle(1,LightBlue); bar(50,50,380,100);
setfillstyle(1,Red); bar(50,100,380,103);
setfillstyle(1,White); bar(50,103,380,153);
setfillstyle(1,Red); bar(50,153,380,156);
setfillstyle(1,Green); bar(50,156,380,206);
setfillstyle(1,Yellow); bar(40,40,50,350);
Readln; CloseGraph;



112
end.

Natijaning ekrandagi ko‘rinishi:

160*. Stol rasmini chizing.

Yechim:
Stol oyoqlari va stol usti qoplamasini hajmli chizish uchun Bar3D(…)
protsedurasidan foydalanish qulay.
Dasturi:
Uses Graph;
Var gd,gm:integer;
Begin gd:=0; InitGraph(gd,gm, ''); setbkcolor(15); setcolor(1); setfillstyle(1,1);
bar3d(100,130,115,220,10,true); bar3d(150,90,165,180,10,true);
bar3d(287,130,302,220,10,true); bar3d(327,90,342,180,10,true);
setcolor(13); setfillstyle(1,13); bar3d(80,120,320,140,60,true);
floodfill(200,80,13);setcolor(4); bar3d(80,120,320,140,60,true);
ReadLn; CloseGraph;
End.

Natijaning ekrandagi ko‘rinishi:


161. Stol, uning ustida gul va kompyuter rasmini chizing.


162*. Uycha rasmini chizing.

Dasturi:


Uses Graph;



113
Var


gd,gm:integer;
m:array[1..4, 1..2] of integer;
Begin
gd:=0; InitGraph(gd,gm, ''); setbkcolor(15); setcolor(3);
m[1,1]:=240;m[1,2]:=10; m[2,1]:=400;m[2,2]:=10;
m[3,1]:=500;m[3,2]:=60; m[4,1]:=140;m[4,2]:=60;
setfillstyle(8, 3); Fillpoly(4,m); setfillstyle(1,7);
bar(170,61,470,250); setcolor(7); rectangle(170,61,470,250);
setfillstyle(11,7); bar(175,65,465,245);
setfillstyle(7,12); bar(160,254,480,300);
setcolor(12); rectangle(160,252,480,300);
setfillstyle(1,4); bar(220,100,272,180); bar(360,100,412,180);
setfillstyle(1,7); bar(224,104,268,176); bar(364,104,408,176);
setfillstyle(1,4); bar(220,120,272,130); bar(360,120,412,130);
bar(244,120,248,176); bar(384,120,388,176);
ReadLn; CloseGraph;
End.

Natijaning ekrandagi ko‘rinishi:


163. Daraxt rasmini chizing.


164. Qushlar rasmini chizing.
165*. Tog‘lar rasmini chizing.
166. Uycha, daraxt, qush, quyosh va tog‘ aks etgan kun manzarasini chizing.
167. Uycha, daraxt, qush, oy va tog‘ aks etgan tun manzarasini chizing.
168*. Olov purkayotgan raketa rasmini chizing.
169. Samolyot rasmini chizing.
170*. Robot rasmini chizing.
171. Tuxum va yonida jo‘ja rasmini chizing.
172*. Tomonining uzunligi a ga teng kvadrat va unga ichki chizilgan aylana
chizish dasturi tuzilsin. a ning qiymati muloqot usulida kiritilsin.


114
a


R
R
a
Yechim:
Chizmaga asosan a=2∙R yoki R=
2
a
. Kvadratning chap yuqori
qirrasi koordinatasi (x, y) bo‘lsa, u holda quyi o‘ng qirrasi (x+a,
y+a) bo‘ladi. Demak, aylana markazi koordinatalari kesmani teng
ikkiga bo‘lish qoidasiga asosan quyidagicha bo‘ladi:






























2
a
y
,
2
a
x
2
a
y
2
,
2
a
x
2
2
a
y
y
,
2
a
x
x
.
Masalan, agar a=100, x=100 va y=80 deb olinsa, aylana markazi koordinata-
lari (150, 130) kabi bo‘ladi. Dasturda a o‘zgaruvchini qiymatini klaviaturadan
kiritish uchun Readln(a) operatori yoziladi. Shakllar chizish protseduralari
piksellarning butun qiymatlarida ishlagani uchun a o‘rniga trunc(a) va R o‘rniga
trunc(R) qaraladi.
Dasturi:
Uses Graph;
Var x, y, gd, gm: Integer; a, R: real;
Begin gd:=0; Init
Graph(gd, gm, ‘‘); Write(‘a= ‘); ReadLn(a); R:=a/2;
WriteLn(‘Kvadrat chap yuqori qirrasi koordinatalarini kiriting:‘);
Write(‘x= ‘); ReadLn(x); Write(‘y= ‘); ReadLn(y);
Setbkcolor(2); Setcolor(14); Rectangle(x, y, x+trunc(a), y+trunc(a));
Setcolor(4); Circle(x+trunc(a/2), y+trunc(a/2), trunc(R));
ReadLn; CloseGraph;
End.

Natijaning ekrandagi ko‘rinishi:


173*. Radiusi R ga teng aylana va unga tashqi chizilgan kvadrat chizish dasturi


tuzilsin. R ning qiymati muloqot usulida kiritilsin.

Yechim:
Avvalgi masaladagi chizmaga asosan a=2∙R. Aylana markazi koordinatasi


(x, y) bo‘lsa, u holda kvadratning chap yuqori qirrasi koordinatasi (x–R, y–R)
bo‘lsa, u holda quyi o‘ng qirrasi (x+R, y+R) bo‘ladi. Dasturda R o‘zgaruvchini


Download 372.89 Kb.

Do'stlaringiz bilan baham:
1   ...   60   61   62   63   64   65   66   67   68




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