• Amaliy vazifalar: 1.Uy rasmini chizish dasturini tuzing. 2. Mashina chizish dasturini tuzing. 3. Geometrik figuralarni rasmini chizish dasturini tuzing.
  • Fizik jarayonlarni kompyuterda modellashtirish




    Download 15,08 Mb.
    bet107/135
    Sana22.05.2024
    Hajmi15,08 Mb.
    #250347
    1   ...   103   104   105   106   107   108   109   110   ...   135
    Bog'liq
    Fizik jarayonlarni kompyuterda modellashtirish

    circle (50, 50, 35); {radusi 35 bo’lgan aylana chizish}
    floodfill (50, 50, 4); {aylana ichiga rang bilan to’ldirish, bo’yaladigan chegara rangi rangli qalam bilan bir xil bo’lishi kerak}
    Takrorlash chun materiallar:










    RANGLAR PALITRASI:

    256·256·256 = 16 777 216

    Amaliy vazifalar:
    1.Uy rasmini chizish dasturini tuzing.
    2. Mashina chizish dasturini tuzing.
    3. Geometrik figuralarni rasmini chizish dasturini tuzing.
    4. Ixtiyoriy rasmni chizish dasturini tuzing.
    Amaliy ish uchun topshiriqlar:
    Quyidagi dasturni kiriting va rasmni hosil qiling:
    Tabiat quynidagi uyni va u yerda turgan darahtni chizish dasturi.

    1. #include

    2. #include

    3. #include

    4. class Fon

    5. {

    6. public:

    7. Fon();

    8. };

    9. Fon::Fon()

    10. {

    11. setfillstyle(6,GREEN);

    12. bar(0,0,getmaxx(),getmaxy());

    13. setfillstyle(1,1);

    14. bar(0,0,getmaxx(),150);

    15. setfillstyle(1,14);

    16. fillellipse(600,50,50,50);

    17. setfillstyle(1,1);

    18. fillellipse(500,390,200,50);

    19. };

    20. class Tree

    21. {

    22. int x,y;

    23. public:

    24. Tree(int X,int Y) {x=X;y=Y;}

    25. void ShowTree();

    26. };

    27. /*Uy sinfini qo’shamiz*/

    28. class Dom

    29. {

    30. int x,y; //Uyni chizishni boshlang’ich koordinatalari

    31. public:

    32. Dom(int X,int Y) {x=X;y=Y;} //Конструктор класса принимает параметры

    33. void ShowHome(); //Chizuvchi Uy klassi metodi

    34. };

    35. void Tree::ShowTree()

    36. {

    37. y=y+getmaxy();

    38. //Рисую ствол и ветви

    39. moveto(x,y-150); lineto(x,y-300);

    40. moveto(x,y-(150+75)); lineto(x+70,y-(150+75)-70);

    41. moveto(x+20,y-(150+75)-20); lineto(x+70,y-(150+75)-20);

    42. moveto(x+40,y-(150+75)-40); lineto(x+45,y-(150+75)-70);

    43. moveto(x,y-(150+75)-40); lineto(x+20,y-(150+75)-65);

    44. moveto(x,y-(150+75)-10); lineto(x-30,y-(150+75)-20);

    45. moveto(x,y-(150+75)-30); lineto(x-25,y-(150+75)-40);

    46. //Рисую листву

    47. setfillstyle(1,GREEN);

    48. fillellipse(x,y-300,5,5);

    49. fillellipse(x+20,y-290,7,7);

    50. fillellipse(x+45,y-300,3,7);

    51. fillellipse(x+75,y-300,10,10);

    52. fillellipse(x+20,y-255,5,10);

    53. fillellipse(x+70,y-247,10,10);

    54. fillellipse(x-30,y-247,10,10);

    55. fillellipse(x-30,y-267,7,7);

    56. fillellipse(x-15,y-270,5,9);

    57. }

    58. /*Uyni chizish metodi klassdan tashqarida berilgan */

    59. void Dom::ShowHome()

    60. {

    61. setfillstyle(3,3); //Rang berish stilini o’rnatish

    62. bar3d(x-150,y,x-50,y-120,2,1); //Uy fasadini chizamiz

    63. //Треугольная часть крыши

    64. int poly[8]; //3 вершины*2 = 6. Tugatish nuqtasi kerak 6+2 =8

    65. poly[0]=x-155; poly[1]=y-120; //A(x,y)

    66. poly[2]=x-100; poly[3]=y-200; //B(x,y)

    67. poly[4]=x-45; poly[5]=y-120; //C(x,y)

    68. poly[6]=poly[0];poly[7]=poly[1]; //Konturni tugatish

    69. setfillstyle(5,1); //Rang berishni o’rnatish

    70. fillpoly(3,poly); //Ichi quyilgan uchburchakni chizamiz

    71. //Tomning parallelogram qismi

    72. /*Parallelogramm uchun nuqtalarni qidirish

    73. outtextxy(x-45,y-120,"A");

    74. outtextxy(x+100,y-120,"B");

    75. outtextxy(x-100,y-200,"C");

    76. outtextxy(x+100-45,y-200,"D"); */

    77. int poly1[10]; // parallelogrammning 4ta nuqtasi*2=8 + biriktirish nuqtasi =8+2=10

    78. poly1[0]=x-45; poly1[1]=y-120; //A

    79. poly1[2]=x+100; poly1[3]=y-120; //B

    80. poly1[4]=x+100-45; poly1[5]=y-200; //D

    81. poly1[6]=x-100; poly1[7]=y-200; //C

    82. poly1[8]=poly1[0]; poly1[9]=poly1[1]; //Konturni biriktirish

    83. setfillstyle(2,1);//УстанRang stilini o’rnatishовка стиля заливки

    84. fillpoly(4,poly1); //Ichi bo’yalgan to’rtburchakni chizish

    85. /*Uyning yon devori*/

    86. /*Поиск точек

    87. outtextxy(x-45,y,"A");

    88. outtextxy(x+100,y,"B");

    89. outtextxy(x+100,y-120,"C");

    90. outtextxy(x-45,y-120,"D"); */

    91. setfillstyle(10,2); //Rang stilini o’rnatish

    92. bar3d(x-45,y,x+100,y-120,1,1); //Ichi bo’yalgan to’rtburchak

    93. //Qidirish va oynalarni chizish

    94. /*outtextxy(x-30,y-50,"A");

    95. outtextxy(x-30,y-80,"B");

    96. outtextxy(x,y-80,"C"); */

    97. setfillstyle(1,7); //Rang stilini o’rnatish

    98. bar3d(x-30,y-50,x,y-80,1,1); //Birinchi oynani chizish

    99. /*outtextxy(x+15,y-50,"A");

    100. outtextxy(x+45,y-80,"B");*/

    101. bar3d(x+15,y-50,x+45,y-80,1,1); //Ikkinchi oynani chizish

    102. /*outtextxy(x+60,y-50,"A");

    103. outtextxy(x+90,y-80,"B"); */

    104. setfillstyle(5,YELLOW); //Rang quyush stilini o’rnatish

    105. bar3d(x+60,y-50,x+90,y-80,1,1); //Uchinchi oynani chizish

    106. /*Koordinatalarni qidirish va eshiklarni chizish

    107. outtextxy(x-70,y,"A");

    108. outtextxy(x-100,y-70,"B");*/

    109. setfillstyle(2,6); //Rang berish stilini o’rnatish

    110. bar3d(x-70,y,x-100,y-70,1,1); //Eshikni chizish

    111. }

    112. int main()

    113. {

    114. int gm,gd=DETECT;

    115. initgraph(&gd,&gm,"");

    116. Fon Fon1; //KOnstruktor yordamida fonni chizish

    117. Tree Derevo1(50,50); // Daraht tipli ob’ektni chizish

    118. Derevo1.ShowTree(); //Darahtni chizish

    119. Dom Dom1(400,300); //Uy tipli ob’ektni yaratish

    120. Dom1.ShowHome(); //Uyni chizish

    121. cin.get();

    122. closegraph();

    123. return 0;

    124. }



    Download 15,08 Mb.
    1   ...   103   104   105   106   107   108   109   110   ...   135




    Download 15,08 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Fizik jarayonlarni kompyuterda modellashtirish

    Download 15,08 Mb.