Microsoft KB Archive/59319

= BUG: Polygon ROM CALLs Top-Justify Within Their Rectangle =

Article ID: 59319

Article Last Modified on 11/21/2006



This article was previously published under Q59319



SYMPTOMS
The vertical position of a polygon manipulated by the ERASEPOLY, INVERTPOLY, PAINTPOLY, and FILLPOLY Toolbox ROM routines is directly related to the y coordinate of the upper-left corner of the rectangle enclosing the polygon that is passed to those routines. This is not the case with FRAMEPOLY.

Microsoft has confirmed this to be a bug with Microsoft QuickBasic Version 1.00 for the Macintosh. We are currently researching this problem and will post further information here as it becomes available.



MORE INFORMATION
In other words, if the y coordinate of the upper-left corner of the rectangle enclosing the polygon is less than the y coordinate of the uppermost point of the specified polygon, then the y coordinate of the uppermost point of the polygon will be drawn as having the same value as the y coordinate of the upper-left corner of the rectangle enclosing the polygon. The y coordinates of the remaining points in the polygon will be adjusted upwards accordingly.

For example, assume the y coordinate of the uppermost point in a polygon is 200 and the y coordinate of the upper-left corner of the rectangle enclosing the polygon is passed to the polygon-drawing routines as 100. When FRAMEPOLY is called, the y coordinate of the uppermost point in the polygon actually drawn will be 200. However, when FILLPOLY, INVERTPOLY, ERASEPOLY, or PAINTPOLY are called, the y coordinate of the uppermost point in the polygon drawn will be converted to 100 because that is the value of the y coordinate of the upper-left corner of the rectangle enclosing the polygon. Remember that the coordinates of this rectangle are passed to the routines as a parameter and it is possible (and workable in the case of FRAMEPOLY) to pass a rectangle whose sides the polygon won't come close to touching.

To avoid this behavior, make sure that the y coordinate of the upper-left corner of the rectangle passed to the FILLPOLY, INVERTPOLY, ERASEPOLY, and PAINTPOLY routines is the same as the y coordinate of the highest point in the polygon. Another workaround is to invoke the equivalent ROM routines FramePgon, FillPgon, InvertPgon, ErasePgon, and PaintPgon with QuickBasic's ToolBox statement to draw polygons. The problem does not occur with these routines.

The following example program illustrates the problem. It first uses FRAMEPOLY to draw a polygon and then prompts the user to perform other operations (FILLPOLY, INVERTPOLY, ERASEPOLY, and PAINTPOLY) on the same polygon. These other operations will affect another region above the original polygon even though the same polygon coordinates are given. This is because the y coordinate of the upper-left corner of the rectangle enclosing the polygon that is passed to the routines (100) is less than the y coordinate of the uppermost point in the polygon (200). The same problem does NOT occur if QuickBasic's ToolBox statement is used to directly invoke the ROM routines FramePgon, FillPgon, InvertPgon, ErasePgon, and PaintPgon in a similar manner.

Code Example
DIM polygon%(12) DIM pattern%(3)

polygon%(0) = 26                         'Number of bytes in array.

polygon%(1) = 100 : polygon%(2)  = 10    'Coordinates of rectangle polygon%(3) = 300 : polygon%(4)  = 500   'enclosing the polygon.

polygon%(5) = 200 : polygon%(6)  = 180   'Coordinates of the polygon%(7) = 260 : polygon%(8)  = 220   'endpoints of the polygon. polygon%(9) = 290 : polygon%(10) = 390 polygon%(11) = 200 : polygon%(12) = 180

FOR i = 0 to 3         'Create a pattern for use with FILLPOLY. pattern%(i) = 1234 NEXT i

FRAMEPOLY VARPTR(polygon%(0))

LOCATE 1,1 PRINT &quot;Click to fill the polygon.&quot; WHILE MOUSE(0) <> -1 WEND FILLPOLY VARPTR(polygon%(0)),VARPTR(pattern%(0))

LOCATE 2,1 PRINT &quot;Click to invert the polygon.&quot; WHILE MOUSE(0) <> -1 WEND INVERTPOLY VARPTR(polygon%(0))

LOCATE 3,1 PRINT &quot;Click to erase the polygon.&quot; WHILE MOUSE(0) <> -1 WEND ERASEPOLY VARPTR(polygon%(0))

LOCATE 4,1 PRINT &quot;Click to paint the polygon.&quot; WHILE MOUSE(0) <> -1 WEND PAINTPOLY VARPTR(polygon%(0))

LOCATE 5,1 PRINT &quot;Click to end.&quot; WHILE MOUSE(0) <> -1 WEND

Additional query words: MQuickB

Keywords: kbbug KB59319

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.