MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / PSL_plotlatexeps

Function PSL_plotlatexeps

src/postscriptlight.c:4275–4320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4273}
4274
4275int PSL_plotlatexeps (struct PSL_CTRL *PSL, double x, double y, double xsize, double ysize, int justify, unsigned char *buffer, double *rgb, struct imageinfo *h) {
4276 /* Plots an Latex EPS image
4277 * x,y : Position of image (in plot coordinates)
4278 * xsize, ysize : Size of image (in user units)
4279 * justify : Indicate which corner (x,y) refers to (see graphic)
4280 * buffer : EPS file (buffered)
4281 * rgb : Font color
4282 * h : Image buffer header
4283 *
4284 * 9 10 11
4285 * |----------------|
4286 * 5 <image> 7
4287 * |----------------|
4288 * 1 2 3
4289 */
4290 double width, height;
4291
4292 /* If one of [xy]size is 0, keep the aspect ratio */
4293 width = h->trx - h->llx;
4294 height = h->try - h->lly;
4295 if (PSL_eq (xsize, 0.0)) xsize = ysize * width / height;
4296 if (PSL_eq (ysize, 0.0)) ysize = xsize * height / width;
4297
4298 /* Correct origin (x,y) in case of justification */
4299 if (justify > 1) { /* Move the new origin so (0,0) is lower left of box */
4300 x -= 0.5 * ((justify + 3) % 4) * xsize;
4301 y -= 0.5 * (int)(justify / 4) * ysize;
4302 }
4303
4304 PSL_command (PSL, "PSL_eps_begin\n");
4305 PSL_command (PSL, "%s\n", psl_putcolor (PSL, rgb, 0));
4306 PSL_command (PSL, "%d %d T %.12g %.12g scale\n", psl_ix (PSL, x), psl_iy (PSL, y), xsize * PSL->internal.dpu / width, ysize * PSL->internal.dpu / height);
4307 PSL_command (PSL, "%.12g %.12g T\n", -h->llx, -h->lly);
4308 PSL_command (PSL, "N %.12g %.12g M %.12g %.12g L %.12g %.12g L %.12g %.12g L P clip N\n", h->llx, h->lly, h->trx, h->lly, h->trx, h->try, h->llx, h->try);
4309 PSL_command (PSL, "%%%%BeginDocument: psimage.eps\n");
4310 if (PSL->internal.memory) {
4311 psl_prepare_buffer (PSL, h->length); /* Make sure we have enough memory to hold the EPS */
4312 strncat (&(PSL->internal.buffer[PSL->internal.n]), (char *)buffer, h->length);
4313 PSL->internal.n += h->length;
4314 }
4315 else
4316 fwrite (buffer, 1U, (size_t)h->length, PSL->internal.fp);
4317 PSL_command (PSL, "%%%%EndDocument\n");
4318 PSL_command (PSL, "PSL_eps_end\n");
4319 return (PSL_NO_ERROR);
4320}
4321
4322#ifdef PSL_EXACT_LINE
4323

Callers 3

gmtplot_map_labelFunction · 0.85
gmt_map_textFunction · 0.85
gmtplot_place_latex_epsFunction · 0.85

Calls 5

PSL_commandFunction · 0.85
psl_putcolorFunction · 0.85
psl_ixFunction · 0.85
psl_iyFunction · 0.85
psl_prepare_bufferFunction · 0.85

Tested by

no test coverage detected