Exemplo n.º 1
0
void filledEllipse(void* s_in,
		   int x, int y, int rx, int ry,
                   int r, int g, int b, int a) 
{
    SDL_Renderer* s = (SDL_Renderer*)s_in;
    filledEllipseRGBA(s, x, y, rx, ry, r, g, b, a);
}
Exemplo n.º 2
0
void ElipseR(int x, int y, int radx, int rady,
             unsigned char r, unsigned char g, unsigned char b, GRF_Imagen img)
{
    GRF_Imagen ptr = ((img==0) ? ventana : img);
    filledEllipseRGBA(ptr, x, y, radx, rady, r, g, b,255);
    if (img==0 && dibujo_activo) SDL_UpdateRect(ptr, x-radx, y-rady, radx*2+1, rady*2+1);
}
Exemplo n.º 3
0
/*!
 * @breif Fill ellipse
 *  fillEllipse({x, y, width, height}, color)
 *  fillEllipse(x, y, width, height, color)
 */
static int32_t
luaSDL_fillEllipse(
	lua_State *L
)
{
	SDL_Surface *surface;
	gp_rect_t rect;
	gp_color_t color;

	surface = (SDL_Surface *) lua_touserdata(L, 1);
	if (!lua_istable(L, 2)) { /* number mode */
		rect.x = (int16_t)lua_tointeger(L, 2);
		rect.y = (int16_t)lua_tointeger(L, 3);
		rect.width = (int16_t)lua_tointeger(L, 4);
		rect.height = (int16_t)lua_tointeger(L, 5);
		color = luaSdl_toColor(L, 6);
	}
	else {
		rect = luaSdl_toRect(L, 2);
		color = luaSdl_toColor(L, 3);
	}

	filledEllipseRGBA(surface, rect.x + rect.width/2, rect.y + rect.height/2, rect.width/2, rect.height/2, color.red, color.green, color.blue, color.alpha);
	return 0;
}
Exemplo n.º 4
0
/* Interface to SDL_gfx version for drawing circles  */
int Surface::DrawCircle(int x0, int y0, int r, int color, int fill) {
  int red = (color >> 16) & 0xff;
  int green = (color >> 4) & 0xff;
  int blue = color & 0xff;
  if (fill)
    filledEllipseRGBA(surf, x0, y0, r, r, red, green, blue, 255);
  else
    ellipseRGBA(surf, x0, y0, r, r, red, green, blue, 255);
  return 0;
}
Exemplo n.º 5
0
int Sprite::drawFilledEllipse(Vector2 *center, int rx, int ry, int r, int g, int b, int a, int translation, Screen *screen) {
	Vector2 *scrolledCenter;
	scrolledCenter = ScrollManager::getInstance()->scrollVector(center);

	int ret = filledEllipseRGBA(screen->getTopScreen(), scrolledCenter->x + translation, scrolledCenter->y + translation, rx, ry, r, g, b, a);


	delete scrolledCenter;

	return ret;
}
Exemplo n.º 6
0
void SDLDebugDraw::DrawSolidCircle(const b2Vec2 &center, float32 radius, const b2Vec2 &axis, const b2Color &color) {
    Sint16 x;
    Sint16 y;

    b2Vec2 v = center; //((vertices[i] + camera.wpos)*camera.getScale()) ;
    v*= camera;
    
    x = (Sint16) v.x;
    y = (Sint16) v.y;

    filledEllipseRGBA(App::get()->ren->renderer,x, y, radius*30, radius*30, color.r, color.g, color.b, color.a);
}
Exemplo n.º 7
0
CAMLprim value ml_filledEllipseRGBA(value dst,value p,value rp, value col,value alpha)
{
  SDL_Surface *sur= SDL_SURFACE(dst);
  SDL_Rect prect,rprect;
  SDL_Color c;
  int r;

  SDLRect_of_value(&prect,p);
  SDLRect_of_value(&rprect,rp);
  SDLColor_of_value(&c,col);
  r=filledEllipseRGBA(sur,prect.x,prect.y,rprect.x,rprect.y,c.r,c.g,c.b, Int_val(alpha));

  return Val_bool(r);
}
void CirculoDibujable::dibujar(SDL_Renderer* renderer,int corrimientoX, int corrimientoY, float escalaZoom, int anchoPx, int altoPx) {
	filledEllipseRGBA(renderer,(this->posicion.x * escalaZoom) - corrimientoX,(this->posicion.y * escalaZoom) - corrimientoY,this->radioHorizontal * escalaZoom,this->radioVertical * escalaZoom,this->getColor()[0],this->getColor()[1],this->getColor()[2],255);
}
Exemplo n.º 9
0
void desenha(SDL_Surface * superficie, Grafo * g,bool flag,bool flagPeso)
{
	SDL_Rect ret;
	int nvertices;
	Nodo *n, *n1;
	TTF_Font* fonte = TTF_OpenFont("airstrip.ttf", 12);

	SDL_Color foregroundColor = { 200, 200, 200 };

	SDL_Surface* textSurface;

	SDL_Rect textLocation;

	ret.w = superficie->w;
	ret.h = superficie->h;
	ret.x = 0;
	ret.y = 0;

	SDL_FillRect (superficie, &ret, SDL_MapRGB(superficie->format, 0, 0, 0));

	nvertices = g->getNumeroVert();

	for (int i=0; i < nvertices; i++){

		n = g->getId(i);

		for (int j=0; j < nvertices; j++){
			if (g->adj(i, j)) {
				n1 = g->getId(j);
				if (flagPeso)
				{
					double x,y;
					stringstream peso;
					x = ((n->getX()+METADE_LARG) + (n1->getX()+METADE_LARG))/2;
					y = ((n->getY()+METADE_ALT) + (n1->getY()+METADE_ALT))/2;

					peso<< g->getPeso(i,j);

					textSurface = TTF_RenderText_Blended(fonte, peso.str().c_str(),foregroundColor);

					textLocation = { x, y, 0, 0 };

					SDL_BlitSurface(textSurface, NULL, superficie, &textLocation);
				}

				lineRGBA (superficie, n->getX() + METADE_LARG, n->getY() + METADE_ALT, n1->getX() + METADE_LARG, n1->getY() + METADE_ALT, 150, 150, 150, 255);
				desenhaFlecha (superficie, n, n1);
			}
		}

		if (flag)
		{
			textSurface = TTF_RenderText_Blended(fonte, n->getNome().c_str(), foregroundColor);
			
			textLocation = { n->getX() + ( METADE_LARG - RAIO ), n->getY() + ( METADE_ALT - RAIO - XFONTE), 0, 0 };

			SDL_BlitSurface(textSurface, NULL, superficie, &textLocation);
		}
			filledEllipseRGBA(superficie, n->getX() + 400, n->getY() + 275, RAIO, RAIO, 150, 150, 150, 255);

	}

	SDL_Flip(superficie);
	TTF_CloseFont(fonte);

	return;
}
Exemplo n.º 10
0
extern void
game_draw_filled_ellipse(Game *game, int x, int y, int rx, int ry, int r, int g, int b, int a)
{
    filledEllipseRGBA(game->screen, x, y, rx, ry, r, g, b, a);
}
Exemplo n.º 11
0
/*bool CollisionCheck( int PlayerX, int PlayerY, int PlayerSize, int EnemyX, int EnemyY, int EnemySize)
{
if (PlayerX > EnemyX + EnemySize)	return false;//(BOXA X VALUE > BOXB X VALUE + BOXB WIDTH VALUE)
if (PlayerX + EnemySize < EnemyX)	return false;
if (PlayerY > EnemyY + EnemySize)	return false;
if (PlayerY + EnemySize < EnemyY)	return false;
return true;

}*/
int main( int argc, char* args[])
{
	//******************************************************
	//					variable declaration
	//******************************************************

	SDL_Event event;
	//pixels per movement

	int X1 = 320;
	int Y1 = 240;

	bool bGameRunning = true;
	bool keysHeld [323] = {false};
	int screenX = 640;
	int screenY = 480;
	int XT0 = 0;
	int YT0 = 0;
	int XT1 = 0;
	int YT1 = 0;
	int XT2 = 0;
	int YT2 = 0;
	int XT3 = 0;
	int YT3 = 0;
	int XS0 = 0;
	int YS0 = 0;
	int XS1 = 0;
	int YS1 = 0;
	int XS2 = 0;
	int YS2 = 0;
	int RS = 0;
	srand ( time(NULL) );

	//******************************************************
	//					end variable declaration
	//******************************************************

	//The Images
	SDL_Surface* hello = NULL ;
	SDL_Surface* screen = NULL ;

	//Start SDL
	SDL_Init ( SDL_INIT_EVERYTHING ) ; //aprox 20

	//Set up screen
	screen = SDL_SetVideoMode ( 640, 480, 32, SDL_SWSURFACE );

	//load image
	//hello = SDL_LoadBMP ( "hello.bmp" );

	//*************************************************
	//					GAME LOOP
	//*************************************************

	while (bGameRunning == true) 
	{
		//***************************
		//			input
		//***************************
		if (SDL_PollEvent(&event))
		{
			if (event.type == SDL_QUIT)
			{
				bGameRunning = false;
			}
			if (event.type == SDL_KEYDOWN)
			{
				keysHeld[event.key.keysym.sym] = true;
			}
			if (event.type == SDL_KEYUP)
			{
				keysHeld[event.key.keysym.sym] = false;
			}
		}
		if ( keysHeld[SDLK_ESCAPE] )
		{
			bGameRunning = false;
		}

		//***************************
		//		   movement
		//***************************

		// initialize random seed:
		
		int XTMover = rand() % 640 + 1;
		int YTMover = rand() % 480 + 1;
		int x0 = XTMover;
		int y0 = YTMover;
		int shape = rand() % 3 + 1;
		int R = rand() % 255 + 1;
		int G = rand() % 255 + 1;
		int B = rand() % 255 + 1;
		RS = rand() % 10 + 20;


		if (shape == 1) // circle
		{
			filledEllipseRGBA(screen,x0,y0,RS,RS,R, G, B, 255);
		}
		if (shape == 2) // triangle
		{
			XT0 = x0;
			YT0 = y0;
			XT1 = XT0 - RS;
			YT1 = YT0 - RS;
			XT2 = XT0 - RS-RS-RS;
			YT2 = YT0 + RS;
			XT3 = XT0 + RS;
			YT3 = YT0 + RS;
			filledTrigonRGBA(screen,XT1,YT1,XT2,YT2,XT3,YT3,R, G, B, 255);
		}
		if (shape == 3) // square
		{
			XS0 = x0;
			YS0 = y0;
			XS1 = XS0 - RS;
			YS1 = YS0 - RS;
			XS2 = XS0 + RS;
			YS2 = YS0 + RS;
			boxRGBA(screen,XS1,YS1,XS2,YS2,R,G,B,255);
		}



		//***************************
		//	  collision detection
		//***************************

		//***************************
		//			drawing
		//***************************

		//Apply image to screen
		//SDL_BlitSurface (hello, NULL, screen, NULL );
		//SDL_FillRect(screen, &screen->clip_rect,SDL_MapRGB(screen->format, 255, 255, 255));
		//rectangleRGBA(screen,X,Y,X2,Y2,255,1,1,100);
		//boxRGBA(screen,X,Y,X2,Y2,R,G,B,A);
		//filledTrigonRGBA(screen,XT1,YT1,XT2,YT2,XT3,YT3,RE, GE, BE, A);
		//trigonRGBA(screen,X,Y,X2,Y2,X3,Y3,R, G, B, A);
		//filledEllipseRGBA(screen,X1,Y1,RS,RS,R, G, B, A);
		//ellipseRGBA(screen,x0,y0,15,15,RShield, GShield, BShield, A);


		//triforce code
		//filledTrigonRGBA(screen,X,Y,x2,y2,x3,y3,R, G, B, A);
		//filledTrigonRGBA(screen,x2,y2,X2,Y2,X4,Y4,R, G, B, A);
		//filledTrigonRGBA(screen,x3,y3,X4,Y4,X3,Y3,R, G, B, A);

		//small circle
		//ellipseRGBA(screen,X,Y,RX,RY,R, G, B, A);

		//test for flip errors
		if (SDL_Flip(screen) == -1)	
		{
			return 1;
		}

		//Pause
		SDL_Delay ( 25 );

		//bGameRunning = false;
	}


	//small circle
	//ellipseRGBA(screen,X,Y,RX,RY,R, G, B, A);

	//Pause
	SDL_Delay ( 2000 );

	//Free the loaded image
	SDL_FreeSurface( hello );

	//Quit SDL
	SDL_Quit();

	return 0;
}
Exemplo n.º 12
0
void gfx_filled_ellipse(int x, int y, int rx, int ry)
{
	filledEllipseRGBA(g_gfx_screen, x, y, rx, ry, g_gfx_color.r, g_gfx_color.g, g_gfx_color.b, 255);
}
Exemplo n.º 13
0
int main(int argc, char** argv)
{
  SDL_Rect r;

  /* Basic 32bit screen */
  SDL_Init(SDL_INIT_VIDEO);
  SDL_SetVideoMode(400, 400, 32, 0);

  /* Draw some white stripes as background */
  int y;
  for (y=0; y<400; y += 20) {
   boxRGBA(SDL_GetVideoSurface(), 0, y, 400, y+10, 255, 255, 255, 255);
  }

  /* Define masking bytes */
  Uint32 mask1 = 0xff000000;
  Uint32 mask2 = 0x00ff0000;
  Uint32 mask3 = 0x0000ff00;
  Uint32 mask4 = 0x000000ff;

  /* Solid color test */
  {
  SDL_Surface* s1 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask1, mask2, mask3, mask4);
  filledEllipseRGBA(s1, 0, 0, 100, 100, 255, 0, 0, 255); // red
  r.x = 0; r.y = 0;
  SDL_BlitSurface(s1, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s2 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask1, mask2, mask3, mask4);
  filledEllipseRGBA(s2, 0, 0, 100, 100, 0, 255, 0, 255); // green
  r.x = 0; r.y = 100;
  SDL_BlitSurface(s2, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s3 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask1, mask2, mask3, mask4);
  filledEllipseRGBA(s3, 0, 0, 100, 100, 0, 0, 255, 255); // blue
  r.x = 100; r.y = 0;
  SDL_BlitSurface(s3, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s4 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask1, mask2, mask3, mask4);
  filledEllipseRGBA(s4, 0, 0, 100, 100, 255, 255, 255, 255); // white
  r.x = 100; r.y = 100;
  SDL_BlitSurface(s4, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s5 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask4, mask3, mask2, mask1);
  filledEllipseRGBA(s5, 0, 0, 100, 100, 255, 0, 0, 255); // red
  r.x = 200; r.y = 0;
  SDL_BlitSurface(s5, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s6 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask4, mask3, mask2, mask1);
  filledEllipseRGBA(s6, 0, 0, 100, 100, 0, 255, 0, 255); // green
  r.x = 200; r.y = 100;
  SDL_BlitSurface(s6, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s7 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask4, mask3, mask2, mask1);
  filledEllipseRGBA(s7, 0, 0, 100, 100, 0, 0, 255, 255); // blue
  r.x = 300; r.y = 0;
  SDL_BlitSurface(s7, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s8 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask4, mask3, mask2, mask1);
  filledEllipseRGBA(s8, 0, 0, 100, 100, 255, 255, 255, 255); // white
  r.x = 300; r.y = 100;
  SDL_BlitSurface(s8, 0, SDL_GetVideoSurface(), &r);
  }

  /* Transparent color test */
  {
  SDL_Surface* s1 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask1, mask2, mask3, mask4);
  filledEllipseRGBA(s1, 0, 0, 100, 100, 255, 0, 0, 200); // red+trans
  r.x = 0; r.y = 200;
  SDL_BlitSurface(s1, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s2 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask1, mask2, mask3, mask4);
  filledEllipseRGBA(s2, 0, 0, 100, 100, 0, 255, 0, 200); // green+trans
  r.x = 0; r.y = 300;
  SDL_BlitSurface(s2, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s3 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask1, mask2, mask3, mask4);
  filledEllipseRGBA(s3, 0, 0, 100, 100, 0, 0, 255, 200); // blue+trans
  r.x = 100; r.y = 200;
  SDL_BlitSurface(s3, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s4 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask1, mask2, mask3, mask4);
  filledEllipseRGBA(s4, 0, 0, 100, 100, 255, 255, 255, 200); // white+trans
  r.x = 100; r.y = 300;
  SDL_BlitSurface(s4, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s5 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask4, mask3, mask2, mask1);
  filledEllipseRGBA(s5, 0, 0, 100, 100, 255, 0, 0, 200); // red+trans
  r.x = 200; r.y = 200;
  SDL_BlitSurface(s5, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s6 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask4, mask3, mask2, mask1);
  filledEllipseRGBA(s6, 0, 0, 100, 100, 0, 255, 0, 200); // green+trans
  r.x = 200; r.y = 300;
  SDL_BlitSurface(s6, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s7 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask4, mask3, mask2, mask1);
  filledEllipseRGBA(s7, 0, 0, 100, 100, 0, 0, 255, 200); // blue+trans
  r.x = 300; r.y = 200;
  SDL_BlitSurface(s7, 0, SDL_GetVideoSurface(), &r);

  SDL_Surface* s8 =
    SDL_CreateRGBSurface(0, 200, 200, 32, mask4, mask3, mask2, mask1);
  filledEllipseRGBA(s8, 0, 0, 100, 100, 255, 255, 255, 200); // white+trans
  r.x = 300; r.y = 300;
  SDL_BlitSurface(s8, 0, SDL_GetVideoSurface(), &r);
  }
  SDL_Flip(SDL_GetVideoSurface());

  printf ("Left - RGBA\nRight - ABGR\nTop - Solid\nBottom - Transparent\n");

  SDL_Event e;
  for(;;) {
    SDL_PollEvent(&e);
    SDL_Delay(1000);
    if ((e.type == SDL_QUIT) || (e.type == SDL_KEYDOWN)) break;
  }

}
Exemplo n.º 14
0
//Draw stuff
void C_GUI::Render_Map()
{
		SDL_Rect markerPosition = {0, 0};
		
		

		if(m_initMap == true){
			//Update X/Y pan
			m_mapPanX = -(m_playerPosition.x - SCREEN_WIDTH/2);

			p_zoomedScreen = zoomSurface(GUI_Img.getImage(0), m_zoomAxisX, m_zoomAxisY, SMOOTHING_ON);//make a copy of the zoomed map

			markerPosition.x = m_playerPosition.x*m_zoomAxisX + m_mapPanX;
			markerPosition.y = m_playerPosition.y*m_zoomAxisX + m_mapPanY;


			m_initMap = OFF;			
		}

		if(Controls.up && m_zoomAxisX < 1){//ZOOM OUT
			m_zoomAxisX+= .01;
			m_zoomAxisY+= .01;
			m_mouseOffsetX = 1 / (m_zoomAxisX * 2);
			m_mouseOffsetY = 1 / (m_zoomAxisY * 2);
			m_zoomAmount--;				
			m_mapPanX -= 5;
			m_mapPanY -= 5;
		//	if(m_mapPanY < -960 * m_zoomAxisX /4)
		//		m_mapPanY = -960 * m_zoomAxisX /4;

			p_zoomedScreen = zoomSurface(GUI_Img.getImage(0), m_zoomAxisX, m_zoomAxisY, SMOOTHING_ON);
		}
		if(Controls.down && m_zoomAxisX > .3){
			m_zoomAxisX-= .01;
			m_zoomAxisY-= .01;
			m_mouseOffsetX = m_zoomAxisX * 2;
			m_mouseOffsetY = m_zoomAxisY * 2;
			m_zoomAmount++;
			m_mapPanX += 5;
			m_mapPanY += 5;

		//	if(m_mapPanY < -960 * m_zoomAxisX /4)
		//		m_mapPanY = -960 * m_zoomAxisX /4;
			p_zoomedScreen = zoomSurface(GUI_Img.getImage(0), m_zoomAxisX, m_zoomAxisY, SMOOTHING_ON);
		}
		if(Controls.left)
			m_mapPanX-=5;
			if(m_mapPanX > 0)
				m_mapPanX = 0;
		if(Controls.right)
			m_mapPanX+=5;

		SDL_Rect clip = {0,0, 2560, 960};
		SDL_Rect offset = {m_mapPanX,m_mapPanY};
		
		SDL_BlitSurface(p_zoomedScreen, &clip, screen, &offset);//draw map
	

		markerPosition.x = m_playerPosition.x*(m_zoomAxisX*2) + m_mapPanX;
		markerPosition.y = m_playerPosition.y*(m_zoomAxisX*2) + m_mapPanY;
		filledEllipseRGBA(screen, markerPosition.x, markerPosition.y - 10, 10, 10, m_mapMarkerHighlight, 0, 200, m_mapMarkerHighlight);//draw player marker
		
		m_mapMarkerHighlight+= 2;
		if(m_mapMarkerHighlight > 255)
			m_mapMarkerHighlight = 100;
}
Exemplo n.º 15
0
 void DrawingArea::DrawFilledEllipse(const int x, const int y, const int rx, const int ry, const SSDL::Color Color) {
     filledEllipseRGBA(this->surface, x, y, rx, ry, Color.GetRed(), Color.GetGreen(), Color.GetBlue(), Color.GetAlpha());
 }