📄 rect5.c
字号:
newEdge = &qaEdgeBuffer[7];
mwSBQA(newEdge, xRadius, yRadius, thisRightEdge, nextBottomEdge, -1, -1);
/* Now shift the edges down and right 1, to compensate for filler
characteristics and to make 1 wide be really 1 wide, and add to the GET. */
newEdge = &qaEdgeBuffer[4];
newEdge->CurrentX++; /* shift 1 to the right */
newEdge->StartY++; /* shift down 1 */
newEdge->Count--; /* skip the bottommost point */
if (newEdge->Count != 0) /* check if more to do */
{
AddToGETYXSorted(newEdge); /* insert the new edge in GET, YX sorted */
newEdge = &qaEdgeBuffer[5];
newEdge->CurrentX--; /* shift 1 to the left */
newEdge->StartY++; /* shift down 1 */
newEdge->Count--;
AddToGETYXSorted(newEdge); /* insert the new edge in GET, YX sorted */
}
newEdge = &qaEdgeBuffer[6];
newEdge->CurrentX++; /* shift 1 to the right */
newEdge->StepVector(newEdge); /* advance Y by 1 (skip first point) */
newEdge->Count--;
if (newEdge->Count != 0) /* check if more to do */
{
AddToGETYXSorted(newEdge); /* insert the new edge in GET, YX sorted */
newEdge = &qaEdgeBuffer[7];
newEdge->CurrentX--; /* shift 1 to the left */
newEdge->StepVector(newEdge); /* advance Y by 1 (skip first point) */
newEdge->Count--; /* skip the topmost point */
AddToGETYXSorted(newEdge); /* insert the new edge in GET, YX sorted */
}
/* now add the vertical outer sides, if applicable */
vertDirection = 1; /* assume bottom and top arcs don't overlap, so
vertical edges can run in same direction as arcs */
nextTopEdge = rXmin.Ymin + yRadius + 1; /* start on the scan line after
the top arc ends */
nextBottomEdge = rXmin.Ymax - yRadius; /* top of bottom arc */
if (nextBottomEdge == nextTopEdge) return; /* distance is 0; edges fit perfectly */
if (nextBottomEdge < nextTopEdge)
{ /* edges overlap by 1; neutralize 1 so we get correct winding rule counts */
/* point back to bottom scan of top arc; make the edges 1 long, starting
at the scan line that ends the top edges (inclusive), to neutralize one
of the arcs; the top & bottom arcs overlap by 1, and that gives one winding
count too many */
nextBottomEdge = nextTopEdge;
nextTopEdge--;
vertDirection = -1; /* edges have to run opposite arcs in order to
neutralize one of them */
}
/* add the vertical edges */
nextBottomEdge -= nextTopEdge; /* distance between top & bottom, not inclusive */
newEdge = &qaEdgeBuffer[9];
mwSV((Vedge *)newEdge, (rXmin.Xmin + 1), nextTopEdge, nextBottomEdge, vertDirection);
AddToGETYXSorted(newEdge); /* insert the new edge in GET, YX sorted */
vertDirection = -vertDirection; /* reverse direction for other side */
newEdge = &qaEdgeBuffer[10];
mwSV((Vedge *)newEdge, rXmin.Xmax, nextTopEdge, nextBottomEdge, vertDirection);
AddToGETYXSorted(newEdge); /* insert the new edge in GET, YX sorted */
return;
}
/* Function FrameRoundRect draws an outline of the rounded rectangle
defined by rectangle argR with corner diameters DiaX and DiaY.
The current "pen" posntion is not affected by FrameRoundRect. */
void FrameRoundRect(rect *argR, int DiaX, int DiaY)
{
rect rXminBase; /* base rectangle */
short grafErrValue; /* error value */
short halfWidth; /* offsets to edges of square pen */
short halfHeight;
int i;
qarcState *newEdge = 0; /* pointer to new edge to add to table */
argDiaX = DiaX; /* get passed parameters */
argDiaY = DiaY;
for (i = 0; i < 12; i++) qaEdgeBuffer[i].NextEdge = 0; /* GET is initially empty */
if (grafPort.pnLevel < 0) return; /* nothing to do */
if (grafPort.portFlags & pfVirtual) /* check if virtual mode */
{
V2GSIZE(argDiaX, argDiaY, &argDiaX, &argDiaY); /* Virtual To Global size */
}
rXmin = *argR; /* get rectangle */
if (globalLevel > 0)
{
/* convert from user to global */
U2GR(rXmin, &rXmin, 1);
}
if (!(grafPort.pnFlags & pnSizeFlg)) /* thin or wide line? */
{ /* thin */
rXWidth = rXmin.Xmax - rXmin.Xmin; /* width */
if (rXWidth < 0)
{
grafErrValue = c_FrameRou + c_NullRect; /* bad rectangle */
nuGrafErr(grafErrValue); /* report error */
return;
}
rXHeight = rXmin.Ymax - rXmin.Ymin; /* height */
if (rXHeight < 0)
{
grafErrValue = c_FrameRou + c_NullRect; /* bad rectangle */
nuGrafErr(grafErrValue); /* report error */
return;
}
AddOuterEdges(newEdge); /* set up the outer edges first */
if ((rXWidth > 0) && (rXHeight > 0))
{
AddInnerEdges(newEdge); /* need inner edges too */
}
}
else
{ /* wide */
/* Draws a wide-line framed rounded rectangle. The approach is the same
as for thin framed rounded rects, except that the outer edges are moved
out by the X and Y pen radii, and the inner arcs are moved in similarly. */
rXminBase = rXmin;
/* For odd pen dimensions, we can be symmetric about the thin edge. For
even, we bias the extra pixel to the outside of the frame. */
/* set up the four outer arcs first and rounded up */
halfWidth = (grafPort.pnSize.X >> 1);
rXmin.Xmin -= halfWidth;
rXmin.Xmax += halfWidth;
halfHeight = (grafPort.pnSize.Y >> 1);
rXmin.Ymin -= halfHeight;
rXmin.Ymax += halfHeight;
rXWidth = rXmin.Xmax - rXmin.Xmin; /* width */
if (rXWidth < 0)
{
grafErrValue = c_FrameRou + c_NullRect; /* bad rectangle */
nuGrafErr(grafErrValue); /* report error */
return;
}
rXHeight = rXmin.Ymax - rXmin.Ymin; /* height */
if (rXHeight < 0)
{
grafErrValue = c_FrameRou + c_NullRect; /* bad rectangle */
nuGrafErr(grafErrValue); /* report error */
return;
}
AddOuterEdges(newEdge); /* set up the outer edges first */
/*Inner arcs are pulled in from frame edge by pen radii. For odd
pen dimensions, we can be symmetric between inner and outer edge
displacements. For even pen dimensions, we bias the extra pixel
to the outside. */
halfWidth = ((grafPort.pnSize.X - 1) >> 1);
rXmin.Xmin = rXminBase.Xmin + halfWidth;
rXmin.Xmax = rXminBase.Xmax - halfWidth;
halfHeight = ((grafPort.pnSize.Y - 1) >> 1);
rXmin.Ymin = rXminBase.Ymin + halfHeight;
rXmin.Ymax = rXminBase.Ymax - halfHeight;
rXWidth = rXmin.Xmax - rXmin.Xmin; /* width */
rXHeight = rXmin.Ymax - rXmin.Ymin; /* height */
if ((rXWidth >= 0) && (rXHeight > 0))
{
AddInnerEdges(newEdge); /* need inner edges too */
}
}
/* draw the oval and done! */
mwScanGET((void **)&GETPtr, (blitRcd *)&rFillRcd[0], fillRcdSize, cmplx, 1, 0);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -