Exemplo n.º 1
0
//void SimpleDrawTest(cdCanvas* canvas)
void SimpleDrawPoly(cdCanvas* canvas)
{
  int w, h;
  cdGetCanvasSize(&w, &h, 0, 0);

  cdBackground(CD_WHITE);
  cdClear();

  //cdSetAttribute("ANTIALIAS", "0");
  cdForeground(cdEncodeAlpha(cdEncodeColor(255, 0, 0), 100));

  cdfCanvasArc(cdActiveCanvas(), 255, 255, 100, 100, 0, 360);

  cdLine(0, 0, 200, 200);

  cdBegin(CD_BEZIER);
  cdVertex(100, 100); 
  cdVertex(150, 200); 
  cdVertex(180, 250); 
  cdVertex(180, 200); 
  cdVertex(180, 150); 
  cdVertex(150, 100); 
  cdVertex(300, 100); 
  cdEnd();


  cdEnd();
}
Exemplo n.º 2
0
static int drawcb(Ihandle *h, int lin, int col,int x1, int x2, int y1, int y2)
{
  if (lin < 5 || lin > 12 || col < 2 || col > 8)
    return IUP_IGNORE;

  cdForeground(CD_RED);
  cdLine(x1, y1, x2, y2);
  cdLine(x1, y2, x2, y1);

  {
    char s[50];
    sprintf(s, "%d:%d", lin, col);
    cdTextAlignment(CD_CENTER);
    cdText((x1+x2)/2, (y1+y2)/2, s);
  }

  return IUP_DEFAULT;
}
Exemplo n.º 3
0
void draw(void)
{
	cdMarkSize(5);
	cdMarkType(CD_PLUS);
	cdMark(10,90);
	cdMarkType(CD_STAR);
	cdMark(20,90);
	cdMarkType(CD_CIRCLE);
	cdMark(30,90);
	cdMarkType(CD_X);
	cdMark(40,90);
	cdMarkType(CD_BOX);
	cdMark(50,90);
	cdMarkType(CD_DIAMOND);
	cdMark(60,90);
	cdMarkType(CD_HOLLOW_CIRCLE);
	cdMark(70,90);
	cdMarkType(CD_HOLLOW_BOX);
	cdMark(80,90);
	cdMarkType(CD_HOLLOW_DIAMOND);
	cdMark(90,90);

	cdLineStyle(CD_CONTINUOUS);
	cdLine(10,80,80,80);
	cdLineStyle(CD_DASHED);
	cdLine(10,75,80,75);
	cdLineStyle(CD_DOTTED);
	cdLine(10,70,80,70);
	cdLineStyle(CD_DASH_DOT);
	cdLine(10,65,80,65);
	cdLineStyle(CD_DASH_DOT_DOT);
	cdLine(10,60,80,60);

	cdLineStyle(CD_CONTINUOUS);

	cdHatch(CD_HORIZONTAL);

	cdBegin(CD_FILL);
	cdVertex(10,50);
	cdVertex(50,50);
	cdVertex(50,10);
	cdVertex(10,10);
	cdEnd();

	cdHatch(CD_VERTICAL);
	cdBegin(CD_FILL);
	cdVertex(60,50);
	cdVertex(100,50);
	cdVertex(100,10);
	cdVertex(60,10);
	cdEnd();

	cdHatch(CD_FDIAGONAL);
	cdBegin(CD_FILL);
	cdVertex(110,50);
	cdVertex(150,50);
	cdVertex(150,10);
	cdVertex(110,10);
	cdEnd();

	cdHatch(CD_BDIAGONAL);
	cdBegin(CD_FILL);
	cdVertex(160,50);
	cdVertex(200,50);
	cdVertex(200,10);
	cdVertex(160,10);
	cdEnd();

	cdHatch(CD_CROSS);
	cdBegin(CD_FILL);
	cdVertex(210,50);
	cdVertex(250,50);
	cdVertex(250,10);
	cdVertex(210,10);
	cdEnd();

	cdHatch(CD_DIAGCROSS);
	cdBegin(CD_FILL);
	cdVertex(260,50);
	cdVertex(300,50);
	cdVertex(300,10);
	cdVertex(260,10);
	cdEnd();

	cdFont(CD_SYSTEM,CD_BOLD,CD_STANDARD);
	cdText(10,100,'Teste');
	cdFont(CD_COURIER,CD_BOLD,CD_STANDARD);
	cdText(60,100,'Teste');
	cdFont(CD_TIMES_ROMAN,CD_BOLD,CD_STANDARD);
	cdText(110,100,'Teste');
	cdFont(CD_HELVETICA,CD_BOLD,CD_STANDARD);
	cdText(160,100,'Teste');
}
Exemplo n.º 4
0
int main()
{
    // you must create a pointer to the image(s) that you will be using
    // not suprisingly, it is of type cdImagePtr
    cdImagePtr im;

    // this is a pointer to the output file you will be using
    FILE *outf;

    // these will be index's into the color palette containing
    // the corresponding colors
    int black, white, blue;


    // Create an image 800 pixels wide by 400 pixels high
    im = cdImageCreate( 800, 400 );

    // allocate some colors (isn't this fun?)
    // the first color allocated is the background color
    white = cdImageColorAllocate( im, 255, 255, 255 );
    black = cdImageColorAllocate( im, 0, 0, 0 );
    blue  = cdImageColorAllocate( im, 0, 0, 255 );


    // set the text attributes
    // font, colorindex, and size respectivily

    // font is the style the text is written in. 1 is for Times,
    // 5 is for Helvetica.
    // we will have black text for this one
    // Size is a tough one,  but larger numbers give larger text.
    //
    if ( !( cdSetTextAttrib( im, 5, black, 20 ) ) )
        return 1;

    // Set some line attributes,  lets make lines solid, width 1, and blue
    //
    if ( !( cdSetLineAttrib( im, 1, 1, blue ) ) )
        return 1;

    // Draw a couple of grid lines
    if ( !( cdLine( im, 0, 200, 799, 200 ) ) )
        return 1;
    if ( !( cdLine( im, 200, 0, 200, 399 ) ) )
        return 1;
    if ( !( cdLine( im, 600, 0, 600, 399 ) ) )
        return 1;


    // Show Text going left, up, down, and right, all starting
    // from the same point

    // Text going to the left
    if ( !( cdSetTextPath( im, 1 ) ) )
        return 1;
    if ( !( cdText( im, 200, 200, "Text Left" ) ) )
        return 1;

    // Text going UP
    if ( !( cdSetTextPath( im, 2 ) ) )
        return 1;
    if ( !( cdText( im, 200, 200, "Text Up" ) ) )
        return 1;

    // Text going DOWN
    if ( !( cdSetTextPath( im, 3 ) ) )
        return 1;
    if ( !( cdText( im, 200, 200, "Text Down" ) ) )
        return 1;

    // Text going to the RIGHT
    if ( !( cdSetTextPath( im, 0 ) ) )
        return 1;
    if ( !( cdText( im, 200, 200, "Text Right" ) ) )
        return 1;

    // Show text going at an angle of 0, 45, 90, 135, 180 Degrees
    //

    // Text at no angle
    if ( !( cdText( im, 600, 200, "CGM Draw" ) ) )
        return 1;

    // Text, 45 Degree Angle
    if ( !( cdSetTextOrient( im, -1, 1, 1, 1 ) ) )
        return 1;
    if ( !( cdText( im, 600, 200, "CGM Draw" ) ) )
        return 1;

    // Text, 90 Degree Angle
    if ( !( cdSetTextOrient( im, -1, 0, 0, 1 ) ) )
        return 1;
    if ( !( cdText( im, 600, 200, "CGM Draw" ) ) )
        return 1;

    // Text, 135 Degree Angle
    if ( !( cdSetTextOrient( im, -1, -1, -1, 1 ) ) )
        return 1;
    if ( !( cdText( im, 600, 200, "CGM Draw" ) ) )
        return 1;

    // Text, 180 Degree Angle
    if ( !( cdSetTextOrient( im, 0, -1, -1, 0 ) ) )
        return 1;
    if ( !( cdText( im, 600, 200, "CGM Draw" ) ) )
        return 1;

    // Skewed Text, No Angle
    if ( !( cdSetTextOrient( im, 1, 1, 1, 0 ) ) )
    {
        return 1;
    }
    if ( !( cdSetTextAttrib( im, -1, -1, 40 ) ) )
    {
        return 1;
    }
    if ( !( cdText( im, 300, 300, "CGM Draw" ) ) )
    {
        return 1;
    }
    // show some lines around it
    if ( !( cdLine( im, 300, 300, 500, 300 ) ) )
        return 1;
    if ( !( cdLine( im, 300, 300, 340, 340 ) ) )
        return 1;

    // reset the text to 0 angle
    if ( !( cdSetTextOrient( im, 0, 1, 1, 0 ) ) )
        return 1;


    if ( !( cdSetTextAttrib( im, 5, -1, 20 ) ) )
        return 1;
    if ( !( cdText( im, 5, 5, "G. Edward Johnson" ) ) )
        return 1;

    // now write the file out, lets call it cdtext.cgm
    outf = fopen( "cdtext.cgm", "wb" );
    if ( !outf )
        return 1;
    cdImageCgm( im, outf );
    fclose( outf );
    outf = 0;

    // Remember to destroy the image when you are done
    cdImageDestroy( im );
    im = 0;

    printf( "CGM Text Example!!!\n" );

    return 0;
}