BOOL Chord(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect, nXStartLine, nYStartLine, nXEndLine, nYEndLine) | |||||
HDC hdc; | /* handle of device context | */ | |||
int nLeftRect; | /* x-coordinate upper-left corner bounding rectangle | */ | |||
int nTopRect; | /* y-coordinate upper-left corner bounding rectangle | */ | |||
int nRightRect; | /* x-coordinate lower-right corner bounding rectangle | */ | |||
int nBottomRect; | /* y-coordinate lower-right corner bounding rectangle | */ | |||
int nXStartLine; | /* x-coordinate line-segment starting point | */ | |||
int nYStartLine; | /* y-coordinate line-segment starting point | */ | |||
int nXEndLine; | /* x-coordinate line-segment ending point | */ | |||
int nYEndLine; | /* y-coordinate line-segment ending point | */ |
The Chord function draws a chord (a closed figure bounded by the intersection of an ellipse and a line segment).
hdc
Identifies the device context.
nLeftRect
Specifies the logical x-coordinate of the upper-left corner of the bounding rectangle.
nTopRect
Specifies the logical y-coordinate of the upper-left corner of the bounding rectangle.
nRightRect
Specifies the logical x-coordinate of the lower-right corner of the bounding rectangle.
nBottomRect
Specifies the logical y-coordinate of the lower-right corner of the bounding rectangle.
nXStartLine
Specifies the logical x-coordinate of the starting point of the line segment.
nYStartLine
Specifies the logical y-coordinate of the starting point of the line segment.
nXEndLine
Specifies the logical x-coordinate of the ending point of the line segment.
nYEndLine
Specifies the logical y-coordinate of the ending point of the line segment.
The return value is nonzero if the function is successful. Otherwise, it is zero.
The (nLeftRect, nTopRect) and (nRightRect, nBottomRect) parameter combinations specify the upper-left and lower-right corners, respectively, of a rectangle bounding the ellipse that is part of the chord. The (nXStartLine, nYStartLine) and (nXEndLine, nYEndLine) parameter combinations specify the endpoints of a line that intersects the ellipse. The chord is drawn by using the selected pen and is filled by using the selected brush.
The figure the Chord function draws extends up to but does not include the right and bottom coordinates. This means that the height of the figure is determined as follows:
nBottomRect – nTopRect
The width of the figure is determined similarly:
nRightRect – nLeftRect
The following example uses a RECT structure to store the points defining the bounding rectangle and uses POINT structures to store the coordinates that specify the beginning and end of the chord:
HDC hdc;
RECT rc = { 10, 10, 180, 140 };
POINT ptStart = { 12, 12 };
POINT ptEnd = { 128, 135 };
Chord(hdc, rc.left, rc.top, rc.right, rc.bottom,
ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);