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.
|
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:
112
Natijaning ekrandagi ko‘rinishi:
160*. Stol rasmini chizing. Yechim:
Natijaning ekrandagi ko‘rinishi: 161. Stol, uning ustida gul va kompyuter rasmini chizing. 162*. Uycha rasmini chizing. Dasturi: Uses Graph; 113
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
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:
(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: |
ma'muriyatiga murojaat qiling