本文整理汇总了C#中Graphics.FillPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.FillPolygon方法的具体用法?C# Graphics.FillPolygon怎么用?C# Graphics.FillPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphics
的用法示例。
在下文中一共展示了Graphics.FillPolygon方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawTriangle
public static void DrawTriangle(Graphics G, Rectangle Rect, Direction D, Color C)
{
int halfWidth = Rect.Width / 2;
int halfHeight = Rect.Height / 2;
Point p0 = Point.Empty;
Point p1 = Point.Empty;
Point p2 = Point.Empty;
switch (D)
{
case Direction.Up:
p0 = new Point(Rect.Left + halfWidth, Rect.Top);
p1 = new Point(Rect.Left, Rect.Bottom);
p2 = new Point(Rect.Right, Rect.Bottom);
break;
case Direction.Down:
p0 = new Point(Rect.Left + halfWidth, Rect.Bottom);
p1 = new Point(Rect.Left, Rect.Top);
p2 = new Point(Rect.Right, Rect.Top);
break;
case Direction.Left:
p0 = new Point(Rect.Left, Rect.Top + halfHeight);
p1 = new Point(Rect.Right, Rect.Top);
p2 = new Point(Rect.Right, Rect.Bottom);
break;
case Direction.Right:
p0 = new Point(Rect.Right, Rect.Top + halfHeight);
p1 = new Point(Rect.Left, Rect.Bottom);
p2 = new Point(Rect.Left, Rect.Top);
break;
}
using (SolidBrush B = new SolidBrush(C))
{
G.FillPolygon(B, new Point[] {
p0,
p1,
p2
});
}
}
示例2: Run
public static void Run()
{
// ExStart:DrawingUsingGraphics
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages() + "SampleImage_out.bmp";
// Create an instance of BmpOptions and set its various properties
BmpOptions imageOptions = new BmpOptions();
imageOptions.BitsPerPixel = 24;
// Create an instance of FileCreateSource and assign it to Source property
imageOptions.Source = new FileCreateSource(dataDir, false);
using (var image = Image.Create(imageOptions, 500, 500))
{
var graphics = new Graphics(image);
// Clear the image surface with white color and Create and initialize a Pen object with blue color
graphics.Clear(Color.White);
var pen = new Pen(Color.Blue);
// Draw Ellipse by defining the bounding rectangle of width 150 and height 100 also Draw a polygon using the LinearGradientBrush
graphics.DrawEllipse(pen, new Rectangle(10, 10, 150, 100));
using (var linearGradientBrush = new LinearGradientBrush(image.Bounds, Color.Red, Color.White, 45f))
{
graphics.FillPolygon(linearGradientBrush, new[] { new Point(200, 200), new Point(400, 200), new Point(250, 350) });
}
image.Save();
}
// ExEnd:DrawingUsingGraphics
}
示例3: PaintSizeTabs
private void PaintSizeTabs(Graphics graphics, Point[] tabPoints)
{
graphics.FillPolygon(tabBrush, tabPoints);
}
示例4: PaintArrow
private void PaintArrow(Graphics g, Rectangle dropDownRect)
{
Point middle = new Point(Convert.ToInt32(dropDownRect.Left + dropDownRect.Width / 2), Convert.ToInt32(dropDownRect.Top + dropDownRect.Height / 2));
//if the width is odd - favor pushing it over one pixel right.
middle.X += (dropDownRect.Width % 2);
Point[] arrow = new[] { new Point(middle.X - 2, middle.Y - 1), new Point(middle.X + 3, middle.Y - 1), new Point(middle.X, middle.Y + 2) };
if (Enabled)
g.FillPolygon(SystemBrushes.ControlText, arrow);
else
g.FillPolygon(SystemBrushes.ButtonShadow, arrow);
}
示例5: 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);
}
示例6: DrawTriangle
public static void DrawTriangle(Graphics G, Rectangle Rect, Helpers.Direction D, Color C)
{
checked
{
int num = (int)Math.Round((double)Rect.Width / 2.0);
int num2 = (int)Math.Round((double)Rect.Height / 2.0);
Point empty = Point.Empty;
Point empty2 = Point.Empty;
Point empty3 = Point.Empty;
switch (D)
{
case Helpers.Direction.Up:
empty = new Point(Rect.Left + num, Rect.Top);
empty2 = new Point(Rect.Left, Rect.Bottom);
empty3 = new Point(Rect.Right, Rect.Bottom);
break;
case Helpers.Direction.Down:
empty = new Point(Rect.Left + num, Rect.Bottom);
empty2 = new Point(Rect.Left, Rect.Top);
empty3 = new Point(Rect.Right, Rect.Top);
break;
case Helpers.Direction.Left:
empty = new Point(Rect.Left, Rect.Top + num2);
empty2 = new Point(Rect.Right, Rect.Top);
empty3 = new Point(Rect.Right, Rect.Bottom);
break;
case Helpers.Direction.Right:
empty = new Point(Rect.Right, Rect.Top + num2);
empty2 = new Point(Rect.Left, Rect.Bottom);
empty3 = new Point(Rect.Left, Rect.Top);
break;
}
using (SolidBrush solidBrush = new SolidBrush(C))
{
G.FillPolygon(solidBrush, new Point[]
{
empty,
empty2,
empty3
});
}
}
}
示例7: DrawBevelRectangle
private void DrawBevelRectangle(int margin, Rectangle rectangle, Color colour1, Color colour2, Color colour3, Graphics graphics)
{
SolidBrush brush1 = new SolidBrush (colour1);
SolidBrush brush2 = new SolidBrush (colour2);
SolidBrush brush3 = new SolidBrush (colour3);
int[] rectangleArray = new int[4] {
rectangle.X,
rectangle.Y,
rectangle.X+rectangle.Width,
rectangle.Y+rectangle.Height};
Point p1;
Point p2;
Point p3 = new Point ((rectangleArray [0] + rectangleArray [2]) / 2, (rectangleArray [1] + rectangleArray [3]) / 2);
for (int i = 0; i < 4; i++)
{
SolidBrush triangleBrush= brush2;
if (i % 2 == 0) {
p1 = new Point (rectangleArray [i], rectangleArray [(i + 1) % 4]);
p2 = new Point (rectangleArray [i], rectangleArray [(i + 3) % 4]);
} else {
p1 = new Point (rectangleArray [(i + 1) % 4], rectangleArray [i]);
p2 = new Point (rectangleArray [(i + 3) % 4], rectangleArray [i]);
}
if (i < 2) {
triangleBrush = brush3;
}
Point[] triangleArray = new Point[3]{ p1, p2, p3 };
graphics.FillPolygon (triangleBrush, triangleArray);
}
graphics.FillRectangle (brush1, AddPixelsToRectangle(rectangle,-margin,-margin));
}
示例8: DrawPolygon
private void DrawPolygon(Graphics graphics, IPolygon polygon, Brush brush, Pen bufferPen, Pen pen)
{
IPolygon imagePolygon = _transform.ReverseTransform(polygon);
if (brush != null)
{
int numPoints = imagePolygon.ExteriorRing.Coordinates.Length;
if (imagePolygon.InteriorRings != null && imagePolygon.InteriorRings.Length > 0)
{
foreach (ILineString lineString in imagePolygon.InteriorRings)
{
numPoints += lineString.Coordinates.Length + 1;
}
}
PointF[] points = new PointF[numPoints];
for (int i = 0; i < imagePolygon.ExteriorRing.Coordinates.Length; ++i)
{
points[i].X = Convert.ToSingle(imagePolygon.ExteriorRing.Coordinates[i].X * _resolution);
points[i].Y = Convert.ToSingle(imagePolygon.ExteriorRing.Coordinates[i].Y * _resolution);
}
if (imagePolygon.InteriorRings != null && imagePolygon.InteriorRings.Length > 0)
{
int offset = imagePolygon.ExteriorRing.Coordinates.Length;
foreach (ILineString lineString in imagePolygon.InteriorRings)
{
for (int i = 0; i < lineString.Coordinates.Length; ++i)
{
points[i + offset].X = Convert.ToSingle(lineString.Coordinates[i].X * _resolution);
points[i + offset].Y = Convert.ToSingle(lineString.Coordinates[i].Y * _resolution);
}
offset += lineString.Coordinates.Length;
points[offset].X = Convert.ToSingle(imagePolygon.ExteriorRing.Coordinates[0].X * _resolution);
points[offset].Y = Convert.ToSingle(imagePolygon.ExteriorRing.Coordinates[0].Y * _resolution);
++offset;
}
}
graphics.FillPolygon(brush, points);
}
if (pen == null && bufferPen != null && imagePolygon.EnvelopeInternal.Width < 10 && imagePolygon.EnvelopeInternal.Height < 10)
{
pen = bufferPen;
}
if (pen != null)
{
DrawLineString(graphics, polygon.ExteriorRing, pen);
foreach (ILineString lineString in polygon.InteriorRings)
{
DrawLineString(graphics, lineString, pen);
}
}
}
示例9: Fill
// Fill this graphics path.
public void Fill(Graphics graphics, Brush brush, Pen pen, FillMode fillMode)
{
/*
foreach( PathObject o in pathObjs ) {
o.Fill( graphics, brush, pen, fillMode );
}
*/
PointF [] poly = GetPathPoints();
if( poly.Length > 2 ) {
graphics.FillPolygon(brush, poly, fillMode );
}
foreach( PathObject o in pathObjs ) {
if( !o.HasPathPoints ) o.Fill(graphics, brush, pen, fillMode);
}
}
示例10: Draw
public void Draw(Graphics g)
{
Point [] poly = new Point [data.Count + 2];
for (int i = 0; i < poly.Length; i ++)
poly [i].Y = ysize;
poly [0] = new Point (0, 0);
poly [poly.Length - 1] = new Point (xsize, 0);
poly [poly.Length - 2] = new Point (xsize, ysize);
for (int i = -1; i < tl.TypeIndexes.Length; i ++) {
Brush b;
if (i == -1)
b = Brushes.DarkGray;
else
b = tl.TypeBrushes [i];
g.FillPolygon (b, poly);
int j = 1;
foreach (TimePoint tp in data) {
int psize;
if (i == -1)
psize = tp.OtherSize;
else
psize = tp.TypeData [i];
poly [j].X = tp.X;
poly [j].Y -= checked ((int)((long)psize * (long) ysize / (long)Profile.MaxSize));
j ++;
}
}
g.FillPolygon (Brushes.White, poly);
{
Point [] line = new Point [data.Count];
int j = 0;
foreach (TimePoint tp in data) {
int psize = tp.HeapSize;
line [j].X = tp.X;
line [j].Y = ysize - checked ((int)((long)psize * (long) ysize / (long)Profile.MaxSize));
j ++;
}
g.DrawLines (Pens.Black, line);
}
#if DEBUG_GRAPH_SIZE
{
Point [] line = new Point [data.Count];
int j = 0;
foreach (TimePoint tp in data) {
int psize = tp.Data.TotalSize;
line [j].X = tp.X;
line [j].Y = ysize - checked ((int)((long)psize * (long) ysize / (long)Profile.MaxSize));
j ++;
}
g.DrawLines (Pens.Black, line);
}
#endif
}