Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

void PoDoFo::PdfPainter::ConvertRectToBezier ( double  dX,
double  dY,
double  dWidth,
double  dHeight,
double  pdPointX[],
double  pdPointY[] 
) [private]

Coverts a rectangle to an array of points which can be used to draw an ellipse using 4 bezier curves.

The arrays plPointX and plPointY need space for at least 12 longs to be stored.

Parameters:
dXx position of the bounding rectangle
dYy position of the bounding rectangle
dWidthwidth of the bounding rectangle
dHeightheight of the bounding rectangle
pdPointXpointer to an array were the x coordinates of the resulting points will be stored
pdPointYpointer to an array were the y coordinates of the resulting points will be stored

Definition at line 1323 of file PdfPainter.cpp.

Referenced by DrawEllipse(), and FillEllipse().

{
    // this function is based on code from:
    // http://www.codeguru.com/Cpp/G-M/gdi/article.php/c131/
    // (Llew Goodstadt)

    // MAGICAL CONSTANT to map ellipse to beziers
    //                          2/3*(sqrt(2)-1) 
    const double dConvert =     0.2761423749154;

    double dOffX    = dWidth  * dConvert;
    double dOffY    = dHeight * dConvert;
    double dCenterX = dX + (dWidth / 2.0); 
    double dCenterY = dY + (dHeight / 2.0); 

    pdPointX[0]  =                            //------------------------//
    pdPointX[1]  =                            //                        //
    pdPointX[11] =                            //        2___3___4       //
    pdPointX[12] = dX;                        //     1             5    //
    pdPointX[5]  =                            //     |             |    //
    pdPointX[6]  =                            //     |             |    //
    pdPointX[7]  = dX + dWidth;               //     0,12          6    //
    pdPointX[2]  =                            //     |             |    //
    pdPointX[10] = dCenterX - dOffX;          //     |             |    //
    pdPointX[4]  =                            //    11             7    //
    pdPointX[8]  = dCenterX + dOffX;          //       10___9___8       //
    pdPointX[3]  =                            //                        //
    pdPointX[9]  = dCenterX;                  //------------------------//

    pdPointY[2]  =
    pdPointY[3]  =
    pdPointY[4]  = dY;
    pdPointY[8]  =
    pdPointY[9]  =
    pdPointY[10] = dY + dHeight;
    pdPointY[7]  =
    pdPointY[11] = dCenterY + dOffY;
    pdPointY[1]  =
    pdPointY[5]  = dCenterY - dOffY;
    pdPointY[0]  =
    pdPointY[12] =
    pdPointY[6]  = dCenterY;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index