Exemplo n.º 1
0
void ps_point( int ix , int iy )
{ if (inpath) ps_stroke() ;
  ps_move( ix , iy ) ;
  fprintf( psfile , "%d %d %c\n",cx,cy,'P');
  ttcur=atcur=inpath=0;
  plot=1;
}
Exemplo n.º 2
0
void draw_test (int id, ps_context* gc)
{
    ps_color col = {0, 0, 1, 1};
    ps_color sol = {1, 0, 0, 1};
    ps_rect cr = {2.7f , 3.4f, 272.4f, 261.3f};
    ps_point s = {50.1f, 50.3f};
    ps_point e = {200.7f, 50.3f};

    ps_point p[3] = {{100,100},{200, 300},{ 300, 40}};
    ps_point cp = {128, 128};
    ps_point sc = {10, 228};
    ps_rect br = {50, 50, 120, 100};

    ps_set_line_width(gc, 1);
    ps_set_stroke_color(gc, &sol);

//    ps_set_line_dash(gc, dashs[0].s, dashs[0].d, 4);
    ps_set_source_color(gc, &col);
    ps_arc (gc, &cp, 10 , 0, 6.28f, True);
    ps_stroke(gc);

//    ps_set_line_dash(gc, dashs[1].s, dashs[1].d, 4);
    ps_tangent_arc(gc, &br, 0, 1.254f);
    ps_stroke(gc);
    ps_move_to(gc, &sc);
    ps_bezier_curve_to(gc, &p[0], &p[1], &p[2]);

    ps_arc (gc, &cp, 100 , 0.785f, 3.140f, False);
    
    ps_bezier_curve_to(gc, &p[0], &p[1], &p[2]);
    
//    ps_set_line_dash(gc, dashs[2].s, dashs[2].d, 4);
    ps_quad_curve_to(gc, &p[1], &p[2]);
    ps_stroke(gc);

//    ps_set_line_dash(gc, dashs[3].s, dashs[3].d, 4);
    ps_rectangle(gc, &cr);
    ps_rounded_rect(gc, &gt, 45.2f, 35.2f, 25.2f, 25.2f, 35.2f, 55.2f, 65.2f, 85.2f);
    ps_ellipse(gc, &gr);
    ps_stroke(gc);

//    ps_reset_line_dash(gc);
    ps_move_to(gc, &s);
    ps_line_to(gc, &e);
    ps_stroke(gc);
}
Exemplo n.º 3
0
void ps_clear( void )
{ if (inpath) ps_stroke() ;
  if (plot)
  {
    fprintf( psfile , "CL\n");
    npages++;
    atcur=inpath=ttcur=plot=0;
  }
}
Exemplo n.º 4
0
static void ps_draw_line(void *handle, int x1, int y1, int x2, int y2,
			 int colour)
{
    psdata *ps = (psdata *)handle;

    y1 = ps->ytop - y1;
    y2 = ps->ytop - y2;
    ps_printf(ps, "newpath %d %d moveto %d %d lineto\n", x1, y1, x2, y2);
    ps_stroke(ps, colour);
}
Exemplo n.º 5
0
void ps_space( int ix1 , int iy1 , int ix2 , int iy2 )
{ if( prolog_not_output ) ps_prolog() ;
  if (inpath) ps_stroke() ;
  fprintf( psfile , "initgraphics\n");
  fprintf( psfile , "1 setlinewidth\n");
  fprintf( psfile , "66 72 translate\n");
  scal=468.0/(ix2-ix1);
  fprintf( psfile , "%f %f scale\n",scal,468.0/(iy2-iy1));
  if (ix1 || iy1) fprintf( psfile , "%d %d translate\n",-ix1, -iy1);
  ps_linemod( "solid" ) ;
  atcur=inpath=font=0;
}
Exemplo n.º 6
0
void ps_rect( int x1,int y1 , int x2,int y2 )
{
   if( inpath ) ps_stroke() ;
   fprintf( psfile , "NP ");
   fprintf( psfile , "%d %d M ",x1,y1);
   fprintf( psfile , "%d %d N ",x2,y1);
   fprintf( psfile , "%d %d N ",x2,y2);
   fprintf( psfile , "%d %d N ",x1,y2);
#if 0
   fprintf( psfile , "%d %d N ",x1,y1);
#endif
   fprintf( psfile , "F S\n") ;
}
Exemplo n.º 7
0
void ps_arc( int x , int y , int x1 , int y1 , int x2 , int y2 )
{  double dx , dy ;

   if (inpath) ps_stroke() ;
   dx=x1-x;
   dy=y1-y;
   fprintf( psfile , "%d %d %f ", x, y, sqrt(dx*dx+dy*dy) );
   fprintf( psfile , "%f ", (double)(atan2(dy,dx)/M_PI)*180.0 );
   dx=x2-x;
   dy=y2-y;
   fprintf( psfile , "%f ", (double)(atan2(dy,dx)/M_PI)*180.0 );
   plot=1;
   atcur=inpath=0;
}
Exemplo n.º 8
0
static void ps_draw_circle(void *handle, int cx, int cy, int radius,
			   int fillcolour, int outlinecolour)
{
    psdata *ps = (psdata *)handle;

    cy = ps->ytop - cy;

    ps_printf(ps, "newpath %d %d %d 0 360 arc closepath\n", cx, cy, radius);

    if (fillcolour >= 0) {
	ps_printf(ps, "gsave\n");
	ps_fill(ps, fillcolour);
	ps_printf(ps, "grestore\n");
    }
    ps_stroke(ps, outlinecolour);
}
Exemplo n.º 9
0
void ps_label( char * s )
{ int is ;
  char c ;

  if (inpath) ps_stroke() ;
  if (!ttcur) fprintf( psfile , "%d %d M\n",cx,cy);
  if (!font) font=ps_setfont();
  fprintf( psfile , "(");
  for( is=0,c=s[is] ; (c!='\0')&&(c!='\n') ; ++is,c=s[is] )
  {
    if (c=='(' || c==')' || c=='\\')putchar('\\');
    putchar(c);
  }
  fprintf( psfile , ") T\n");
  ttcur=plot=1;
  atcur=inpath=0;
}
Exemplo n.º 10
0
static void ps_draw_polygon(void *handle, int *coords, int npoints,
			    int fillcolour, int outlinecolour)
{
    psdata *ps = (psdata *)handle;

    int i;

    ps_printf(ps, "newpath %d %d moveto\n", coords[0], ps->ytop - coords[1]);

    for (i = 1; i < npoints; i++)
	ps_printf(ps, "%d %d lineto\n", coords[i*2], ps->ytop - coords[i*2+1]);

    ps_printf(ps, "closepath\n");

    if (fillcolour >= 0) {
	ps_printf(ps, "gsave\n");
	ps_fill(ps, fillcolour);
	ps_printf(ps, "grestore\n");
    }
    ps_stroke(ps, outlinecolour);
}
Exemplo n.º 11
0
void ps_linemod( char * s)
{ double pt ;
  pt = 1.0 / scal ;

  if (inpath) ps_stroke() ;  /* draw anything specified before setdash */

  if (strncmp(s,"solid",5) == 0) {
     fprintf( psfile , "[] 0 setdash\n") ;
  } else if( strncmp(s,"dotted",6) == 0 ) {
     fprintf( psfile , "[ %f %f ] 0 setdash\n" , 2.0*pt , 3.0*pt ) ;
  } else if( strncmp(s,"dotdashed",9) == 0 ) {
     fprintf( psfile , "[ %f %f %f %f ] 0 setdash\n" ,
	    2.0*pt , 3.0*pt , 6.0*pt , 3.0*pt ) ;
  } else if( strncmp(s,"shortdashed",11) == 0 ) {
     fprintf( psfile , "[ %f %f ] 0 setdash\n" , 6.0*pt , 3.0*pt ) ;
  } else if( strncmp(s,"longdashed",10) == 0 ) {
     fprintf( psfile , "[ %f %f ] 0 setdash\n" , 9.0*pt , 4.5*pt ) ;
  } else {
     fprintf(stderr,
	     "plotps: linestyle '%s' not implemented.\n",s);
     fprintf( psfile , "[] 0 setdash\n") ;
  }
}
Exemplo n.º 12
0
void draw_test (int id, ps_context* gc)
{
//    int i;
//    double w;
    ps_font* old;
//    ps_size ts;
//    ps_font_info info;
//    ps_glyph g[5];
    ps_glyph tg;
//    ps_point s1;
//    ps_point e1;
    ps_color c1= {1, 0, 0, 0.8f};
    ps_color c2= {0, 0, 1, 0.8f};
    //ps_color x = {0, 0, 0, 1};
    ps_rect r = {150, 150, 400, 250};
    /*
    ps_rect er = {150, 50, 100, 100};
    ps_reset_clip(gc);
    ps_ellipse(gc, &er);
    ps_clip(gc);
    */
        ps_point s = {100, 100};
        ps_point e = {250, 100};

//    ps_set_shadow(gc, 1, 1, 0.15f);
//    ps_set_shadow_color(gc, &x);
    ps_translate(gc, -200, -200);
    ps_rotate(gc, 0.02f);
    ps_translate(gc, 200, 200);

  //  ps_set_text_antialias(gc, False);
        
//        double ds[] = {5, 3.1, 1.2, 5.5};

//        ps_set_line_dash(gc, 0, ds, 4);
        ps_move_to(gc, &s);
        ps_line_to(gc, &e);
    ps_stroke(gc);

  //  ps_set_text_render_type(gc, TEXT_TYPE_MONO);
    ps_set_text_matrix(gc, pn);
    ps_text_out_length(gc, 100, 100, text, strlen(text));


/*    
    if (a) {
    //    ps_font_set_size(pf, 16);
        ps_set_text_color(gc, &c1);
        a = 0;
    } else {
    //    ps_font_set_size(pf, 26);
        ps_set_text_color(gc, &c2);
        a = 1;
    }
*/
    //ps_matrix_rotate(pm, 0.13);
    ps_set_text_matrix(gc, pm);
    //ps_font_set_weight(pf, w);
    ps_set_text_color(gc, &c1);
    ps_set_text_stroke_color(gc, &c2);

    ps_rectangle(gc, &r);
    ps_stroke(gc);
//    ps_wide_text_out_length(gc, 200, 100, wtext, 5);
    old = ps_set_font(gc, pf);

    //ts = ps_text_extent(gc, wtext, 5);
//fprintf(stderr, "w: %.2f - h: %.2f \n", ts.w, ts.h);
///    s1.x = s1.y =  150;
//    e1.y = 150;
//    e1.x = 150 + ts.w;
//    ps_move_to(gc, &s1);
//    ps_line_to(gc, &e1);
//    ps_stroke(gc);


    ps_draw_text(gc, &r, wtext, 5, DRAW_TEXT_STROKE, TEXT_ALIGN_LEFT | TEXT_ALIGN_TOP);

    //ps_set_source_gradient(gc, gr);
    //ps_set_source_image(gc, pi);
    ps_set_source_pattern(gc, pt);
    ps_get_glyph(gc, 0x56fe, &tg);

//    ts = ps_glyph_extent(&tg);
//fprintf(stderr, "w: %.2f - h: %.2f \n", ts.w, ts.h);
    ps_get_path_from_glyph(gc, &tg, pa);
    ps_set_path(gc, pa);
    ps_fill(gc);

//    ps_get_font_info(gc, &info);
//fprintf(stderr, "h: %.2f - a: %.2f - d: %.2f - l: %.2f \n", info.size, info.ascent, info.descent, info.leading);
    ps_set_font(gc, old);
    ps_set_text_render_type(gc, TEXT_TYPE_STROKE);

/*
    for (i=0; i<5; i++)
        ps_get_glyph(gc, gtext[i], &g[i]);

    ps_show_glyphs(gc, 200, 200, g, 5);
*/
}
Exemplo n.º 13
0
void ps_maybe_stroke( void )
{ if (inpath>100) ps_stroke();  }
Exemplo n.º 14
0
void ps_setrgb( float rrr , float ggg , float bbb )
{ if( inpath ) ps_stroke() ;
  fprintf( psfile , "%f %f %f setrgbcolor\n" , rrr,ggg,bbb ) ;
}
Exemplo n.º 15
0
void ps_setwidth( float www )
{ if( inpath ) ps_stroke() ;
  fprintf( psfile , "%f setlinewidth\n" , www ) ;
}
Exemplo n.º 16
0
void on_draw(ps_context* gc)
{
    int i;
    ps_color color = {1, 1, 1, 1};
    ps_set_source_color(gc, &color);
    ps_clear(gc);

    ps_set_line_cap(gc, LINE_CAP_BUTT);
    ps_set_composite_operator(gc, COMPOSITE_SRC_OVER);

    ps_identity(gc);
    ps_set_matrix(gc, adjust);
    ps_scale(gc, (float)scale, (float)scale);

    // draw background
    ps_set_source_gradient(gc, shadowGradient);
    ps_set_path(gc, shadowPath);
    ps_fill(gc);

    // draw quadrant
    ps_set_source_gradient(gc, quadrantGradient);
    ps_set_path(gc, quadrantPath);
    ps_fill(gc);

    ps_identity(gc);
    ps_scale(gc, (float)scale, (float)scale);
    // draw inner bevel
    ps_set_source_gradient(gc, bevelsGradient);
    ps_set_fill_rule(gc, FILL_RULE_EVEN_ODD);
    ps_set_path(gc, innerBevelPath);
    ps_fill(gc);

    ps_identity(gc);
    ps_translate(gc, -256, -256);
    ps_rotate(gc, (float)PI);
    ps_translate(gc, 256, 256);
    ps_scale(gc, (float)scale, (float)scale);

    ps_set_source_gradient(gc, bevelsGradient);
    ps_set_fill_rule(gc, FILL_RULE_EVEN_ODD);
    ps_set_path(gc, outerBevelPath);
    ps_fill(gc);

    // draw seconds tags
    {
        ps_color sc = {0.11f, 0.12f, 0.13f, 0.65f};
        ps_set_line_width(gc, 2.0f);
        ps_set_line_cap(gc, LINE_CAP_ROUND);
        ps_set_stroke_color(gc, &sc);
        for (i = 0; i < 60; i++) {
            if ((i % 5) != 0) {
                ps_identity(gc);
                ps_translate(gc, -256, -256);
                ps_rotate(gc, 2 * PI - ((float)i/60.0f) * PI * 2);
                ps_translate(gc, 256, 256);
                ps_scale(gc, (float)scale, (float)scale);
                ps_set_path(gc, secondTagPath);
                ps_stroke(gc);
            }
        }

        // draw hours and milliseconds tags
        for (i = 0; i < 12; i++) {
            float rot = 2 * PI - (((float)i / 12.0f) * PI * 2);
            ps_set_line_width(gc, 7.0);
            ps_identity(gc);
            ps_translate(gc, -256, -256);
            ps_rotate(gc, (float)rot);
            ps_translate(gc, 256, 256);
            ps_scale(gc, (float)scale, (float)scale);
            ps_set_path(gc, hourTagPath);
            ps_stroke(gc);

            ps_set_line_width(gc, 2.0);
            ps_identity(gc);
            ps_translate(gc, -356, -256);
            ps_rotate(gc, (float)rot);
            ps_translate(gc, 356, 256);
            ps_scale(gc, (float)scale, (float)scale);
            ps_set_path(gc, msTagPath);
            ps_stroke(gc);
        }
    }
    //draw cursors
    {
        time_t ctime;
        struct tm *ltime;
        ctime = time(NULL);
        ltime = localtime(&ctime);
        drawCursors(gc, ltime->tm_hour, ltime->tm_min, ltime->tm_sec, millsecons);
    }
    //draw glass
    {
        ps_color gcol = {0.04f, 0.045f, 0.05f, 0.8f};
        ps_identity(gc);
        ps_set_matrix(gc, adjust);
        ps_scale(gc, (float)scale, (float)scale);
        ps_set_composite_operator(gc, COMPOSITE_PLUS);
        ps_set_source_color(gc, &gcol);
        ps_set_path(gc, glassPath);
        ps_fill(gc);
    }
}