#include #include #include #include #define X 740 #define Y 640 ///функция рисования координатной плоскости void koordinatnaya_ploskost(SDL_Surface *screen , double razmer) { SDL_Rect ramka={30, 30, X-60, Y-60 }; SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)-100); SDL_FillRect(screen, &ramka, SDL_MapRGB(screen->format, 255, 255, 255)); int cx=X/2, cy=Y/2; Draw_VLine(screen ,X/2, 40, Y-40, SDL_MapRGB(screen->format, 0,0,0)); ///ось Y Draw_HLine(screen ,40, Y/2, X-40, SDL_MapRGB(screen->format, 0,0,0)); ///ось X for(int cord_x=X/2+razmer; cord_xformat, 192,192,192)); Draw_VLine(screen ,cx , 40, Y-40, SDL_MapRGB(screen->format, 192,192,192)); } for(int cord_y=Y/2+razmer; cord_yformat, 192,192,192)); Draw_HLine(screen ,40, cy, X-40, SDL_MapRGB(screen->format, 192,192,192)); } } ///функция расставления координат void koordinati(SDL_Surface *screen,int razmer) { int razmer_ttf=16, cx=X/2, temp, temp1, f=8; char pol_cord[]="987654321"; SDL_Rect cord_text={X/2,10,16,16}, cord_text_snizu={20,Y-30,16,16}; SDL_Surface *text, *otr; TTF_Font* font=TTF_OpenFont("shrifts/ttf3.ttf",razmer_ttf); SDL_Color color={100, 50, 25}; otr=TTF_RenderText_Solid(font, "-" ,color); ///расставление координат сверху и снизу for(cord_text.x=X/2+razmer*2; cord_text.x40 && b>40 ) Draw_FillEllipse(screen, -a+kostil , b+2 , 1, 1, SDL_MapRGB(screen->format, 255,0,0)); x+=0.0001; kostil=0; } } int main ( int argc, char** argv ) { if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } TTF_Init(); atexit(SDL_Quit); SDL_Surface *screen = SDL_SetVideoMode(X, Y, 16, SDL_HWSURFACE|SDL_DOUBLEBUF); if ( !screen ) { printf("Unable to set 640x480 video: %s\n", SDL_GetError()); return 1; } bool done = false; int razmer=30; while (!done) { SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: done = true; break; case SDL_KEYDOWN: { if (event.key.keysym.sym == SDLK_ESCAPE) done = true; if(event.key.keysym.sym == SDLK_UP) if((razmer+10)10 && (razmer-10)>10) razmer-=5; break; } } } koordinatnaya_ploskost(screen , razmer); koordinati(screen, razmer); grafik(screen, razmer); SDL_Flip(screen); } TTF_Quit(); return 0; }