예제 #1
0
int main (int argc, char *argv[])
{
    int arc_type;

    if (argc != 2)
    {
        printf ("USAGE: WHICHARC arcfile\n");
        return 100;
    }

    arc_type = WhichArc (argv[1]);

    if (arc_type == -1)
        printf ("File %s not found!\n", argv[1]);
    else
    {
        printf ("%s:\tArchive type is %s\t(return value = %d)\n",
                argv[1],
                Arctypes[arc_type],
                arc_type
               );
    }

    return arc_type;
}
int main(int argc,char *argv[])
{
      char *arc_types[]={"UNKNOWN", "ARC", "ZOO", "ARJ", "LHARC", "LHA",
                         "ZIP", "PAK", "PAK", "ARC7", "SFXARC", "SFXARJ",
                         "SFXLHARC", "SFXLHA", "SFXZIP", "SFXARC7", "SFXPAK",
                         "EXE"};

      while (--argc)
      {
            enum ArcType which;

            if (ArcERR == (which = WhichArc(*++argv)))
                  printf("File error accessing %s\n", *argv);
            else  printf("%s archive type is %s\n", *argv, arc_types[which]);
      }
      return(0);
}
예제 #3
0
파일: bresenhm.cpp 프로젝트: paulfitz/poker
//---------------------------------------------------------------------------
void EllipseArc2D (int xc, int yc, int a, int b, float fx0, float fy0,
    float fx1, float fy1, void (*callback)(int,int))
{
    // Assert (within floating point roundoff errors):
    //   (fx0-xc)^2/a^2 + (fy0-yc)^2/b^2 = 1
    //   (fx1-xc)^2/a^2 + (fy1-yc)^2/b^2 = 1
    // Assume if (fx0,fy0) == (fx1,fy1), then entire ellipse should be drawn.
    //
    // Integer points on arc are guaranteed to be traversed clockwise.

    const int a2 = a*a, b2 = b*b;

    // get integer end points for arc
    int x0, y0, x1, y1;
    SelectEllipsePoint(a2,b2,fx0-xc,fy0-yc,x0,y0);
    SelectEllipsePoint(a2,b2,fx1-xc,fy1-yc,x1,y1);

    int dx = x0 - x1;
    int dy = y0 - y1;
    int sqrlen = dx*dx+dy*dy;
    if ( sqrlen == 1 || ( sqrlen == 2 && abs(dx) == 1 ) )
    {
        callback(xc+x0,yc+y0);
        callback(xc+x1,yc+y1);
        return;
    }

    // determine initial case for arc drawing
    int arc = WhichArc(a2,b2,x0,y0);
    while ( 1 )
    {
        // process the pixel
        callback(xc+x0,yc+y0);

        // Determine next pixel to process.  Notation <(x,y),dy/dx>
        // indicates point on ellipse and slope at that point.
        int sigma;
        switch ( arc )
        {
        case 0:  // <(0,b),0> to <(u0,v0),-1>
            x0++;
            dx++;
            sigma = b2*x0*x0+a2*(y0-1)*(y0-1)-a2*b2;
            if ( sigma >= 0 )
            {
                y0--;
                dy--;
            }
            if ( b2*x0 >= a2*y0 )
                arc = 1;
            break;
        case 1:  // <(u0,v0),-1> to <(a,0),infinity>
            y0--;
            dy--;
            sigma = b2*x0*x0+a2*y0*y0-a2*b2;
            if ( sigma < 0 )
            {
                x0++;
                dx++;
            }
            if ( y0 == 0 )
                arc = 2;
            break;
        case 2:  // <(a,0),infinity> to <(u1,v1),+1>
            y0--;
            dy--;
            sigma = b2*(x0-1)*(x0-1)+a2*y0*y0-a2*b2;
            if ( sigma >= 0 )
            {
                x0--;
                dx--;
            }
            if ( b2*x0 <= -a2*y0 )
                arc = 3;
            break;
        case 3:  // <(u1,v1),+1> to <(0,-b),0>
            x0--;
            dx--;
            sigma = b2*x0*x0+a2*y0*y0-a2*b2;
            if ( sigma < 0 )
            {
                y0--;
                dy--;
            }
            if ( x0 == 0 )
                arc = 4;
            break;
        case 4:  // <(0,-b),0> to <(u2,v2,-1)>
            x0--;
            dx--;
            sigma = b2*x0*x0+a2*(y0+1)*(y0+1)-a2*b2;
            if ( sigma >= 0 )
            {
                y0++;
                dy++;
            }
            if ( a2*y0 >= b2*x0 )
                arc = 5;
            break;
        case 5:  // <(u2,v2,-1)> to <(-a,0),infinity>
            y0++;
            dy++;
            sigma = b2*x0*x0+a2*y0*y0-a2*b2;
            if ( sigma < 0 )
            {
                x0--;
                dx--;
            }
            if ( y0 == 0 )
                arc = 6;
            break;
        case 6:  // <(-a,0),infinity> to <(u3,v3),+1>
            y0++;
            dy++;
            sigma = b2*(x0+1)*(x0+1)+a2*y0*y0-a2*b2;
            if ( sigma >= 0 )
            {
                x0++;
                dx++;
            }
            if ( a2*y0 >= -b2*x0 )
                arc = 7;
            break;
        case 7:  // <(u3,v3),+1> to <(0,b),0>
            x0++;
            dx++;
            sigma = b2*x0*x0+a2*y0*y0-a2*b2;
            if ( sigma < 0 )
            {
                y0++;
                dy++;
            }
            if ( x0 == 0 )
                arc = 0;
            break;
        }

        sqrlen = dx*dx+dy*dy;
        if ( sqrlen <= 1 )
            break;
    }
}