|SQR Lines, Boxes and Images||KEVIN RESCHENBERG|
GRAPHIC [HORZ-LINE|VERT-LINE|BOX] and
PRINT-IMAGE statements can be used to draw lines and boxes, add
shading, and print pictures.
Positioning these elements around your text can be a frustrating experience unless you use a
one-point coordinate grid system as described in the last post. Let's do that, and
begin with three simple examples showing the positioning of text and a box:
alter-printer font=4 point-size=48 ! Helvetica
! Text first, shaded box second
print 'xy' (1, 1)
graphic (1, 1, 50) box 20 1 10
! Shaded box first, text second
graphic (1, 60, 50) box 20 1 10
print 'xy' (1, 60)
! Text first, unshaded box second
print 'xy' (1, 120)
graphic (1, 120, 50) box 20 1 0
The parameters in the box statement are: (row, column, width) BOX depth line-width shading-percent.
First, look carefully at the positioning of text and box. Both begin at exactly the same position. You can see that this position
is the top left corner of the box but is not the top left corner of the text—instead, it's the left edge of the baseline
of the text. You might think that a box beginning in the same position as text would enclose the text, but that's not how it works.
Next, note the order in which the text and box are printed. In the first example the shaded box prints second and therefore overlays
part of the text. The second example shows the text overlaying the box because it was printed after the box. In the third example the box is
printed after the text but does not affect the text because the box is not shaded—in effect, the box is transparent and the
text shows through it.
Other variations of the same
GRAPHIC statement will produce horizontal or vertical lines. This example prints
two very thin lines, and then to the right, a box of the same size. The "1" after "-line" specifies a line thickness of 1 decipoint, or 1/720 inch.
graphic (1, 1, 10) horz-line 1
graphic (1, 1, 10) vert-line 1
graphic (1, 20, 10) box 10 1 0
SQR 6x (PeopleSoft SQR 8x)
This result was obtained on PeopleSoft SQR version 8, which is a slightly modified variant of
SQR version 6. It is magnified 200%. You will note two significant problems with this. First, all of the lines should be the same
thickness, but the vertical line is much thicker than the others. It appears that the line thickness for vertical lines is interpreted
as points instead of decipoints, so the line is 10 times the specified thickness. Second, both the horizontal line and the box begin on row/line 1
but the box appears slightly higher.
In a later version (SQR 11), all lines are the same thickness as expected. The alignment, though, is the same as in the
If your version of SQR has the vertical line bug, how do you get around it? By using thicker
lines, by drawing overlapping boxes, or by using a major kludge described below!
Here we have an image shown in two different sizes. The first one is surrounded by a box at the same position, to show
PRINT-IMAGE uses the same positioning as
GRAPHIC BOX . In the middle is a .JPG file I created
that consists of just a single red pixel. Over on the right is a normal photo.
print-image (1, 1) type=jpeg-file source='x:\sqr-bug.jpg'
graphic (1, 1, 11) box 13 1 0
print-image (1, 20) type=jpeg-file source='x:\sqr-bug.jpg'
print-image (1, 50) type=jpeg-file source='x:\red-dot.jpg'
print-image (1,160) type=jpeg-file source='x:\colorado.jpg'
The small image to the left is an 11 x 13-pixel .JPG. But since points don't equal pixels, even this small image has been scaled up by SQR
(and therefore slightly distorted, especially because the source picture is so small). In contrast, the landscape at the right
has been scaled down to about 3% of its original dimensions.
IMAGE-SIZE is required. This means that you can't just print a picture in its actual size as you could with HTML.
You need to determine what size to use (in points) and then be careful to scale both dimensions in the same ratio. If your image is
11 pixels wide and 13 pixels high, as in the first example, you could use 11 points by 13 points or any multiple, such as 22 x 26.
Sometimes you'll need to round one of the dimensions up or down to the next point. For example, 16.5 by 19.5 would be
a multiple of this image size but it must be rounded to 16 x 19 or 17 x 20. This would give us approximately the desired size, but the image would
be slightly distorted due to the aspect ratio rounding.
Now for the kludge I mentioned above. Can you draw a very thin vertical line if your version of SQR has the vertical line bug?
(Or if you don't have that problem but want lines in a color other than black?)
Well, you could use Paint to create a small image and then stretch it out vertically. Would a one-pixel black dot work? No, because that one pixel
would be scaled up to one point and then we're right back where we started. But you could create an image with a few white pixels
next to one black pixel. That image would be scaled down and you'd get a thin black (or actually grayish, depending on the number
of white pixels) line. I have used this
technique to draw very thin gray lines (horizontal and vertical) and it looks good.
The one-pixel red picture scaled up to a box shows one way to use color on a page. SQR provides other options, as we'll see
next time in using color in SQR reports.