コード例 #1
0
ファイル: color_wrappers.c プロジェクト: yav/allegro
void shal_draw_spline(float points[8],
                      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_spline(points, color, thickness);
}
コード例 #2
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);
   }
}
コード例 #3
0
ファイル: ssf.c プロジェクト: xharbour/core
USHORT ssfDrawChar( AL_BITMAP * dst, ssfFont * sfont, char c, int x, int y, int color )
{
   BYTE     p;
   int      i, j, thick;
   ssfGlyph charGlyph;
   ssfFrame charFrame;
   int      points[ 8 ];
   float    fScale;

   p           = ( BYTE ) c;
   charGlyph   = *sfont->chars[ p ];
   fScale      = ( float ) ( ( float ) sfont->fsize / ( float ) 65535 );

   for( i = 0; i < charGlyph.num; i++ )
   {
      charFrame = charGlyph.frames[ i ];
      if( charFrame.ftype == SSF_SPLINE2 )
      {
         fLeft2   = x + ( int ) ( fScale * charFrame.left );
         fTop2    = y + ( int ) ( fScale * charFrame.top );
         fRight2  = x + ( int ) ( fScale * charFrame.right );
         fBottom2 = y + ( int ) ( fScale * charFrame.bottom );
      }
      else
      {
         fLeft    = x + ( int ) ( fScale * charFrame.left );
         fTop     = y + ( int ) ( fScale * charFrame.top );
         fRight   = x + ( int ) ( fScale * charFrame.right );
         fBottom  = y + ( int ) ( fScale * charFrame.bottom );
      }

      switch( charFrame.ftype )
      {
         case SSF_SPLINE2:
            thick = ( int ) ( fScale * charFrame.thick );

            if( thick == 0 )
               thick++;

            for( j = 0; j < thick; j++ )
            {
               al_draw_spline( dst, points, color );
               switch( charFrame.thickdir )
               {
                  case THICK_LEFT:
                     fLeft--;
                     fRight--;
                     fLeft2--;
                     fRight2--;
                     break;
                  case THICK_UP:
                     fTop--;
                     fBottom--;
                     fTop2--;
                     fBottom2--;
                     break;
                  case THICK_RIGHT:
                     fLeft++;
                     fRight++;
                     fLeft2++;
                     fRight2++;
                     break;
                  case THICK_DOWN:
                     fTop++;
                     fBottom++;
                     fTop2++;
                     fBottom2++;
                     break;
               }
            }
            break;

         case SSF_LINE:
            thick = ( int ) ( fScale * charFrame.thick );

            if( thick == 0 )
               thick++;

            for( j = 0; j < thick; j++ )
            {
               al_draw_line( dst, fLeft, fTop, fRight, fBottom, color );
               switch( charFrame.thickdir )
               {
                  case THICK_LEFT:
                     fLeft--;
                     fRight--;
                     break;
                  case THICK_UP:
                     fTop--;
                     fBottom--;
                     break;
                  case THICK_RIGHT:
                     fLeft++;
                     fRight++;
                     break;
                  case THICK_DOWN:
                     fTop++;
                     fBottom++;
                     break;
               }
            }
            break;

         case SSF_BOX:
            al_draw_rect_fill( dst, fLeft, fTop, fRight, fBottom, color );
            break;

         case SSF_TRIANGLE:
            thick = x + ( int ) ( fScale * charFrame.thick );
            al_draw_triangle( dst, fLeft, fTop, fRight, fBottom, thick, y + ( int ) ( fScale * charFrame.thickdir ), color );
            break;
      }
   }

   return sfont->fsize / 2;
}
コード例 #4
0
ファイル: ssf.c プロジェクト: NaldoDj/core
unsigned short ssfDrawChar( AL_BITMAP * dst, ssfFont * sfont, char c, int x, int y, int color )
{
   HB_BYTE  p;
   int      i, j, thick;
   ssfGlyph charGlyph;
   ssfFrame charFrame;
   int      points[ 8 ];
   float    fScale;

   p         = ( HB_BYTE ) c;
   charGlyph = *sfont->chars[ p ];
   fScale    = ( float ) ( ( float ) sfont->fsize / ( float ) 65535 );

   for( i = 0; i < charGlyph.num; i++ )
   {
      charFrame = charGlyph.frames[ i ];
      if( charFrame.ftype == SSF_SPLINE2 )
      {
         points[ _F_LEFT2 ]   = x + ( int ) ( fScale * charFrame.left );
         points[ _F_TOP2 ]    = y + ( int ) ( fScale * charFrame.top );
         points[ _F_RIGHT2 ]  = x + ( int ) ( fScale * charFrame.right );
         points[ _F_BOTTOM2 ] = y + ( int ) ( fScale * charFrame.bottom );
      }
      else
      {
         points[ _F_LEFT ]   = x + ( int ) ( fScale * charFrame.left );
         points[ _F_TOP ]    = y + ( int ) ( fScale * charFrame.top );
         points[ _F_RIGHT ]  = x + ( int ) ( fScale * charFrame.right );
         points[ _F_BOTTOM ] = y + ( int ) ( fScale * charFrame.bottom );
      }

      switch( charFrame.ftype )
      {
         case SSF_SPLINE2:
            thick = ( int ) ( fScale * charFrame.thick );

            if( thick == 0 )
               thick++;

            for( j = 0; j < thick; j++ )
            {
               al_draw_spline( dst, points, color );
               switch( charFrame.thickdir )
               {
                  case THICK_LEFT:
                     points[ _F_LEFT ]--;
                     points[ _F_RIGHT ]--;
                     points[ _F_LEFT2 ]--;
                     points[ _F_RIGHT2 ]--;
                     break;
                  case THICK_UP:
                     points[ _F_TOP ]--;
                     points[ _F_BOTTOM ]--;
                     points[ _F_TOP2 ]--;
                     points[ _F_BOTTOM2 ]--;
                     break;
                  case THICK_RIGHT:
                     points[ _F_LEFT ]++;
                     points[ _F_RIGHT ]++;
                     points[ _F_LEFT2 ]++;
                     points[ _F_RIGHT2 ]++;
                     break;
                  case THICK_DOWN:
                     points[ _F_TOP ]++;
                     points[ _F_BOTTOM ]++;
                     points[ _F_TOP2 ]++;
                     points[ _F_BOTTOM2 ]++;
                     break;
               }
            }
            break;

         case SSF_LINE:
            thick = ( int ) ( fScale * charFrame.thick );

            if( thick == 0 )
               thick++;

            for( j = 0; j < thick; j++ )
            {
               al_draw_line( dst, points[ _F_LEFT ], points[ _F_TOP ], points[ _F_RIGHT ], points[ _F_BOTTOM ], color );
               switch( charFrame.thickdir )
               {
                  case THICK_LEFT:
                     points[ _F_LEFT ]--;
                     points[ _F_RIGHT ]--;
                     break;
                  case THICK_UP:
                     points[ _F_TOP ]--;
                     points[ _F_BOTTOM ]--;
                     break;
                  case THICK_RIGHT:
                     points[ _F_LEFT ]++;
                     points[ _F_RIGHT ]++;
                     break;
                  case THICK_DOWN:
                     points[ _F_TOP ]++;
                     points[ _F_BOTTOM ]++;
                     break;
               }
            }
            break;

         case SSF_BOX:
            al_draw_rect_fill( dst, points[ _F_LEFT ], points[ _F_TOP ], points[ _F_RIGHT ], points[ _F_BOTTOM ], color );
            break;

         case SSF_TRIANGLE:
            thick = x + ( int ) ( fScale * charFrame.thick );
            al_draw_triangle( dst, points[ _F_LEFT ], points[ _F_TOP ], points[ _F_RIGHT ], points[ _F_BOTTOM ], thick, y + ( int ) ( fScale * charFrame.thickdir ), color );
            break;
      }
   }

   return sfont->fsize / 2;
}
コード例 #5
0
ファイル: allegro-raw.c プロジェクト: chrra/allegro-raw
void al_draw_spline_w(float a, float b, float c, float d, float e, float f, float g, float h, ALLEGRO_COLOR *color, float thickness)
{
	float points[8] = {a, b, c, d, e, f, g, h};
	al_draw_spline(points, *color, thickness);
}