19-bilet
19,1// C++ da grafik tasvirlarni harakatlantirish (Animatsiya)Chiziq rangini tanlash - setcolor ( rang);
Nuqta hosil qilish - putpixel (x o’qi bo`yicha koordinata, y o’qi bo`yicha koordinata, rang);Masalan: putpixel (150,120, 9);To`g`ri chiziq hosil qilish – l`121`ine (x1, y1, x2, y2); x1, y1- chiziq boshi koordinatasi; x2, y2 - chiziq oxiri koordinatasi. Masalan: setcolor ( 10 ); line (120,100,220,100); Siniq chiziqlar hosil qilish setcolor ( 12 ); - chiziq rangi moveto (x1, y1); - chiziq boshlanish koordinatasi lineto (x2, y2); - chiziq singan qismi koordinatasi lineto (x3, y3); - chiziq oxiri koordinatasito`rtburchak hosil qilish - rectangle (x1, y1, x2, y2); x1, y1- to’rtburchak diogonali boshi koordinatasi; x2, y2 - to’rtburchak diogonali oxiri koordinatasi. Masalan: setcolor ( 10 ); rectangle (100, 100, 200, 200); to`rtburchak soha hosil qilish setfillstyle ( 1, 12 ); - stil va rangni tanlash bar (x1, y1, x2, y2); - to‘rtburchak soha chizish; x1, y1- to’rtburchak diogonali boshi koordinatasi; x2, y2 - to’rtburchak diogonali oxiri koordinatasi. Aylana chizish - circle ( x, y, R ); x, y – aylana markazi koordinatasi, R – aylana radiusi. Masalan: setcolor ( LIGHTRED ); circle ( 120,130,50 ); Grafikda matn xosil qilish setcolor ( 9 ); outtextxy ( x, y, "Olim" ); x, y – matn hosil bo’ladigan koordinata.
Namuna. Quyidagi y=2arctg(x)-x+3 funksiya grafigini x[-5;5] oraliqda n=0.0001 qadam bilan chizing. Uning C++ tilidagi dasturi quyidagicha. #include#include#include#includeint main() {float y,x; float z,w;initwindow(640,480); //Oyna o‘lchamimoveto(320,0); //koordinata gorizontal o‘qi boshilineto(320,480); //koordinata gorizontal o‘qi oxiri moveto(0,240); //koordinata vertikal o‘qi boshilineto(640,240); //koordinata vertikal o‘qi oxiriz=320; w=240; for(x=-5;x<=5;x+=0.0001) { y=2*atan(x)-x+3; moveto(z,w);putpixel(320+x*50,240-y*50,14); z=320+x*50; w=240-y*50;} getch();closegraph();}
Do'stlaringiz bilan baham: |