Kreisbild aus Punkten
von heinz- SNIPPET_DESC:
- Kreisbild aus Punkten
- SNIPPET_CREATION_TIME:
- 06.01.2019 18:56:36
- SNIPPET_PRUNE_TIME:
- Unendlich
- SNIPPET_TEXT:
-
- /*
- z2z
- 06.01.2019
- */
- #include <stdlib.h>
- #include <time.h>
- #include <SDL.h>
- #include "SDL_gfxPrimitives.h"
- // Bildschirmdaten
- const int bX=1024;
- const int bY=768;
- /*
- const int bX=2000;
- const int bY=2000;
- */
- const int bF=32;
- // Grafik-Arbeitsbereich
- SDL_Surface* display=NULL;
- // Ereignisstapel fuer Tastatur- und Maus-Ereignisse
- SDL_Event ereignis;
- const double Pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
- int main()
- {
- srandom(time(0));
- // SDL
- if(SDL_Init(SDL_INIT_VIDEO)<0)
- {
- fprintf(stderr,"\aSDL konnte nicht initialisiert werden: %s\n",SDL_GetError());
- exit(1);
- }
- atexit(SDL_Quit);
- display=SDL_SetVideoMode(bX,bY,bF,SDL_SWSURFACE);
- if(display==NULL)
- {
- fprintf(stderr,"\aKonnte kein Display %ix%ix%i erzeugen: %s\n",bX,bY,bF,SDL_GetError());
- exit(1);
- }
- for(int z=0 ; z<10000 ; z++)
- {
- float winkel=(float)(rand()%36000000)/100000.0;
- float radius= (rand()% 2000) / 10.0;
- float x = sin( winkel * (Pi / 180.0) ) * radius;
- float y = cos( winkel * (Pi / 180.0) ) * radius;
- pixelColor(display,x+bX/2,y+bY/2,0xffffffff);
- }
- SDL_Flip(display);
- // Warte auf Taste oder Maus-Taste
- bool programm_ende=false;
- while(!programm_ende)
- {
- while(SDL_PollEvent(&ereignis))
- {
- if(ereignis.type==SDL_MOUSEBUTTONDOWN||ereignis.type==SDL_KEYDOWN)
- {
- programm_ende=true;
- }
- }
- SDL_Delay(1);
- }
- SDL_FreeSurface(display);
- }
Quellcode
Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN