Beispiel #1
0
void pdf_startpage(gfxdevice_t*dev, int width, int height)
{
    internal_t*i = (internal_t*)dev->internal;

    if(!i->tempfile) {
	i->tempfile = strdup(mktempname(0, "pdf"));

	PDF_begin_document(i->p, i->tempfile, 0, "");
	//PDF_set_value(i->p, "compress", 0);
	PDF_set_parameter(i->p, "usercoordinates", "true");
	PDF_set_parameter(i->p, "topdown", "true");
    }

    int width_plus_pad = width+floor(i->config_xpad*2);
    int height_plus_pad = height+floor(i->config_ypad*2);
    PDF_begin_page_ext(i->p, width_plus_pad, height_plus_pad, i->page_opts);
    PDF_set_value(i->p, "CropBox/llx", 0);
    PDF_set_value(i->p, "CropBox/lly", 0);
    PDF_set_value(i->p, "CropBox/urx", width_plus_pad);
    PDF_set_value(i->p, "CropBox/ury", height_plus_pad);
    if(i->config_xpad || i->config_ypad) {
	PDF_set_value(i->p, "TrimBox/llx", i->config_xpad);
	PDF_set_value(i->p, "TrimBox/lly", i->config_ypad);
	PDF_set_value(i->p, "TrimBox/urx", i->config_xpad+width);
	PDF_set_value(i->p, "TrimBox/ury", i->config_ypad+height);
    }

    PDF_set_parameter(i->p, "fillrule", "evenodd");
    i->width = width;
    i->height = height;
    i->num_pages++;

    reset_matrix(i);
}
Beispiel #2
0
void pdf_startclip(gfxdevice_t*dev, gfxline_t*line)
{
    internal_t*i = (internal_t*)dev->internal;
    
    restore_matrix(i);
    PDF_save(i->p);
    
    if(mkline(line, i->p, i->config_xpad, i->config_ypad, 1.0, 1))
	PDF_clip(i->p);
    else   
	; // TODO: strictly speaking, an empty clip clears everything
    
    reset_matrix(i);
}
Beispiel #3
0
void pdf_stroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
{
    internal_t*i = (internal_t*)dev->internal;
    if(width<1e-6)
	return;
    reset_matrix(i);
    PDF_setlinewidth(i->p, width);
    PDF_setlinecap(i->p, cap_style==gfx_capButt?0:(cap_style==gfx_capRound?1:2));
    PDF_setlinejoin(i->p, joint_style==gfx_joinMiter?0:(joint_style==gfx_joinRound?1:2));
    
    PDF_setrgbcolor_stroke(i->p, color->r/255.0, color->g/255.0, color->b/255.0);

    if(joint_style==gfx_joinMiter)
	PDF_setmiterlimit(i->p, miterLimit);
    if(mkline(line, i->p, i->config_xpad, i->config_ypad, 1.0, 0))
	PDF_stroke(i->p);
}
Beispiel #4
0
void pdf_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
{
    internal_t*i = (internal_t*)dev->internal;
    reset_matrix(i);
    PDF_setrgbcolor_fill(i->p, color->r/255.0, color->g/255.0, color->b/255.0);
    /*
       pdf-x (pdf 1.3) doesn't support opacityfill
    if(color->a!=255) {
	char opacityfill[80];
	sprintf(opacityfill, "opacityfill %f", color->a/256.0);
	int gstate = PDF_create_gstate(i->p, opacityfill);
	PDF_set_gstate(i->p, gstate);
    }*/
	
    if(mkline(line, i->p, i->config_xpad, i->config_ypad, 1.0, 1)) {
	PDF_fill(i->p);
    }
}
Beispiel #5
0
void pdf_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
{
    internal_t*i = (internal_t*)dev->internal;

    if(!font)
	return;

    gfxglyph_t*glyph = &font->glyphs[glyphnr];
    char as_shape = 0;
    if(!type3 && !ttf) {msg("<warning> No type3 enabled. Drawing char %d as shape", glyphnr);as_shape=1;}
    if(glyphnr>256-32) {msg("<warning> Drawing char %d as shape (not < 224)", glyphnr);as_shape=1;}
	
    if(as_shape) {
	reset_matrix(i);
	PDF_setrgbcolor_fill(i->p, color->r/255.0, color->g/255.0, color->b/255.0);
	gfxline_t*line2 = gfxline_clone(glyph->line);
	gfxline_transform(line2, matrix);
	if(mkline(line2, i->p, i->config_xpad, i->config_ypad, 1.0, 1)) {
	    PDF_fill(i->p);
	}
	gfxline_free(line2);
    } else {
	assert(gfxfontlist_hasfont(i->fontlist, font));
	int fontid = (int)(ptroff_t)gfxfontlist_getuserdata(i->fontlist, font->id);

	gfxmatrix_t m = *matrix;

	m.m00*=64;
	m.m01*=64;
	m.m10*=64;
	m.m11*=64;
	if(ttf) {
	    m.m10 = -m.m10;
	    m.m11 = -m.m11;
	}

	if(!(fabs(m.m00 - i->m00) < 1e-6 &&
	     fabs(m.m01 - i->m01) < 1e-6 &&
	     fabs(m.m10 - i->m10) < 1e-6 &&
	     fabs(m.m11 - i->m11) < 1e-6)) {
	    set_matrix(i, m.m00, m.m01, m.m10, m.m11);
	}
	double tx, ty;
	transform_back(i, m.tx+i->config_xpad, m.ty+i->config_ypad, &tx, &ty);
	
	PDF_setfont(i->p, fontid, ttf?16.0:1.0);
	PDF_setrgbcolor_fill(i->p, color->r/255.0, color->g/255.0, color->b/255.0);

	char name[32];
	sprintf(name, "%c", glyphnr+32);

	if(fabs(tx - i->lastx) > 0.001 || ty != i->lasty) {
	    PDF_show_xy2(i->p, name, strlen(name), tx, ty);
	} else {
	    PDF_show2(i->p, name, strlen(name));
	}

	i->lastx = tx + glyph->advance;
	i->lasty = ty;
    }
}
Beispiel #6
0
Datei: f4.cpp Projekt: pzinn/M2
void F4GB::do_spairs()
{
  if (hilbert && hilbert->nRemainingExpected() == 0)
    {
      if (M2_gbTrace >= 1)
        fprintf(stderr, "-- skipping degree...no elements expected in this degree\n");
      return;
    }
  reset_matrix();
  reset_syz_matrix();
  clock_t begin_time = clock();

  n_lcmdups = 0;
  make_matrix();

  if (M2_gbTrace >= 5) {
    fprintf(stderr, "---------\n");
    show_matrix();
    fprintf(stderr, "---------\n");
  }

  clock_t end_time = clock();
  clock_make_matrix += end_time - begin_time;
  double nsecs = static_cast<double>(end_time - begin_time);
  nsecs /= CLOCKS_PER_SEC;
  if (M2_gbTrace >= 2)
    fprintf(stderr, " make matrix time = %f\n", nsecs);

  if (M2_gbTrace >= 2)
    H.dump();

  begin_time = clock();
  gauss_reduce(true);
  end_time = clock();
  clock_gauss += end_time - begin_time;

  //  fprintf(stderr, "---------\n");
  //  show_matrix();
  //  fprintf(stderr, "---------\n");

  nsecs = static_cast<double>(end_time - begin_time);
  nsecs /= CLOCKS_PER_SEC;
  if (M2_gbTrace >= 2)
    {
      fprintf(stderr, " gauss time          = %f\n", nsecs);

      fprintf(stderr, " lcm dups            = %ld\n", n_lcmdups);
      if (M2_gbTrace >= 5)
        {
          fprintf(stderr, "---------\n");
          show_matrix();
          fprintf(stderr, "---------\n");
          show_syz_matrix();
          //  show_new_rows_matrix();
        }
    }
  new_GB_elements();
  int ngb = INTSIZE(gb);
  if (M2_gbTrace >= 1) {
    fprintf(stderr, " # GB elements   = %d\n", ngb);
    if (M2_gbTrace >= 5) show_gb_array(gb);
    if (using_syz)
      fprintf(stderr, " # syzygies      = %ld\n", static_cast<long>(syz_basis.size()));
    if (M2_gbTrace >= 5) show_syz_basis();
  }

  clear_matrix();
  clear_syz_matrix();
}