コード例 #1
0
ファイル: color_wrappers.c プロジェクト: yav/allegro
void shal_draw_rounded_rectangle(float x1,
                                 float y1,
                                 float x2,
                                 float y2,
                                 float rx,
                                 float ry,
                                 float color_r,
                                 float color_g,
                                 float color_b,
                                 float color_a,
                                 float thickness)
{
    ALLEGRO_COLOR color;
    color.r = color_r;
    color.g = color_g;
    color.b = color_b;
    color.a = color_a;
    return al_draw_rounded_rectangle(x1,
                                     y1,
                                     x2,
                                     y2,
                                     rx,
                                     ry,
                                     color,
                                     thickness);
}
コード例 #2
0
/* ----------------------------------------------------------------------------
 * Draws a button widget.
 */
void menu_button::draw(const float time_spent) {
    if(!font || !enabled) return;
    
    al_draw_rounded_rectangle(
        center.x - size.x * 0.5, center.y - size.y * 0.5,
        center.x + size.x * 0.5, center.y + size.y * 0.5,
        16, 16, al_map_rgba(255, 255, 255, 32), 2
    );
    
    if(selected) {
        draw_bitmap(
            bmp_icon, point(center.x - size.x * 0.5 + 16, center.y),
            point(16, 16),
            sin(time_spent * ICON_SWAY_TIME_SCALE) * ICON_SWAY_DELTA
        );
        draw_bitmap(
            bmp_icon, point(center.x + size.x * 0.5 - 16, center.y),
            point(16, 16),
            sin(time_spent * ICON_SWAY_TIME_SCALE) * ICON_SWAY_DELTA
        );
    }
    
    int text_x = center.x;
    if(text_align == ALLEGRO_ALIGN_LEFT) {
        text_x = center.x - size.x * 0.5 + 32;
    } else if(text_align == ALLEGRO_ALIGN_RIGHT) {
        text_x = center.x + size.x * 0.5 - 32;
    }
    
    draw_text_lines(
        font, text_color,
        point(text_x, center.y),
        text_align, 1, text
    );
}
コード例 #3
0
ファイル: Snake.cpp プロジェクト: ferrolho/allegro-snake
void Snake::DrawSnake()
{
	for (unsigned int i = 0; i < cells.size(); i++)
	{
		al_draw_rounded_rectangle(cells[i][0] - (size / 2), cells[i][1] - (size / 2), cells[i][0] + (size / 2), cells[i][1] + (size / 2), 4, 4, color, 2.0);
	}
}
コード例 #4
0
ファイル: InputField.cpp プロジェクト: kruci/Juicy-Plebs
bool InputField::Bitmap()
{

   // al_set_target_bitmap(bmp);
    al_set_target_bitmap(as_bitmap);
    al_clear_to_color(bckground_color);

    //float tx = (text_width <= width ? 0 : width - text_width);
    float tx = (text_width <= width ? (center == true ? (width - text_width)/2 : 0) : width - text_width);

    al_draw_text(font, text_color, tx, (height - text_height) / 2.0f, 0, text.c_str());

    if(detectingbutton->is_button_clicked() == true)
    {
        if(bling > 30)
        {
            al_draw_line(tx + text_width -2, (height - text_height) / 2.0f, tx + text_width -2, (height + text_height) / 2.0f, text_color, 2);
            if(bling > 60)
            {
                bling = 0;
            }
        }
        bling++;
    }

    /*al_set_target_bitmap(as_bitmap);
    al_clear_to_color(al_map_rgba(0,0,0,0));
    al_draw_bitmap(bmp, 0, 0, 0);*/
    al_draw_rounded_rectangle(0, 0, width, height, 5, 5, outline_color, 2);
    al_set_target_backbuffer(al_get_current_display());
    return true;
}
コード例 #5
0
ファイル: widgetbase.cpp プロジェクト: kruci/rGUI
 void Widget::wd_Print_AddedThickness()
 {
         al_draw_rounded_rectangle(wd_theme.added_thickness/2 + wd_theme.thickness/2,
                               wd_theme.added_thickness/2 + wd_theme.thickness/2,
                               wd_width + wd_theme.added_thickness/2 -  wd_theme.thickness/2,
                               wd_height + wd_theme.added_thickness/2-  wd_theme.thickness/2,
                             wd_theme.roundx, wd_theme.roundy,wd_theme.c_outline, wd_theme.thickness + wd_theme.added_thickness);
 }
コード例 #6
0
ファイル: widget.cpp プロジェクト: MarkOates/allegro_flare
void UIWidget::on_draw()
{
   if (surface_area)
   {
      al_draw_rounded_rectangle(0, 0, surface_area->placement.size.x, surface_area->placement.size.y, 4, 4, color::color(color::aliceblue, 0.2), 2.0);
      ALLEGRO_BITMAP *widget_icon = UIStyleAssets::get_widget_icon();
      al_draw_tinted_bitmap(widget_icon, color::color(color::white, 0.1), place.size.x/2-al_get_bitmap_width(widget_icon)/2, place.size.y/2-al_get_bitmap_height(widget_icon)/2, 0);
   }
}
コード例 #7
0
void DescriptionBox::Draw(std::string title, std::string description){
	ALLEGRO_COLOR color = al_color_name("white");
	if (title == "Game Over") {
		color = al_color_name("red");
	}
    al_draw_rounded_rectangle(10, ScreenHeight - 190, ScreenWidth - 10, ScreenHeight - 10, 7, 7, al_color_name("white"), 5);
    //std::cout << title << " " << description << std::endl;
    al_draw_text(font, color, 20, ScreenHeight - 190, ALLEGRO_ALIGN_LEFT, title.c_str());
    al_draw_text(font, al_color_name("white"), 20, ScreenHeight - 160, ALLEGRO_ALIGN_LEFT, description.c_str());
}
コード例 #8
0
ファイル: weapon_sys.c プロジェクト: rcorre/alecs
static void draw_lockon(struct ecs_entity *target, int lockon_count) {
  Collider *collider = &target->components[ECS_COMPONENT_COLLIDER]->collider;
  // draw lockon rect
  if (collider) {
    rectangle r = collider->rect;
    al_draw_rounded_rectangle(r.x, r.y, r.x + r.w, r.y + r.h, 1, 1, PRIMARY_LOCK_COLOR, 3);
    // draw lock count
    al_draw_textf(main_font, PRIMARY_LOCK_COLOR, r.x + r.w, r.y, 0, "%d", lockon_count);
  }
}
コード例 #9
0
ファイル: SaveSlots.cpp プロジェクト: EdwinMartens/star_trek
void Slot::Draw(ALLEGRO_FONT * a_pFont)
{
     if (m_blHighLight)
    {
       al_draw_rounded_rectangle((float)m_nX,
                                     (float)m_nY,
                                     (float)(m_nX + m_nWidth),
                                     (float)(m_nY + m_nHeight),
                                     10, 10,
                                     m_pParent->m_ColorHighlight,2);

    }
    else
    {
        al_draw_rounded_rectangle((float)m_nX,
                                     (float)m_nY,
                                     (float)(m_nX + m_nWidth),
                                     (float)(m_nY + m_nHeight),
                                     10, 10,
                                    m_pParent->m_ColorOuter,2);


    }

     al_draw_filled_rounded_rectangle((float)m_nX,
                                     (float)m_nY,
                                     (float)(m_nX + m_nWidth),
                                     (float)(m_nY + m_nHeight),
                                     10, 10,
                                     m_pParent->m_ColorInner);

   if (a_pFont != NULL)
   {
      al_draw_text(a_pFont,
                   m_pParent->m_ColorOuter,
                   m_nX + (m_nWidth/2), m_nY + (m_nHeight/4),
                   ALLEGRO_ALIGN_CENTRE,
                   m_strCaption.c_str());

   }
}
コード例 #10
0
ファイル: main.c プロジェクト: wjwwood/agame
int agame_msg(char const * msg, ALLEGRO_FONT * font) {
  int w = al_get_display_width(display);
  int h = al_get_display_height(display);
  // Draw the bounding box
  al_draw_filled_rounded_rectangle(0, h - h/3.0, w, h,
                                   10, 10, al_map_rgb(120, 120, 120));
  al_draw_filled_rounded_rectangle(5, h - h/3.0 + 5, w - 5, h - 5,
                                   10, 10, al_map_rgb(230, 230, 230));
  al_draw_rounded_rectangle(5, h - h/3.0 + 5, w - 5, h - 5,
                            10, 10, al_map_rgb(0, 0, 0), 3);
  al_draw_justified_text(font, al_map_rgb(0, 0, 0), 10, w - 10,
                         h - h/3.0 + 10, 16, 0, msg);
  return 1;
}
コード例 #11
0
ファイル: primitives.c プロジェクト: caivega/minisphere
static duk_ret_t
js_OutlinedRoundRectangle(duk_context* ctx)
{
	int n_args = duk_get_top(ctx);
	float x = duk_require_int(ctx, 0) + 0.5;
	float y = duk_require_int(ctx, 1) + 0.5;
	int w = duk_require_int(ctx, 2);
	int h = duk_require_int(ctx, 3);
	float radius = duk_require_number(ctx, 4);
	color_t color = duk_require_sphere_color(ctx, 5);
	int thickness = n_args >= 7 ? duk_require_int(ctx, 6) : 1;

	if (!is_skipped_frame())
		al_draw_rounded_rectangle(x, y, x + w - 1, y + h - 1, radius, radius, nativecolor(color), thickness);
	return 0;
}
コード例 #12
0
static void draw_square(Square *sq)
{
   ALLEGRO_TRANSFORM trans;
   float alpha;
   float size;
   ALLEGRO_COLOR tint;

   al_build_transform(&trans, sq->cx, sq->cy, 1.0, 1.0, sq->rot);
   al_use_transform(&trans);

   alpha = sin(sq->life);
   al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_ONE);
   tint = al_map_rgba_f(0.5, 0.3, 0, alpha);

   size = sq->size;
   al_draw_filled_rounded_rectangle(-size, -size, size, size, 3, 3, tint);

   size *= 1.1;
   al_draw_rounded_rectangle(-size, -size, size, size, 3, 3, tint, 2);
}
コード例 #13
0
static void TransformationsPrimitives(int mode)
{
   float t = al_get_time();
   if (mode == INIT) {
   
   } else if (mode == LOGIC) {
      Theta += Speed;
      al_build_transform(&MainTrans, ScreenW / 2, ScreenH / 2, sinf(t / 5), cosf(t / 5), Theta);
   } else if (mode == DRAW) {
      float points[8] = {
         -300, -200,
         700, 200,
         -700, 200,
         300, -200
      };
      
      if (Blend)
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE);
      else
         al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
      
      al_use_transform(&MainTrans);
      
      al_draw_line(-300, -200, 300, 200, al_map_rgba_f(0, 0.5, 0.5, 1), Thickness);
      al_draw_triangle(-150, -250, 0, 250, 150, -250, al_map_rgba_f(0.5, 0, 0.5, 1), Thickness);
      al_draw_rectangle(-300, -200, 300, 200, al_map_rgba_f(0.5, 0, 0, 1), Thickness);
      al_draw_rounded_rectangle(-200, -125, 200, 125, 50, 100, al_map_rgba_f(0.2, 0.2, 0, 1), Thickness);
      
      al_draw_ellipse(0, 0, 300, 150, al_map_rgba_f(0, 0.5, 0.5, 1), Thickness);
      al_draw_elliptical_arc(-20, 0, 300, 200, -ALLEGRO_PI / 2, -ALLEGRO_PI, al_map_rgba_f(0.25, 0.25, 0.5, 1), Thickness);
      al_draw_arc(0, 0, 200, -ALLEGRO_PI / 2, ALLEGRO_PI, al_map_rgba_f(0.5, 0.25, 0, 1), Thickness);
      al_draw_spline(points, al_map_rgba_f(0.1, 0.2, 0.5, 1), Thickness);
      al_draw_pieslice(0, 25, 150, ALLEGRO_PI * 3 / 4, -ALLEGRO_PI / 2, al_map_rgba_f(0.4, 0.3, 0.1, 1), Thickness);
      
      al_use_transform(&Identity);
   }
}
コード例 #14
0
void Menu_Screen::Draw_Screen( ALLEGRO_EVENT &events , ALLEGRO_TIMER *FPS , ALLEGRO_TIMER *MapFPS)
{
	//OBSLUGA EVENTU CZASU
	if(events.type == ALLEGRO_EVENT_TIMER)
	{
		if( events.timer.source == FPS )
			draw = true ;
	}
	//ODSWIEZAMY EKRAN
	if(draw)
	{
		//draw = false ;
		
		al_draw_bitmap( Screen_Bitmap["Menu_Background"] , 0 , 0 , NULL ) ;
		al_draw_bitmap( Screen_Bitmap["Title"] , 100 , 0 , NULL ) ;
		al_draw_bitmap( Screen_Bitmap["Start"] , ScreenWidth / 2 - 100 , 200 , NULL ) ;
		al_draw_bitmap( Screen_Bitmap["Edit"] , ScreenWidth / 2 - 210 , 300 , NULL ) ;
		al_draw_bitmap( Screen_Bitmap["New"] , ScreenWidth / 2 + 10 , 300 , NULL ) ;
		al_draw_bitmap( Screen_Bitmap["Options"] , ScreenWidth / 2 - 100 , 400 , NULL ) ;
		al_draw_bitmap( Screen_Bitmap["Exit"] , ScreenWidth / 2 - 100 , 500 , NULL ) ;

		//OPCJE
		if(Options)
		{
			al_draw_bitmap( Screen_Bitmap["Options_Background"] , 150 , 150 , NULL ) ;
			al_draw_text( Font_Big , al_map_rgb(44 , 100 , 255) , 400 , 155 , ALLEGRO_ALIGN_CENTER , "OPTIONS" ) ;
			al_draw_text( Font_Smal , al_map_rgb(44 , 100 , 255) , 350 , 300 , ALLEGRO_ALIGN_CENTER , "DIFFICULTY" ) ;
			al_draw_bitmap( Screen_Bitmap["Options_Back"] , 200 , 380 , NULL ) ;
			al_draw_bitmap( Screen_Bitmap["Options_Easy"] , 500 , 225 , NULL ) ;
			al_draw_bitmap( Screen_Bitmap["Options_Medium"] , 500 , 300 , NULL ) ;
			al_draw_bitmap( Screen_Bitmap["Options_Hard"] , 500 , 375 , NULL ) ;
		}

		switch(Select_Options)
		{
			case 0:

				if(Options)
					al_draw_bitmap( Screen_Bitmap["Options_Easy2"] , 500 , 225 , NULL ) ;
				else
					al_draw_bitmap( Screen_Bitmap["Start2"] , ScreenWidth / 2 - 100 , 200 , NULL ) ;
				break ;

			case 1:

				if(Options)
					al_draw_bitmap( Screen_Bitmap["Options_Medium2"] , 500 , 300 , NULL ) ;
				else
					al_draw_bitmap( Screen_Bitmap["Edit2"] , ScreenWidth / 2 - 210 , 300 , NULL ) ;
				break ;

			case 2:

				if(Options)
					al_draw_bitmap( Screen_Bitmap["Options_Hard2"] , 500 , 375 , NULL ) ;
				else 
					al_draw_bitmap( Screen_Bitmap["New2"] , ScreenWidth / 2 + 10 , 300 , NULL ) ;
				break ;

			case 3:

				if(Options) 
					al_draw_bitmap( Screen_Bitmap["Options_Back2"] , 200 , 380 , NULL ) ;
				else
					al_draw_bitmap( Screen_Bitmap["Options2"] , ScreenWidth / 2 - 100 , 400 , NULL ) ;
				break ;

			case 4:

				if(!Options)
					al_draw_bitmap( Screen_Bitmap["Exit2"] , ScreenWidth / 2 - 100 , 500 , NULL ) ;
				break ;
		}//switch(Select_Options)

		//ZAZNACZENIE WYBRANEGO POZIOMU TRUDNOSCI
		if(Options)
			al_draw_rounded_rectangle( difficultyX1 , difficultyY1 , difficultyX2 , difficultyY2 , 10 , 10 , al_map_rgb( 0 , 0 , 255 ) , 10 ) ;

		//al_flip_display() ;
		//al_clear_to_color(al_map_rgb(0 , 0 , 0)) ;
	}
}
コード例 #15
0
ファイル: graphics.cpp プロジェクト: LibreGames/monster-rpg-2
static void draw_the_controls(bool draw_controls, ALLEGRO_COLOR tint)
{
#if defined ALLEGRO_IPHONE || defined ALLEGRO_ANDROID
	if (use_dpad && dpad_buttons && draw_controls && global_draw_controls) {
		if ((dpad_type == DPAD_TOTAL_2 || dpad_type == DPAD_HYBRID_2)) {
			ALLEGRO_COLOR light = al_map_rgba(100*tint.r, 200*tint.g, 100*tint.b, 255*tint.a);
			ALLEGRO_COLOR dark = al_map_rgba(150*tint.r, 250*tint.g, 150*tint.b, 255*tint.a);
			int x = BUTTON_SIZE+10;
			int y = dpad_at_top ? 5 : BH-5-BUTTON_SIZE;

			if (!config.getSwapButtons()) {
				al_draw_circle(BW-20-BUTTON_SIZE/2, y+BUTTON_SIZE/2, 
					BUTTON_SIZE/2, light, 2);
				al_draw_circle(BW-20-BUTTON_SIZE/2, y+BUTTON_SIZE/2, 
					BUTTON_SIZE/2+1, dark, 1);

				al_draw_filled_circle(BW-25-BUTTON_SIZE*1.5, y+BUTTON_SIZE/2, BUTTON_SIZE/2, light);
				al_draw_circle(BW-25-BUTTON_SIZE*1.5, y+BUTTON_SIZE/2, BUTTON_SIZE/2, dark, 1);
			}
			else {
				al_draw_circle(BW-25-BUTTON_SIZE*1.5, y+BUTTON_SIZE/2, 
					BUTTON_SIZE/2, light, 2);
				al_draw_circle(BW-25-BUTTON_SIZE*1.5, y+BUTTON_SIZE/2, 
					BUTTON_SIZE/2+1, dark, 1);

				al_draw_filled_circle(BW-20-BUTTON_SIZE/2, y+BUTTON_SIZE/2, BUTTON_SIZE/2, light);
				al_draw_circle(BW-20-BUTTON_SIZE/2, y+BUTTON_SIZE/2, BUTTON_SIZE/2, dark, 1);
			}

			y = dpad_at_top ? 5 : BH-BUTTON_SIZE*3-5;

			int l = BUTTON_SIZE*1.5-10;

			al_draw_rounded_rectangle(10, y, 10+BUTTON_SIZE*3, y+BUTTON_SIZE*3, 5, 5, light, 2);
			al_draw_rounded_rectangle(9, y-1, 10+BUTTON_SIZE*3+1, y+BUTTON_SIZE*3+1, 5, 5, dark, 1);
			m_draw_line(17, y+7, 17+l, y+7+l, dark);
			m_draw_line(10+BUTTON_SIZE*3-8, y+7, 10+BUTTON_SIZE*3-8-l, y+7+l, dark);
			m_draw_line(17, y+BUTTON_SIZE*3-7, 17+l, y+BUTTON_SIZE*3-7-l, dark);
			m_draw_line(10+BUTTON_SIZE*3-7, y+BUTTON_SIZE*3-7, 10+BUTTON_SIZE*3-7-l, y+BUTTON_SIZE*3-7-l, dark);

			al_draw_filled_triangle(x+4, y+BUTTON_SIZE-4, x+BUTTON_SIZE/2, y+4, x+BUTTON_SIZE-4, y+BUTTON_SIZE-4, light/*, 1*/);
			al_draw_triangle(x+4, y+BUTTON_SIZE-4, x+BUTTON_SIZE/2, y+4, x+BUTTON_SIZE-4, y+BUTTON_SIZE-4, dark, 1);
			
			x = 10;
			y += BUTTON_SIZE;
		
			al_draw_filled_triangle(x+4, y+BUTTON_SIZE/2, x+BUTTON_SIZE-4, y+4, x+BUTTON_SIZE-4, y+BUTTON_SIZE-4, light/*, 1*/);
			al_draw_triangle(x+4, y+BUTTON_SIZE/2, x+BUTTON_SIZE-4, y+4, x+BUTTON_SIZE-4, y+BUTTON_SIZE-4, dark, 1);

			x = 10+BUTTON_SIZE*2;
			
			al_draw_filled_triangle(x+BUTTON_SIZE-4, y+BUTTON_SIZE/2, x+4, y+BUTTON_SIZE-4, x+4, y+4, light/*, 1*/);
			al_draw_triangle(x+BUTTON_SIZE-4, y+BUTTON_SIZE/2, x+4, y+BUTTON_SIZE-4, x+4, y+4, dark, 1);

			x = 10+BUTTON_SIZE;
			y += BUTTON_SIZE;
		
			al_draw_filled_triangle(x+4, y+4,
				x+BUTTON_SIZE/2, y+BUTTON_SIZE-4,
				x+BUTTON_SIZE-4, y+4, light/*, 1*/);
			al_draw_triangle(x+4, y+4,
				x+BUTTON_SIZE/2, y+BUTTON_SIZE-4,
				x+BUTTON_SIZE-4, y+4, dark, 1);
		}
		else {
			ALLEGRO_VERTEX verts[36];

			InputDescriptor ie = getInput()->getDescriptor();

			int x = BUTTON_SIZE+10;
			int y = dpad_at_top ? 5 : BH-5-BUTTON_SIZE;
			const int s = 20; // bitmap size
			const int o = (BUTTON_SIZE-s)/2; // offset to draw

			int nv = 0;
			int vx, vy;
			int vu, vv;

			#define SETXY \
				verts[nv].x = vx; \
				verts[nv].y = vy; \
				verts[nv].z = 0; \
				verts[nv+1].x = vx+20; \
				verts[nv+1].y = vy; \
				verts[nv+1].z = 0; \
				verts[nv+2].x = vx; \
				verts[nv+2].y = vy+20; \
				verts[nv+2].z = 0; \
				verts[nv+3].x = vx+20; \
				verts[nv+3].y = vy; \
				verts[nv+3].z = 0; \
				verts[nv+4].x = vx+20; \
				verts[nv+4].y = vy+20; \
				verts[nv+4].z = 0; \
				verts[nv+5].x = vx; \
				verts[nv+5].y = vy+20; \
				verts[nv+5].z = 0;

			#define SETUV \
				verts[nv].u = vu; \
				verts[nv].v = vv; \
				verts[nv+1].u = vu+20; \
				verts[nv+1].v = vv; \
				verts[nv+2].u = vu; \
				verts[nv+2].v = vv+20; \
				verts[nv+3].u = vu+20; \
				verts[nv+3].v = vv; \
				verts[nv+4].u = vu+20; \
				verts[nv+4].v = vv+20; \
				verts[nv+5].u = vu; \
				verts[nv+5].v = vv+20; \
				nv += 6;

			if (config.getSwapButtons()) {
				vx = BW-20-BUTTON_SIZE+o;
				vy = y+o;
			}
			else {
				vx = BW-25-BUTTON_SIZE*2;
				vy = y+o;
			}

			SETXY

			if (ie.button1) {
				vu = 20;
				vv = 40;

				SETUV
			}
			else {
				vu = 0;
				vv = 40;

				SETUV
			}

			if (config.getSwapButtons()) {
				vx = BW-25-BUTTON_SIZE*2;
				vy = y+o;
			}
			else {
				vx = BW-20-BUTTON_SIZE+o;
				vy = y+o;
			}

			SETXY

			if (ie.button2) {
				vu = 60;
				vv = 40;

				SETUV
			}
コード例 #16
0
void DrawingClass::DrawRoundedRectangle (float x0, float y0, float x1,
    float y1, float rx, float ry, int r, int g, int b, float thick) {
  ALLEGRO_COLOR color = al_map_rgb(r, g, b);
  al_draw_rounded_rectangle(x0, y0, x1, y1, rx, ry, color, thick);
}
コード例 #17
0
ファイル: allegro-raw.c プロジェクト: chrra/allegro-raw
void al_draw_rounded_rectangle_w(float x1, float y1, float x2, float y2, float rx, float ry, ALLEGRO_COLOR *color, float thickness)
{
	al_draw_rounded_rectangle(x1, y1, x2, y2, rx, ry, *color, thickness);
}