short Escape(hdc, SET_POLY_MODE, sizeof(int),lpMode, NULL)
The SET_POLY_MODE printer escape sets the poly mode for the device driver. The poly mode is a state variable indicating how to interpret calls to graphics device interface (GDI) Polygon and Polyline functions.
The SET_POLY_MODE escape enables a device driver to draw shapes (such as Bezier curves) not directly supported by GDI. This permits applications that draw complex curves to send the curve description directly to a device without having to simulate the curve as a polygon with a large number of points.
hdc
HDC Identifies the device context.
lpMode
LPINT Points to a short integer specifying the desired poly mode. The poly mode is a state variable indicating how points in Polygon or Polyline function calls should be interpreted. Device drivers are not required to support all possible modes. A device driver returns zero if it does not support the specified mode. The lpMode parameter may be one of the following values:
Value | Meaning |
PM_POLYLINE (1) | Points define a conventional polygon or polyline. |
PM_BEZIER (2) | Points define a sequence of 4-point Bezier spline curves. The first curve passes through the first four points, with the first and fourth points as endpoints and the second and third points as control points. Each subsequent curve in the sequence has the endpoint of the previous curve as its start point, the next two points as control points, and the third as its endpoint. |
The last curve in the sequence is permitted to have fewer than four points. If the curve has only one point, it is considered a point. If it has two points, it is a line segment. If it has three points, it is a parabola defined by drawing a Bezier curve with the first and third points as endpoints and the two control points equal to the second point. | |
PM_POLYLINESEGMENT (3) | Points specify a list of coordinate pairs. Line segments are drawn connecting each successive pair of points. |
PM_POLYSCANLINE (4) | Points specify a list of coordinate pairs. Line segments are drawn connecting each successive pair of points. Each line segment is a nominal-width line drawn with the current brush. Each line segment must be strictly vertical or horizontal, and scan lines must be passed in strictly increasing or decreasing order. This mode is only used for polygon calls. |
The return value is the previous poly mode. If the return value is zero, the device driver did not handle the request.
This escape is used only by PostScript printer drivers.
An application should issue the SET_POLY_MODE escape before it draws a complex curve. It should then call the Polyline or Polygon function with the desired control points defining the curve. After drawing the curve, the application should reset the driver to its previous state by issuing the SET_POLY_MODE escape.
Polyline calls draw using the currently selected pen.
Polygon calls draw using the currently selected pen and brush. If the start point and endpoint are not equal, a line is drawn from the start point to the endpoint before the polygon (or curve) is filled.
GDI treats Polygon calls using PM_POLYLINESEGMENT mode exactly the same as Polyline calls.
Four points define a Bezier curve. GDI generates the curve by connecting the first and second, second and third, and third and fourth points. GDI then connects the midpoints of these consecutive line segments. Finally, GDI connects the midpoints of the lines connecting the midpoints, and so forth.
The line segments drawn in this way converge to a curve defined by the following parametric equations, expressed as a function of the independent variable t.
X(t) = (1-t) 3 x1 + 3(1-t) 2 tx2 + 3(1-t)t 2 x3 + t 3 x4
Y(t) = (1-t) 3 y1 + 3(1-t) 2 ty2 + 3(1-t)t 2 y3 + t 3 y4
The points (x1, y1), (x2, y2), (x3, y3) and (x4, y4) are the control points defining the curve. The independent variable t varies from 0 to 1.
Primitive types other than PM_BEZIER and PM_POLYLINESEGMENT may be added to this escape in the future. Applications should check the return value from this escape to determine whether the driver supports the specified poly mode.