本文整理汇总了C#中Graphics.DrawPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawPolygon方法的具体用法?C# Graphics.DrawPolygon怎么用?C# Graphics.DrawPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphics
的用法示例。
在下文中一共展示了Graphics.DrawPolygon方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoPage
protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
{
Pen pen = new Pen(clr);
Brush brush = new SolidBrush(clr);
const int xOffset = 10;
const int yOffset = 10;
grfx.DrawPolygon(pen, new PointF[]
{
MMConv(grfx, new PointF(xOffset, yOffset)),
MMConv(grfx, new PointF(xOffset+100, yOffset)),
MMConv(grfx, new PointF(xOffset+100, yOffset+10)),
MMConv(grfx, new PointF(xOffset, yOffset+10))
});
StringFormat strfmt = new StringFormat();
strfmt.Alignment = StringAlignment.Center;
for (int i=1; i<100; i++)
{
if (i%10 == 0)
{
grfx.DrawLine(pen,
MMConv(grfx, new PointF(xOffset+i, yOffset)),
MMConv(grfx, new PointF(xOffset+i, yOffset+5)));
grfx.DrawString((i/10).ToString(), Font, brush,
MMConv(grfx, new PointF(xOffset+i, yOffset+5)),
strfmt);
}
else if (i%5 == 0)
{
grfx.DrawLine(pen,
MMConv(grfx, new PointF(xOffset+i, yOffset)),
MMConv(grfx, new PointF(xOffset+i, yOffset+3)));
}
else
{
grfx.DrawLine(pen,
MMConv(grfx, new PointF(xOffset+i, yOffset)),
MMConv(grfx, new PointF(xOffset+i, yOffset+2.5f)));
}
}
}
示例2: Render
public override void Render(Graphics gr, int iScale)
{
Point[] points = new Point[m_iNumPoints];
int iRad = m_iVertexRadius * iScale;
for (int i = 0; i < m_iNumPoints; ++i)
{
points[i].X = (m_iXStart * iScale) + iRad + (int)(Math.Sin(2 * i * Math.PI / m_iNumPoints + m_dRotation) * iRad);
points[i].Y = (m_iYStart * iScale) + iRad - (int)(Math.Cos(2 * i * Math.PI / m_iNumPoints + m_dRotation) * iRad);
}
gr.FillPolygon(new SolidBrush(m_Color), points);
if (m_iBorderThickness > 0)
gr.DrawPolygon(new Pen(m_BorderColor, m_iBorderThickness), points);
}
示例3: Draw
// Draw this path object.
public override void Draw(Graphics graphics, Pen pen)
{
graphics.DrawPolygon(pen, points);
}