|
From: Daniel J S. <dan...@ie...> - 2006-07-16 18:55:58
|
Ethan A Merritt wrote: > On Saturday 15 July 2006 01:04 am, Timoth=C3=A9e Lecomte wrote: >=20 >>this one comes from graphics.c:3408 : >> >>x =3D xl; >>y =3D yb; >>w =3D xr - xl + 1; >>h =3D yt - yb + 1; >>(*t->fillbox) (style, x, y, w, h); >>(*t->move) (xl, yb); >>(*t->vector) (xl, yt); >>(*t->vector) (xr, yt); >>(*t->vector) (xr, yb); >>(*t->vector) (xl, yb); >> >>I think these "+1" should be removed for consistency with the other use= s. >=20 >=20 > I'm not so sure. > The length in pixels of a line that starts at pixel x1 and ends at pixe= l x2 > is (x2-x1)+1. So this code looks correct to me. It may well be that = some > terminals interpret w and h incorrectly, but that would be an error in = the > individual terminal driver, not the core code.=20 >=20 > I guess the fundamental question is whether "width" should be interpret= ed > as "number of horizontal pixels" or "x_right - x_left". These are not > the same number. The former makes sense if you are thinking in terms o= f > terminal coords (pixels); the latter makes sense if you are thinking in= =20 > terms of a continuous variable (plot x coordinate). My initial preference would be to think along the lines of "plot x coordi= nate", perhaps for the simple reason of however this thread got started. = If you plot a series of rectangles to "cover" a range staying with x_rig= ht - x_left avoids there being an overlap of one pixel. E.g., series of incremented ranges: 0-9 10-19 20-29 etc. For histograms or whatever. Saying that the width of the rectangle shoul= d be 11 instead of 10 would mean that there is going to be one rectangle = of the bunch that is 9 pixels and one which is 11 pixels. Dan |