📄 line9.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1997 - 1999 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* LINE9.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* This file contains the POLYLINE function. */
/* */
/* AUTHOR */
/* */
/* Robert G. Burrill, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* None */
/* */
/* DEPENDENCIES */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* BobB 5/17/99 Corrected test conditions */
/* */
/*************************************************************************/
#include "meta_wnd.h"
#include "metconst.h" /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h" /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "metmacs3.h"
/* Function POLYLINE draws the specified line series using the current line
style for connecting multiple lines. If PTCNT is less than zero (0), an
additional line will be drawn to the first point, closing the polygon (used
by FramePoly), and the absolute value of PTCNT is used as the count. */
void PolyLine( short PTCNT, point *PTS )
{
int absCNT; /* abs(PTCNT) */
int i = 0;
short TempX;
short TempY;
void (*lineExecPntr)();
lineExecPntr = (void (*)()) lineExecIDV;
/* BobB 5/17/99 - corrected the following line for the test condition
if (grafPort.pnFlags && pnSizeFlg) */ /* What kind of line are we handling? */
if (!(grafPort.pnFlags & pnSizeFlg)) /* What kind of line are we handling? */
{
/* Thin line does not care about re-drawing of points that cross lines, but
it does care that vertices only get drawn for one of the two entering lines
(not twice, that is), so we'll have to go through the default blitRcd and
use skipLast. Note that this is NOT the same as calling LineTo with the end
point backed off, as THAT would draw a different line. */
DrawThin:
grafBlist.skipStat = SkipLast; /* don't draw the last point */
grafBlit.blitCnt = 1; /*we'll draw just one segment at a time */
TempX = PTS[0].X; /* get the start coordinates of the */
TempY = PTS[0].Y; /* first line segment */
if (globalLevel > 0)
{
/* convert from user to blit rcd */
U2GP(TempX, TempY, &grafBlist.Xmin, &grafBlist.Ymin, 1);
}
else
{
grafBlist.Xmin = TempX; /* set them into blit rcd */
grafBlist.Ymin = TempY;
}
/* Calculate absolute value of the count of vertices in polyline */
if (PTCNT == 0) return; /* nothing to do */
if (PTCNT < 0) /* need to close polygon (connect last point to first point) */
{
absCNT = 1 - PTCNT; /* negate and add one extra close point */
}
else
{
absCNT = PTCNT;
}
/* calculate number of vectors = point count - 1;
subtract one more since the last vector is handled specially */
absCNT = absCNT - 2;
if (absCNT == 0 ) goto DoLastSegment; /* only one vector to draw */
if (absCNT < 0 ) goto ThinDoneNoSkip; /* only one point to draw */
for (i = 1; i <= absCNT; i++) /* advance to the next polyline vertex */
{
TempX = PTS[i].X; /* set the end coordinates of this line */
TempY = PTS[i].Y;
if (globalLevel > 0)
{
/* convert from user to blit rcd */
U2GP(TempX, TempY, &grafBlist.Xmax, &grafBlist.Ymax, 1);
}
else
{
grafBlist.Xmax = TempX; /* set them into blit rcd */
grafBlist.Ymax = TempY;
}
lineExecPntr(&grafBlit); /* call the current line routine with the
default blitRcd */
grafBlist.Xmin = grafBlist.Xmax; /* set the start coordinates of next */
grafBlist.Ymin = grafBlist.Ymax;
}
DoLastSegment:
/* If the original count was < 0, we need to close the polygon, otherwise we
need to draw the last segment without skipping the last point. */
if (PTCNT >= 0) goto DrawLastSeg; /* close polygon? */
i = 0; /* yes, close the polygon */
goto ThinDone; /* draw the segment with SkipLast */
DrawLastSeg: /* draw the last segment of the
polyline, including the last point */
i = absCNT + 1; /* advance to the final vertex in the polyline */
ThinDoneNoSkip:
grafBlist.skipStat = NoSkip; /* draw the last point, this once */
ThinDone:
TempX = PTS[i].X; /* set the end coordinates of the last */
TempY = PTS[i].Y;
if (globalLevel > 0)
{
/* convert from user to blit rcd */
U2GP(TempX, TempY, &grafBlist.Xmax, &grafBlist.Ymax, 1);
}
else
{
grafBlist.Xmax = TempX; /* set them into blit rcd */
grafBlist.Ymax = TempY;
}
lineExecPntr(&grafBlit); /* call the current line routine with the
default blitRcd */
return;
}
/* ======================================================================
Wide line may be either square or oval pen; figure out which. */
/* BobB 5/17/99 - corrected the following line for the test condition
if (grafPort.pnFlags && pnShapeFlg) */ /* square or oval pen? */
if (grafPort.pnFlags & pnShapeFlg) /* square or oval pen? */
{
DoSquare:
/* Square pen, supporting no cap styles and no join styles. Dashing is
supported, but does not draw each pixel once and only once, so vertices and
self-intersection aren't handled properly for dashed XOR and the like. */
/* BobB 5/17/99 - corrected the following line for the test condition
if (grafPort.pnFlags && pnDashFlg) goto DrawThin; */ /* is the line dashed? */
if (grafPort.pnFlags & pnDashFlg) goto DrawThin; /* is the line dashed? */
/* Note that skipLast is ignored by dashing square pen wide lines */
/* Special square pen solid or patterned poly line - dashes ignored at this
point (should never reach this point with dashing selected). */
lineExecPntr = (void (*)()) lineSqPolyIDV;
lineExecPntr(PTS, PTCNT, 0); /* call the square pen polyline */
return;
}
/* oval pen, supporting all cap styles, joins, and patterns */
if (PTCNT < 0) goto DoSquare; /* if this a framepoly do it with square pen */
lineExecPntr = (void (*)()) lineOvPolyIDV;
lineExecPntr(PTCNT, PTS); /* call the oval pen polyline */
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -