B. J. Boltayev, A. R. Azamatov, G. A. Azamatova, B. S. Xurramov nazariya, algoritm, dastur toshkent 2013
Download 372.89 Kb.
|
Algoritmlash va dasturlash asoslari seriyasidan Kitob – II b. J.-fayllar.org
FloodFill(A,B,D) protsedurasi tanlangan rangni shakl ichiga “quyish” (MS
Paint dasturidagi kabi) uchun xizmat qiladi, bu yerda (A,B) shakl ichidagi biror nuqta, D chegara chizig‘i rangi. ۩ . Svetofor rasmini chizuvchi dastur tuzing. Yechim:
1) Bar(X1,Y1,X2,Y2) protsedurasi yordamida 2 ta to‘g‘ri to‘rtburchak, Fil- lEllipse(X,Y,XR,YR) protsedurasi yordamida 3 ta doira chizib (doira chizish uchun XR=YR bo‘lishi kerak), ularning ichini bo‘yash uchun rang va usulni SetFillStyle(usul,rang); protsedurasi yordamida tanlash orqali. Bo‘yash usuli 1 deb olinadi, chunki shakl ichi to‘liq bo‘yaladi. Ranglar esa doiralar uchun 4 (qizil), 14 (sariq), 2 (yashil) tanlanadi. Dasturda doiralar chegara chizig‘i rangi Setcolor(rang) protsedurasi yordamida tanlanmagani uchun Paskal dasturi che- gara rangini oq (kodi 15) rangda chizadi. 2) To‘g‘ri to‘rtburchaklar chizish uchun Rectangle(X1,Y1,X2,Y2) protsedurasidan va doiralar chizish uchun Circle(X,Y,R) protsedurasidan foyda- lanish mumkin. SetFillStyle(usul,rang); protsedurasidan bu shakllarni ichini bo‘yash usuli va rangini tanlashda, tanlangan rangni shakl ichiga “quyish” (MS Paint dasturidagi kabi) uchun FloodFill(A,B,D) protsedurasidan foydalanish mumkin, bu yerda (A,B) shakl ichidagi biror nuqta, D chegara chizig‘i rangi. Dasturda chegara chizig‘i rangi Setcolor(rang) protsedurasi yordamida tan- lanmagan bo‘lsa, u holda Paskal dasturi chegara rangini oq (kodi 15) rangda chi- zadi. Agar shakl ichini bo‘yashda FloodFill(A,B,D) protsedurasidan foydala- nayotganda (A,B) nuqta shakl ichiga tegishli bo‘lmasa, u holda rang MS Paint dasturidagi yopiq sohani bo‘yash ( ) uskunasi yordamida bo‘yagandagi kabi rang “yoyilib” ketadi. Dasturi: Uses graph; Var gd, gm: Integer; Begin gd := 0; InitGraph(gd, gm, ''); setfillstyle(1,6); bar(150,10,210,190); SetFillStyle(1,red); fillEllipse(180,40,30,30); SetFillStyle(1,14); fillEllipse(180,100,30,30); SetFillStyle(1,2); fillEllipse(180,160,30,30); setfillstyle(1,6); bar(175,190,185,300); Readln; CloseGraph; end. Natijaning ekrandagi ko‘rinishi: Dasturi (Floodfill): Uses graph; 78
gd, gm: integer; Begin gd:=0; InitGraph(gd, gm, ''); setfillstyle(1,6); rectangle(150,10,210,190); Floodfill(160,100,15); SetFillStyle(1,4); circle(180,40,25); Floodfill(180,40,15); SetFillStyle(1,14); circle(180,100,25); Floodfill(180,100,15); SetFillStyle(1,2); circle(180,160,25); Floodfill(180,160,15); setfillstyle(1,6); rectangle(175,190,185,300); Floodfill(180,200,15); Readln; CloseGraph; End. Download 372.89 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling