bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange working of plotutils


From: Rajnai Mark
Subject: Strange working of plotutils
Date: Tue, 08 Feb 2005 11:41:49 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040413 Debian/1.6-5


Dear Author,

I have noticed a strange property of plotutils while I tried to draw some pictures into meta file. I had written many program that use functions of libplot and write GNU meta file as output. If I want to visualize or convert these meta files with plot program, the top and the right edge of the picture is incomplete in some cases. It seems this defect depends on the size of the picture or the user coordinate system that is specified by "space" function. I have attached a simple program that should draw some lines at the edge of the domain. It can be compiled with

gcc lines.c -o lines -lplot
The program has 3 arguments: width, height and format of output, and it write result to stdout.
(Ex. lines 100 200 meta)

I would demonstrate this bug(???) via this small program:
- If I choose the size 100x180 with meta output, and I draw result with plot -T X --bitmap-size 100x180, everithing is all right. - If I choose the size 100x200 with meta output, and I draw result with plot -T X --bitmap-size 100x200, the horizontal lines that should be in the uppermost row are missing, but the end of the skew line can be seen in the uppermost row of the picture. - If I choose the size 100x200 with "png" or "X" instead of "meta", every line appears correctly. - I checked the ascii meta files, and it contained all of the lines => it seems the plot program forgets to draw some object that should be on the edges. The problem occures with "plot -T png" or gif as well, and even with drawing points on the edges.

I like this useful package because it's very simple to use. But I don't know if it is a normal working and I my knowledge is incomplete, or those lines (and points) should really be appear.

Best regards,
Mark Rajnai
#include <stdlib.h>
#include <stdio.h> 
#include <plot.h>

int
main(int argc, char**argv)
{
  plPlotter *plotter;
  plPlotterParams *plotter_params;

        // Width and height of plotter area
        int w, h;
        char buff[256];

        if(argc<4)
                {
                        printf("Usage: lines width height display-type\n");
                        printf("Example: lines 200 300 meta\n");
                        exit(1);
                }
        // Let's suppose arguments are OK
        w = atoi(argv[1]);
        h = atoi(argv[2]);

  /* set Plotter parameters */
  plotter_params = pl_newplparams ();
        sprintf(buff,"%sx%s",argv[1],argv[2]);
  pl_setplparam (plotter_params, "BITMAPSIZE", buff);
  pl_setplparam (plotter_params, "META_PORTABLE", "yes");
  /* create a Metafile Plotter with the specified parameters */
  if ((plotter = pl_newpl_r (argv[3], stdin, stdout, stderr,
                             plotter_params)) == NULL)
    {
      fprintf (stderr, "Couldn't create Plotter\n");
      return 1;
    }
  
  /* open it, set up user coordinate system */
  pl_openpl_r (plotter);
  pl_erase_r (plotter);
  pl_space_r (plotter, 0, 0, w-1, h-1);


        // Some red lines at the corners
  pl_pencolor_r (plotter, 65000, 0, 0);
  pl_line_r (plotter, 0, 9, 0, 0);
  pl_line_r (plotter, 0, 0, 9, 0);
  pl_line_r (plotter, w-10, 0, w-1, 0);
  pl_line_r (plotter, w-1, 0, w-1, 9);
  pl_line_r (plotter, 0, h-10, 0, h-1);
  pl_line_r (plotter, 0, h-1, 9, h-1);
  pl_line_r (plotter, w-10, h-1, w-1, h-1);
  pl_line_r (plotter, w-1, h-1, w-1, h-10);

        // Some green lines at upper left periphery
  pl_pencolor_r (plotter, 0, 33500, 0);
  pl_line_r (plotter, 0, h-2, 5, h-1);
  pl_line_r (plotter, 0, h-8, 5, h-7);
  pl_line_r (plotter, 5, h-4, 0, h-5);
  pl_line_r (plotter, 7, h-1, 12, h-1);

        // And a blue line
  pl_pencolor_r (plotter, 0, 0, 50000);
  pl_line_r (plotter, 20, h-2, 30, h-2);

  /* close and delete Plotter */
  pl_closepl_r (plotter);
  if (pl_deletepl_r (plotter) < 0)
    {
      fprintf (stderr, "Couldn't delete Plotter\n");
      return 1;
    }
  return 0;
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]