240
137. To‘g‘ri chiziqlar yordamida chegarasi yashil rangli archa rasmini chizing. 138*. To‘g‘ri chiziqlar yordamida chegarasi yashil rangli archa rasmini chizing va ichini ko‘k rangga bo‘yang.
Ichi fon rangida bo‘lgan (10,15), (510,200) nuqtalarni tutashtiruvchi yashil rangli to‘rtburchak chizing.
Ichi qizil rangda bo‘lgan (510,200), (10,15) nuqtalarni tutashtiruvchi yashil rangli to‘rtburchak chizing.
141*. Qizil rangli muntazam beshburchak chizing.
Yechim:
y
Matematika fanidan ta’rifiga ko‘ra, sin va
R
x
cos . Bundan markazi (0,0) nuqtada bo‘lgan R
R
radiusli aylananing (x, y) nuqtalarini quyidagi formulalar juftligi orqali aniqlash mumkinligi kelib chiqadiki: x = r·cos(), y = r·sin(), bu yerda bur o‘zgaradi.
Dasturda aylana nuqtalarini chizishda
|
|
chak 0 dan 2· gacha
burchakka mos piksellar butun
|
qiymatli bo‘lishi uchun ko‘paytmani Trunc orqali yozamiz. Aylana markazini aniqlaydigan butun o‘zgaruvchilarni kiritib olamiz: markazX va markazY. Aylana markazini (markazX, markazY) nuqtaga ko‘chirib Paskalda quyidagi formulalarni hosil qilamiz: x:= markazX +trunc(R*cos(alfa));
y:= markazY +trunc(R*sin(alfa));
Masaladagi muntazam beshburchak uchlari koordinatalarini aniqlash uchun quyidagicha mulohaza yuritamiz:
Muntazam beshburchakka tashqi aylana chizish mumkin. Aylanani bir “aylanib” chiqish 3600 yoki 2∙π ga teng. Bu burchakni 5 ga bo‘linsa, aylanani beshta teng yoyga ajratuvchi nuqtalar orasidagi burchak 2∙π/5 aniqlanadi. Ekran markazi (320, 240) ni koordinata boshi hisoblab muntazam beshburchakning yuqori uchi koordinatalarini radiusi 100 ga teng aylananing nuqtasi sifatida x:= 320 +trunc(100*cos(–pi/2)); y:= 240 +trunc(100*sin(–pi/2));
kabi aniqlash mumkin. Muntazam beshburchakning keyingi har bir nuqtasi shu formulada –pi/2 ga, mos ravishda, 1∙(2∙π/5)=2∙π/5, 2∙(2∙π/5)=4∙π/5,
3∙(2∙π/5)=6∙π/5, 4∙(2∙π/5)=8∙π/5 ni qo‘shish orqali hosil qilinadi.
Endi bu nuqtalarni Line(X1,Y1,X2,Y2) protsedurasi yoki FillPoly(BS,KM) protsedurasi yordamida tutashtirish mumkin. Chiziq rangini tanlash uchun SetColor(4), fon rangini tanlash uchun esa SetBkColor(14) protseduralaridan foydalaniladi.
|
Dasturi (Line):
Uses Graph;
Var gd, gm: integer; X1,Y1, X2, Y2: Integer; X3,Y3, X4,Y4, X5, Y5:Integer;
Begin Gd:= 0; InitGraph(Gd, Gm, ''); Setbkcolor(14); Setcolor(4);
X1:=320+trunc(100*cos(–pi/2)); Y1:=240+trunc(100*sin(–pi/2));
X2:=320+trunc(100*cos(–pi/2+2*pi/5)); Y2:=240+trunc(100*sin(–pi/2+2*pi/5));
X3:=320+trunc(100*cos(–pi/2+4*pi/5)); Y3:=240+trunc(100*sin(–pi/2+4*pi/5));
X4:=320+trunc(100*cos(–pi/2+6*pi/5)); Y4:=240+trunc(100*sin(–pi/2+6*pi/5));
X5:=320+trunc(100*cos(–pi/2+8*pi/5)); Y5:=240+trunc(100*sin(–pi/2+8*pi/5));
Line(X1,Y1,X2,Y2); Line(X2,Y2,X3,Y3); Line(X3,Y3,X4,Y4);
Line(X4,Y4,X5,Y5); Line(X5,Y5,X1,Y1); Readln; CloseGraph; End.
|
Dasturi (FillPoly):
Uses Graph;
Var gd, gm : Integer; bb : Array[1..5,1..2] of Integer;
Begin Gd:= 0; InitGraph(Gd, Gm, ''); Setbkcolor(14); Setcolor(4); bb[1,1]:=320+trunc(100*cos(–pi/2)); bb[1,2]:=240+trunc(100*sin(–pi/2)); bb[2,1]:=320+trunc(100*cos(–pi/2+ 2*pi/5));
|
bb[2,2]:=240+trunc(100*sin(–pi/2+ 2*pi/5)); bb[3,1]:=320+trunc(100*cos(–pi/2+ 4*pi/5)); bb[3,2]:=240+trunc(100*sin(–pi/2+ 4*pi/5)); bb[4,1]:=320+trunc(100*cos(–pi/2+ 6*pi/5)); bb[4,2]:=240+trunc(100*sin(–pi/2+ 6*pi/5)); bb[5,1]:=320+trunc(100*cos(–pi/2+ 8*pi/5)); bb[5,2]:=240+trunc(100*sin(–pi/2+ 8*pi /5)); FillPoly(5,bb); Readln; CloseGraph; End.
142*. Ichi siyrak qizil nuqtalar bilan to‘ldirilgan muntazam oltiburchak chizing.
Yechim:
Masaladagi muntazam oltiburchak uchlari koordinatalarini aniqlash uchun quyidagicha mulohaza o‘rinli:
Muntazam oltiburchakka tashqi aylana chizish mumkin. Aylanani bir “aylanib” chiqish 3600 yoki 2∙π ga teng. Bu burchakni 6 ga bo‘linsa, aylanani oltita teng yoyga ajratuvchi nuqtalar orasidagi burchak 2∙π/6=π/3 aniqlanadi. Ekran markazini koordinata boshi hisoblab muntazam oltiburchakning yuqori uchi koordinatalarini radiusi 100 ga teng aylananing nuqtasi sifatida x:= 320 +trunc(100*cos(–pi/2)); y:= 240 +trunc(100*sin(–pi/2));
kabi aniqlash mumkin. Muntazam oltiburchakning keyingi har bir nuqtasi shu formulada –pi/2 ga, mos ravishda, 1∙(π/3)=π/3, 2∙(π/3)=2∙π/3, 3∙(π/3)=π, 4∙(π/3)=4∙π/3, 5∙(π/3)=5∙π/3 ni qo‘shish orqali hosil qilinadi.
Chiziq rangini tanlash uchun SetColor(4), fon rangini tanlash uchun Set-
BkColor(14), ichini siyrak qizil nuqtalar bilan to‘ldirish uchun SetFillStyle(10,4); protseduralaridan foydalaniladi. Agar bu nuqtalar FillPoly(BS,KM) protsedurasi yordamida tutashtirilsa, ichi o‘zi bo‘yaladi. Agar nuqtalarni Line(X1,Y1,X2,Y2) protsedurasi yordamida tutashtirilsa ichiga bo‘yash usulini qo‘llash uchun Floodfill protsedurasidan foydalaniladi.
|
Dasturi (Line):
Uses Graph;
Var gd, gm, X1,Y1, X2,Y2: integer; X3,Y3,X4,Y4,X5,Y5,X6,Y6:Integer; Begin
Gd:= 0; InitGraph(Gd, Gm, ''); Setbkcolor(14); Setcolor(4); SetFillStyle(10,4);
X1:= 320 +trunc(100*cos(-pi/2)); Y1:= 240 +trunc(100*sin(-pi/2));
X2:= 320 +trunc(100*cos(-pi/2+pi/3)); Y2:= 240 +trunc(100*sin(-pi/2+pi/3));
X3:= 320 +trunc(100*cos(-pi/2+2*pi/3)); Y3:= 240 +trunc(100*sin(-pi/2+2*pi/3));
X4:= 320 +trunc(100*cos(-pi/2+pi)); Y4:= 240 +trunc(100*sin(-pi/2+pi));
X5:= 320 +trunc(100*cos(-pi/2+4*pi/3)); Y5:= 240 +trunc(100*sin(-pi/2+4*pi/3));
|
X6:= 320 +trunc(100*cos(-pi/2+5*pi/3)); Y6:= 240 +trunc(100*sin(-pi/2+5*pi/3));
Line(X1,Y1,X2,Y2); Line(X2,Y2,X3,Y3); Line(X3,Y3,X4,Y4); Line(X4,Y4,X5,Y5); Line(X5,Y5,X6,Y6); Line(X6,Y6,X1,Y1); Floodfill( 320,240, red); Readln; CloseGraph; End.
|
Dasturi (FillPoly):
Uses Graph;
Var gd, gm : Integer; A : Array[1..6,1..2] of Integer;
Begin
Gd:= 0; InitGraph(Gd, Gm, ''); Setbkcolor(14); Setcolor(4); SetFillStyle(10,4);
A[1,1]:=320+trunc(100*cos(–pi/2)); A[1,2]:=240+trunc(100*sin(–pi/2));
A[2,1]:=320+trunc(100*cos(–pi/2+pi/3)); A[2,2]:=240+trunc(100*sin(–pi/2+pi/3));
A[3,1]:=320+trunc(100*cos(–pi/2+2*pi/3));
A[3,2]:=240+trunc(100*sin(–pi/2+2*pi/3));
A[4,1]:=320+trunc(100*cos(–pi/2+pi)); A[4,2]:=240+trunc(100*sin(–pi/2+pi));
A[5,1]:=320+trunc(100*cos(–pi/2+4*pi/3));
A[5,2]:=240+trunc(100*sin(–pi/2+4*pi/3));
A[6,1]:=320+trunc(100*cos(–pi/2+5*pi/3));
A[6,2]:=240+trunc(100*sin(–pi/2+5*pi/3)); FillPoly(6,A); Readln; CloseGraph; End.
|
143*. Ekran markazida muntazam sakkizburchak chizing.
Yechim:
Muntazam oltiburchakka tashqi aylana chizish mumkin. Aylanani bir
“aylanib” chiqish 3600 yoki 2∙π ga teng. Bu burchakni 8 ga bo‘linsa, aylanani sakkizta teng yoyga ajratuvchi nuqtalar orasidagi burchak alfa=2∙π/8=π/4 aniqlanadi. Ekran markazini koordinata boshi hisoblab muntazam oltiburchakning yuqori uchi koordinatalarini radiusi 100 ga teng aylananing nuqtasi sifatida x:= 320 +trunc(100*cos(alfa)); y:= 240 +trunc(100*sin(alfa));
kabi aniqlash mumkin. Muntazam oltiburchakning keyingi har bir nuqtasi shu formulada alfa=alfa+π/4 orqali hosil qilinadi. Kesmalarni chizish uchun LineTo (X,Y) protsedurasidan foydalanamiz.
|
Dasturi:
uses graph;
var gd, gm :integer; x,y : array[1..8] of integer; alfa:real; Begin gd:=0; Initgraph(gd, gm,''); alfa:=pi/4; x[1]:=320+round(100*cos(alfa)); y[1]:=240+round(100*sin(alfa)); alfa:=alfa+pi/4; x[2]:=320+round(100*cos(alfa)); y[2]:=240+round(100*sin(alfa)); alfa:=alfa+pi/4; x[3]:=320+round(100*cos(alfa)); y[3]:=240+round(100*sin(alfa)); alfa:=alfa+pi/4; x[4]:=320+round(100*cos(alfa)); y[4]:=240+round(100*sin(alfa)); alfa:=alfa+pi/4; x[5]:=320+round(100*cos(alfa)); y[5]:=240+round(100*sin(alfa)); alfa:=alfa+pi/4; x[6]:=320+round(100*cos(alfa)); y[6]:=240+round(100*sin(alfa)); alfa:=alfa+pi/4; x[7]:=320+round(100*cos(alfa)); y[7]:=240+round(100*sin(alfa));
|
alfa:=alfa+pi/4; x[8]:=320+round(100*cos(alfa)); y[8]:=240+round(100*sin(alfa));
MoveTo(x[8], y[8]); LineTo(x[1], y[1]); LineTo(x[2], y[2]); LineTo(x[3], y[3]); LineTo(x[4], y[4]); LineTo(x[5], y[5]); LineTo(x[6], y[6]); LineTo(x[7], y[7]); LineTo(x[8], y[8]); Readln; Closegraph; End.
|
144. Kub rasmini chizing, barcha yoqlari turli rangda bo‘lsin.
145*. Sariq rangli to‘g‘ri chiziq va markazlari shu to‘g‘ri chiziqda joylashgan qizil rangli 5 ta aylana chizing.
146*. Radiusi R ga teng chegarasi sariq rangli, ichi ko‘k rangli doira chizing.
Yechim:
Bu masalani turli xil usullarda hal etish mumkin. Masalan:
SetColor(yellow) protsedurasi yordamida chegarasi tanlanlangan aylana Circle(320,240,R) protsedurasi yordamida markazda chiziladi. Uning ichini bo‘yash uchun rang va usulni SetFillStyle(1,blue) protsedurasi yordamida tanlab, FloodFill(320,240,yellow) yordamida bo‘yaladi.
SetColor(yellow) protsedurasi yordamida chegarasi, SetFillStyle(1,blue) protsedurasi yordamida ichini bo‘yash uchun rang va usul tanlanlangan doira FillEllipse(320,240,R,R) protsedurasi yordamida markazda chiziladi.
|
Dasturi (Circle):
Uses graph;
Var gd, gm, R: integer; begin
Write(‘Radiusni kiriting: ‘); Readln(R); gd:=0; InitGraph(gd, gm,'');
SetColor(yellow);
Circle(320,240,100);
SetFillStyle(1,blue);
FloodFill(320,240,yellow);
Readln; CloseGraph; end.
|
Dasturi (FillEllipse): Uses Graph;
var gd, gm, R: integer;
Begin
Write(‘Radiusni kiriting: ‘); Readln(R);
gd:= 0; InitGraph(gd, gm, '');
SetColor(yellow);
SetFillStyle(1,blue);
FillEllipse(320,240,R,R);
Readln; CloseGraph; end.
|
147*. Yonma-yon joylashgan tegib turadigan uch xil rangli doira chizing 148*. Uchalasi bir-biriga tegib turadigan uch xil rangli doira chizing.
149*. Olimpiada emblemasini eslatuvchi 5 ta halqa rasmini chizing. 150*. Oy rasmini chizing.
Yechim:
Ekranda oq rangli oy ko‘rinishini hosil qilish uchun ichi oqqa bo‘yalgan doira bilan ichi fon rangi, ya’ni qoraga bo‘yalgan doira kesishtiriladi. Shunda birinchi doiraning kerakmas qismi qora rangda aks etgani uchun ko‘rinmaydi va oy ko‘rinishi hosil bo‘ladi. Doirani oq gardishi ko‘rinmasligi uchun chegara rangini ham fon rangida olinishi muhim.
|
Dasturi:
Uses graph;
Var gd, gm: integer;
Begin gd:=0; Initgraph(gd,gm,'');
Setcolor(0); Setfillstyle(1,15);
Fillellipse(200,200,50,50);
Setfillstyle(1,0 );
Fillellipse(225,200,45,45);
Readln; CloseGraph; End.
|
Natijaning ekrandagi ko‘rinishi:
|
|
|
|
151*. Nur sochib turgan quyosh rasmini chizing.
152*. Dengiz uzra nur taratayotgan Quyosh rasmini chizing. Dengizni chizishda yoy chizish protsedurasidan foydalaning.
Yechim:
Ekran foniga och billur rang (kodi 11) tanlanib, radiusi 50 piksel bo‘lgan chegarasi va ichi sariq rangli doira chiziladi: Setcolor(14); Setfillstyle(1,14); Fillellipse(510,100,50,50). Quyosh nurlarini chizish uchun quyosh markazidan chiquvchi chiziqlar olinishi hisoblashni osonlashtirgani uchun Line(500,100, X, Y); protsedurasi yordamida X va Y larni tanlash orqali chiziladi.
Mavjlanayotgan dengizni chizish uchun Ellipse(X,Y,BB,OB,XR,YR) protsedurasidan foydalaniladi, bu yerda markazi (X,Y) nuqtada, x va y o‘qlari bo‘yicha radiuslari mos ravishda XR va YR ga teng ellipsning BB burchagidan OB burchagigacha bo‘lgan yoyini chizadi. Burchak gradus o‘lchov birligida beriladi. Dengizga rang berish uchun Floodfill protsedurasidan foydalaniladi.
|
Dasturi:
Uses graph;
Var gd, gm: integer;
Begin gd:=0; Initgraph(gd, gm, '');
Setbkcolor(11); Setfillstyle(1,yellow);
Setcolor(yellow); Fillellipse(510,100,50,50); line(510,100,510,10); line(510,100,510,190); line(510,100,420,100); line(510,100,600,100); line(510,100,445,40); line(510,100,575,40); line(510,100,445,150); line(510,100,575,150);
Setcolor(blue); Setfillstyle(1, blue); ellipse(40,300,22,145,70,45); ellipse(193,265,200,340,95,50); ellipse(340,307,40,146,70,45); ellipse(455,300,22,148,70,45); ellipse(608,265,200,340,95,50); Floodfill(40,340,blue); Readln; CloseGraph; End.
|
Natijaning ekrandagi ko‘rinishi:
|
153*. Ekranni sariq gorizontal chiziqlar bilan to‘ldiring.
Yechim:
Bu masalani turli xil usullarda hal etish mumkin. Masalan:
To‘g‘ri to‘rtburchak chizib, uning ichini bo‘yash uchun rang va usulni SetFillStyle(usul,rang); protsedurasi yordamida tanlash orqali, bu yerda rang – tanlanayotgan rang kodi, usul – bo‘yash usuli. Bar(X1,Y1,X2,Y2) protsedurasi ekranda yuqori chap burchagi (X1,Y1) va quyi o‘ng burchagi (X2,Y2) koordinatali nuqtalarda bo‘lgan, ichi joriy rang va joriy usulda bo‘yalgan to‘g‘ri to‘rtburchak chizadi. Joriy rangni sariq, ya’ni Yellow (kodi 14), bo‘yash usulini 2, ya’ni qalin gorizontal chiziqlar bilan to‘ldirish, X1=0, Y1=0, X2=639, Y2=479 kabi tanlash masala yechimini beradi;
Bar3D(X1,Y1,X2,Y2,a,b) protsedurasi joriy rang va joriy usulda bo‘yalgan parallelepiped chizadi, bu yerda a – parallelepiped yon tomonining uzunligi, b esa mantiqiy ifoda bo‘lib, uning qiymati “rost” bo‘lsa parallelepipedning yuqori qirrasi chiziladi, “yolg‘on” bo‘lsa chizilmaydi. Shuning uchun SetFillStyle(2,14); a=0, b=False, X1=0, Y1=0, X2=639, Y2=479 kabi tanlash masala yechimini beradi.
|
Dasturi (Bar):
uses graph; Var
gd, gm: integer;
begin gd := 0; InitGraph(gd, gm, ''); setfillstyle(2, yellow);
Bar(0,0,639,479);
Readln; CloseGraph; end.
|
Dasturi (Bar3D):
Uses Graph; Var
gd, gm: integer;
Begin gd:= 0; InitGraph(gd, gm, '');
SetFillStyle(2,14);
Bar3D(0,0,639,479,0,False);
Readln; CloseGraph; end.
|
154*. Ekranni teng to‘rt bo‘lakka bo‘lib, ularni mos ravishda qizil, sariq, yashil va ko‘k ranglarga bo‘yang.
Yechim:
Ekranning o‘lchamlari 0..639x0..479 bo‘lgani uchun to‘g‘ri to‘rtburchaklar
yordamida 4 bo‘lakka bo‘lish mumkin. To‘g‘ri to‘rtburchaklar diagonallari uchlari koordinatalari quyidagicha aniqlanadi: (0,0) va (320,240); (320,0) va (639,240); (0,240) va (320,479); (320,240) va (639,479).
To‘g‘ri to‘rtburchaklar chizish uchun Bar(X1,Y1,X2,Y2); chegarasi rangini belgilash uchun SetColor(rang), ichini bo‘yash uchun SetFillStyle(usul,rang); protsedurasidan foydalanish qulay.
|
Dasturi:
Uses graph;
Var gd, gm:integer;
Begin
gd := 0; InitGraph(gd, gm, ''); setfillstyle(1,red); bar(0,0,320,240); setfillstyle(1,yellow); bar(320,0,639,240); setfillstyle(1,green); bar(0,240,320,479); setfillstyle(1,blue); bar(320,240,639,479); Readln; CloseGraph; end.
|
Natijaning ekrandagi ko‘rinishi:
|
155*. Ekranning to‘rtta burchagida eni 60 va bo‘yi 40 ga teng qizil rangli to‘rtburchaklar chizuvchi dastur tuzing.
Yechim:
Ekranning o‘lchamlari 0..639x0..479 bo‘lgani uchun to‘g‘ri to‘rtburchaklar diagonallari uchlari koordinatalari quyidagicha aniqlanadi: chap yuqori burchakdagi to‘g‘ri to‘rtburchakning diagonallari uchlari (0,0) va (60,40); o‘ng yuqori burchakdagi to‘g‘ri to‘rtburchakning diagonallari uchlari (639–60,0)=(579,0) va (639,40); chap quyi burchakdagi to‘g‘ri to‘rtburchakning diagonallari uchlari (0,479–40)=(0,439) va (60,479); o‘ng quyi burchakdagi to‘g‘ri to‘rtburchakning diagonallari uchlari (639–60,479–40)=(579,439) va (639,479).
To‘g‘ri to‘rtburchaklar chizish uchun Bar(X1,Y1,X2,Y2); chegarasi rangini belgilash uchun SetColor(rang), ichini bo‘yash uchun SetFillStyle(usul,rang); protsedurasidan foydalanish qulay.
|
Dasturi:
Uses graph; Var
gd, gm:integer; Begin
gd := 0; InitGraph(gd, gm, ''); setcolor(4); setfillstyle(1, red); bar(0,0,60,40); bar(579,0,639,40); bar(0,439,60,479); bar(579,439,639,479); Readln; CloseGraph; end.
|
Natijaning ekrandagi ko‘rinishi:
|
156*. Ekranni teng 4 bo‘lakka bo‘lib, har birini markazida radiusi kiritilgan A soniga teng chegaralari va ichi turli rangli doiralar chizing.
157*. Mustaqillik maydonidagi O‘zbekiston xaritasi aks ettirilgan monument rasmini xaritasiz chizing.
158*. Mustaqillik maydonidagi O‘zbekiston xaritasi aks ettirilgan monument rasmini xaritasiz chizing va ichiga “O‘ZBEKISTON RESPUBLIKASI” matnini tagma-tag yozing.
Yechim:
Chiziq rangi SetColor(Rang) protsedurasi, formasi va qalinligi SetLineStyle(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) yurgich 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;
|
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;
Daraxt rasmini chizing.
Qushlar rasmini chizing.
165*. Tog‘lar rasmini chizing.
Uycha, daraxt, qush, quyosh va tog‘ aks etgan kun manzarasini chizing.
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.
Yechim:
a
Chizmaga asosan a=2∙R yoki R= . Kvadratning chap yuqori
2 a
qirrasi koordinatasi (x, y) bo‘lsa, u holda quyi o‘ng qirrasi (x+a, y+a) bo‘ladi. Demak, aylana markazi koordinatalari kesmani teng a ikkiga bo‘lish qoidasiga asosan quyidagicha bo‘ladi:
x x a y y a 2x a 2 y a a a .
, , x , y
2 2 2 2 2 2
Masalan, agar a=100, x=100 va y=80 deb olinsa, aylana markazi koordinatalari (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; InitGraph(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:
|
|
|
Do'stlaringiz bilan baham: |