[GRASS5] R_cont_rel & R_polygon_rel

Huidae Cho grass4u at gmail.com
Thu Feb 16 03:34:46 EST 2006


Hi,

I tried to draw two boxes with R_cont_rel and R_polygon_rel (or R_box_rel).
Even if I used the same coordinates, these two commands produced boxes with
different areas.

For example,

R_move_abs(100, 100);
R_cont_rel(1,0);
R_cont_rel(0,-1);
R_cont_rel(-1,0);
R_cont_rel(0,1);

creates a 2*2 pixel box.  four edges are: (100,100)-(101,100)-(101,99)-(100,99).


R_move_abs(100, 100);
R_box_rel(1,1);

or

R_move_abs(100, 100);
xarr[0] = 0; yarr[0] = 0;
xarr[1] = 1; yarr[1] = 0;
xarr[2] = 0; yarr[2] = -1;
xarr[3] = -1; yarr[3] = 0;
xarr[4] = 0; yarr[4] = 1;
R_polygon_rel(xarr, yarr, 4);

creates a 1*1 pixel box.  (100, __99__).


R_move_abs(0,0);
xarr[0] = 0; yarr[0] = 0;
xarr[1] = 1; yarr[1] = 0;
xarr[2] = 0; yarr[2] = -1;
xarr[3] = -1; yarr[3] = 0;
xarr[4] = 0; yarr[4] = 1;
R_polygon_rel(xarr, yarr, 4);

draws nothing. that is (0, -1).


R_box_*() commands use XFillRectangle() which has width and height arguments.
The width and height of a box are given by x2-x1 and y2-y1 respectively, so we
lose one pixel both from width and height.  It looks like XFillPolygon() also
behaves similarly.  It seems trivial, but it's sometimes really annoying.

What do you think about this?

Huidae Cho




More information about the grass-dev mailing list