Describes the rectangle in the window, with rounded rectangles and ellipses can only be drawn from the GDI in the axial direction. If someone wants to rotate or skew in Windows NT, he can use the world coordinate system to transform. Unfortunately, under Windows 95/98, there is no world coordinate system transform. As a cross-platform solution, you need to do more work. The rectangle can be simulated by quadrilateral so that it can rotate and skew. However, what should I do if the ellipse is? There are basically three options. Both options use a custom function to draw an ellipse. The mathematical model of the ellipse is relatively simple, and there is also a modified Bresenham equation for rotating ellipses in standard text. However, this method must perform the raster operation himself, which is complex when drawing a wide line. This effort is only to draw an ellipse with a connection-free line segment worthwhile to a disengaged screen (such as DirectDraw) or bitmap. The actual line can be called via lineto (...) or POLYLINE (...) graphics interface. You can complete the approximation of the ellipse, or use the GDI's FlattenPath (...) function. Use the Bezier curve to approximate the ellipse. This method is illustrated here. Draw an ellipse with the Bezier curve to use four Bessel curves, each represents 90 degrees of the original axial ellipse, so that a quite approximate ellipse can be obtained, and the maximum error is only 0.027%. This maximum error is equivalent to the error of the ellipse of the long diameter 3700 is less than one pixel, which has exceeded the accuracy we have requested. The advantage is simple. It only needs four GDI calls. The calculation price of the Bessel curve control point is very small. Quick you can use the new graphics card to draw hardware support. On my system, this and call the GDI function Ellipse (...) to draw an elliptical speed ratio, if not faster, at least just as fast. Changes Because the Bezier curve is unchanged at the rotation, scaling and removal, only the same change is required when the ellipse is changed. Coincidentally, because each point on a three Bessel curve is a control point gravity combination, the relationship between the control points on the ribbed mapping is constant. The device is independent. This doesn't need to do this when using the Bezier curve. There is also an advantage that the ellipse can be output to the painting program through the element file, such as CorelDRAW, which can have a zoom graphic in which the distortion can be used. The process begins with an axial elliptical external boundary rectangle (using a normal GDI). 13 defined 4 composed of Elliptical Besier curves (following standard 0-12) can be calculated using an empirical constant. The following code generates a control point (e.g., mm_text) of the mapping mode in the Y-axis positive direction. When the Y-axis positive direction, the offset amount is set to a negative value as long as it is shown in the comment.
// Create Points To Simulate Ellipse Using Beziers // Using Bezier Curve Creating Points, Analog Elliptical Void Ellipsetobezier (CRECT & R, CPOINT * CCTLPT) // Magical Constant To Map Ellipse to Beziers // / 3 * (SQRT (2) -1) // Map the ellipse into the constant of the Bezier curve 2/3 * (SQRT (2) -1) const double etobconst = .2761423749154; csize offset ((int) (R.Width () * tobconst, (INT) (R.Height () * etobconst); // use the folload line instead for mapping systems where ver y is updwards // When the Y-axis positive direction, use the following row // CSIZE OFFSET ((int (R.Width () * etobconst), - (int) (R.Height () * etobconst); CPoint Center ((R.L.L.Right) / 2, (R.Top R.BOTTOM) / 2); CCTLPT [0] .x = // ---------------------- / cctlpt [1] .x = // / cctlpt [ 11] .x = // 2___3___4 / ccTLPT [12] .x = r.Left; // 1 5 / cctlpt [5] .x = // | | / cctlpt [6] .x = // | | / cctlpt [7] .x = r.right; // 0 12 6 / ccTLPT [2] .x = // | | / cctlpt [10] .x = center.x - offset.cx; // | | / cctlpt [4] .x = // 11 7 / cctlpt [ 8] .x = center.x offset.cx; // 10___9___8 / cctlpt [3] .x = // / cctlpt [9] .x = center.x; // ---------- -------------- * CCTLPT [2] .y = cctlpt [3] .y = cctlpt [4] .y = r.top; cctlpt [8] .y = cctlpt [9 ] .y = cctlpt [10] .y = r.bottom; cctlpt [7] .y = cctlpt [11] .y = center.y offet.cy; cctlpt [1] .y = cctlpt [5] .y =