本文整理汇总了C#中System.Drawing.Graphics.FillClosedCurve方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.FillClosedCurve方法的具体用法?C# Graphics.FillClosedCurve怎么用?C# Graphics.FillClosedCurve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.FillClosedCurve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawHexagon
private void DrawHexagon(Hexagon hexagon, Graphics graphics, Pen borderPen, Brush unitBrush, Brush lockedBrush, int x, int y)
{
if (hexagon.HasColor)
{
var brush = hexagon.Color == Hexagon.UnitColor ? unitBrush : lockedBrush;
graphics.FillClosedCurve(brush, new[] { hexagon.Point1, hexagon.Point2, hexagon.Point3, hexagon.Point4, hexagon.Point5, hexagon.Point6 });
}
graphics.DrawLine(borderPen, hexagon.Point1, hexagon.Point2);
graphics.DrawLine(borderPen, hexagon.Point2, hexagon.Point3);
graphics.DrawLine(borderPen, hexagon.Point3, hexagon.Point4);
graphics.DrawLine(borderPen, hexagon.Point4, hexagon.Point5);
graphics.DrawLine(borderPen, hexagon.Point5, hexagon.Point6);
graphics.DrawLine(borderPen, hexagon.Point6, hexagon.Point1);
if (!string.IsNullOrEmpty(hexagon.Text))
{
graphics.DrawString(hexagon.Text, new Font(FontFamily.GenericMonospace, hexagon.FontSize), borderPen.Brush, hexagon.Point6.X, hexagon.Point6.Y);
}
if (hexagon.HasCircle)
{
graphics.DrawEllipse(borderPen, hexagon.Circle);
}
}
示例2: DrawFillEllipse
public static void DrawFillEllipse(Graphics g, Brush b, float x, float y, float width, float height, Matrix m = null, double eps = 0.001)
{
List<PointF> ps = new List<PointF>();
if (m == null)
PointsForEllipse(x, y, width, height).ToList().ForEach(p => ps.AddRange(SplinePoints(p, eps)));
else
PointsForEllipse(x, y, width, height).ToList().ForEach(p => ps.AddRange(SplinePoints(m * p, eps)));
g.FillClosedCurve(b, ps.ToArray());
}
示例3: Draw
public override void Draw(RectangleF rect)
{
Graphics g = new Graphics();
//g.Clear(Color.White);
g.SmoothingMode = SmoothingMode.AntiAlias;
// Create a pen object:
Pen aPen = new Pen(Color.Blue, 2);
// Create a brush object with a transparent red color:
SolidBrush aBrush = new SolidBrush(Color.Red);
HatchBrush hBrush = new HatchBrush(HatchStyle.Shingle, Color.Blue, Color.LightCoral);
HatchBrush hBrush2 = new HatchBrush(HatchStyle.Cross, Color.Blue, Color.LightCoral);
HatchBrush hBrush3 = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Blue, Color.LightCoral);
HatchBrush hBrush4 = new HatchBrush(HatchStyle.Sphere, Color.Blue, Color.LightCoral);
// Draw a rectangle:
g.DrawRectangle(aPen, 20, 20, 100, 50);
// Draw a filled rectangle:
g.FillRectangle(hBrush, 20, 90, 100, 50);
// Draw ellipse:
g.DrawEllipse(aPen, new Rectangle(20, 160, 100, 50));
// Draw filled ellipse:
g.FillEllipse(hBrush2, new Rectangle(170, 20, 100, 50));
// Draw arc:
g.DrawArc(aPen, new Rectangle(170, 90, 100, 50), -90, 180);
// Draw filled pie pieces
g.FillPie(aBrush, new Rectangle(170, 160, 100, 100), -90, 90);
g.FillPie(hBrush4, new Rectangle(170, 160, 100, 100), -90, -90);
// Create pens.
Pen redPen = new Pen(Color.Red, 3);
Pen greenPen = new Pen(Color.Green, 3);
greenPen.DashStyle = DashStyle.DashDotDot;
SolidBrush transparentBrush = new SolidBrush(Color.FromArgb(150, Color.Wheat));
// define point array to draw a curve:
Point point1 = new Point(300, 250);
Point point2 = new Point(350, 125);
Point point3 = new Point(400, 110);
Point point4 = new Point(450, 210);
Point point5 = new Point(500, 300);
Point[] curvePoints ={ point1, point2, point3, point4, point5};
// Draw lines between original points to screen.
g.DrawLines(redPen, curvePoints);
// Fill Curve
g.FillClosedCurve(transparentBrush, curvePoints);
// Draw closed curve to screen.
g.DrawClosedCurve(greenPen, curvePoints);
g.Dispose();
}
示例4: DrawSelectionLasso
/// <summary>
/// Draw a polyline using an array of points and fills the interior
/// cfr Lasso Select in Paint.Net
/// </summary>
/// <param name="graphics"></param>
/// <param name="color"></param>
/// <param name="points"></param>
public static void DrawSelectionLasso(Graphics graphics, Color color, PointF[] points)
{
if (points.Length < 2)
{
return;
}
Pen pen = new Pen(color);
graphics.DrawCurve(pen, points);
pen.Dispose();
Brush brush = new SolidBrush(Color.FromArgb(30, color));
graphics.FillClosedCurve(brush, points);
brush.Dispose();
}
示例5: Render
//Render a polygon
private static void Render(DnaPolygon polygon, Graphics g, int scale)
{
if (polygon.IsComplex)
return;
Point[] points = GetGdiPoints(polygon.Points, scale);
using (Brush brush = GetGdiBrush(polygon.Brush))
{
if (polygon.Splines)
{
if (polygon.Filled)
{
g.FillClosedCurve(brush, points, FillMode.Winding);
}
else
{
using (Pen pen = new Pen(brush, Math.Max(1, polygon.Width)))
{
g.DrawCurve(pen, points, 3F);
}
}
}
else
{
if (polygon.Filled)
{
g.FillPolygon(brush, points, FillMode.Winding);
}
else
{
using (Pen pen = new Pen(brush, Math.Max(1, polygon.Width)))
{
g.DrawPolygon(pen, points);
}
}
}
}
}
示例6: Draw
public void Draw(Graphics g)
{
g.FillClosedCurve(Brush, ControlPoints.ToArray(), FillMode.Alternate, Tension);
}
示例7: Balloon
public void Balloon(Graphics gr,
Rectangle rect,
Point target,
Color color,
IFieldControlContext context)
{
Point[] balloon = VectorUtils.VectorizeBalloon(rect, target, Math.PI / 8);
gr.SmoothingMode = SmoothingMode.AntiAlias;
using (LinearGradientBrush br =
new LinearGradientBrush(rect, Color.White, color, LinearGradientMode.ForwardDiagonal)
)
{
br.WrapMode = WrapMode.TileFlipXY;
gr.FillClosedCurve(br, balloon, FillMode.Alternate, 0.08f);
}
gr.DrawClosedCurve(Pens.Black, balloon, 0.08f, FillMode.Alternate);
}
示例8: DrawCustomer
public void DrawCustomer(Graphics g)
{
if (Drawable)
{
g.FillRectangle(DrawingClass.GetColor(Shirt), X, Y, 40, 100);
g.DrawRectangle(Pens.Black, X, Y, 40, 100);
g.DrawRectangle(Pens.Black, X + 10, Y + 15, 20, 80);
g.FillRectangle(DrawingClass.GetColor(Pants), X + 5, Y + 100, 30, 100);
g.DrawRectangle(Pens.Black, X + 5, Y + 100, 30, 100);
g.DrawEllipse(Pens.Black, X + 5, Y - 30, 30, 30);
Rectangle Rect = new Rectangle(X - 5, Y - 100, 50, 50);
switch (State)
{
case 1: //Только идет
g.FillEllipse(Brushes.Yellow, Rect);
g.FillRectangle(Brushes.Black, X + 10, Y - 65, 20, 3);
break;
case 2: //Получил
g.FillEllipse(Brushes.LightGreen, Rect);
g.FillClosedCurve(Brushes.Black, new Point[6] {
new Point(X + 10, Y - 68),
new Point(X + 20, Y - 65),
new Point(X + 30, Y - 68),
new Point(X + 30, Y - 65),
new Point(X + 20, Y - 62),
new Point(X + 10, Y - 65) });
break;
case 3: //Не получил
g.FillEllipse(Brushes.Red, Rect);
g.FillClosedCurve(Brushes.Black, new Point[6] {
new Point(X + 10, Y - 65),
new Point(X + 20, Y - 68),
new Point(X + 30, Y - 65),
new Point(X + 30, Y - 62),
new Point(X + 20, Y - 65),
new Point(X + 10, Y - 62) });
break;
}
g.FillEllipse(Brushes.Black, X + 5, Y - 85, 10, 10);
g.FillEllipse(Brushes.Black, X + 25, Y - 85, 10, 10);
g.DrawString(Desire.ToString() + " p.", new Font("Arial", 10), Brushes.Black, X + 5, Y - 50);
g.DrawEllipse(Pens.Black, Rect);
}
}
示例9: DrawIt
public void DrawIt(Graphics e, bool light)
{
if (light) e.FillClosedCurve(new SolidBrush(FaceColor), new[] { pt1.ToPoitntFxy(), pt2.ToPoitntFxy(), pt3.ToPoitntFxy(), pt4.ToPoitntFxy(),pt1.ToPoitntFxy()}, FillMode.Alternate);
else e.DrawLines(new Pen(FaceColor,1), new[] { pt1.ToPoitntFxy(), pt2.ToPoitntFxy(), pt3.ToPoitntFxy(), pt4.ToPoitntFxy(), pt1.ToPoitntFxy() });
}
示例10: PaintLine
/// <summary>
/// Paints a line of the memory control, starting with the address.
/// </summary>
/// <remarks>
/// The strategy is to find any items present at the current address, and try
/// to paint as many adjacent items as possible.
/// </remarks>
/// <param name="g"></param>
/// <param name="rc"></param>
/// <param name="rdr"></param>
private Address PaintLine(Graphics g, Rectangle rc, ImageReader rdr, Point ptAddr, bool render)
{
StringBuilder sbCode = new StringBuilder(" ");
// Draw the address part.
rc.X = 0;
string s = string.Format("{0}", rdr.Address);
int cx = (int) g.MeasureString(s + "X", ctrl.Font, rc.Width, StringFormat.GenericTypographic).Width;
if (!render && new Rectangle(rc.X, rc.Y, cx, rc.Height).Contains(ctrl.ptDown))
{
return rdr.Address;
}
else
{
g.FillRectangle(SystemBrushes.Window, rc.X, rc.Y, cx, rc.Height);
g.DrawString(s, ctrl.Font, SystemBrushes.ControlText, rc.X, rc.Y, StringFormat.GenericTypographic);
}
cx -= cellSize.Width / 2;
rc = new Rectangle(cx, rc.Top, rc.Width - cx, rc.Height);
uint rowBytesLeft = ctrl.cbRow;
ulong linearSelected = ctrl.addrSelected != null ? ctrl.addrSelected.ToLinear() : ~0UL;
ulong linearAnchor = ctrl.addrAnchor != null ? ctrl.addrAnchor.ToLinear() : ~0UL;
ulong linearBeginSelection = Math.Min(linearSelected, linearAnchor);
ulong linearEndSelection = Math.Max(linearSelected, linearAnchor);
do
{
Address addr = rdr.Address;
ulong linear = addr.ToLinear();
ImageMapItem item;
if (!ctrl.ImageMap.TryFindItem(addr, out item))
break;
ulong cbIn = (linear - item.Address.ToLinear()); // # of bytes 'inside' the block we are.
uint cbToDraw = 16; // item.Size - cbIn;
// See if the chunk goes off the edge of the line. If so, clip it.
if (cbToDraw > rowBytesLeft)
cbToDraw = rowBytesLeft;
// Now paint the bytes in this span.
for (int i = 0; i < cbToDraw; ++i)
{
Address addrByte = rdr.Address;
ctrl.ImageMap.TryFindItem(addrByte, out item);
bool isSelected = linearBeginSelection <= addrByte.ToLinear() && addrByte.ToLinear() <= linearEndSelection;
bool isCursor = addrByte.ToLinear() == linearSelected;
if (rdr.IsValid)
{
byte b = rdr.ReadByte();
s = string.Format("{0:X2}", b);
char ch = (char) b;
sbCode.Append(Char.IsControl(ch) ? '.' : ch);
}
else
{
s = "??";
sbCode.Append(' ');
}
cx = cellSize.Width * 3;
Rectangle rcByte = new Rectangle(
rc.Left,
rc.Top,
cx,
rc.Height);
if (!render && rcByte.Contains(ptAddr))
return addrByte;
var theme = GetBrushTheme(item, isSelected);
g.FillRectangle(theme.Background, rc.Left, rc.Top, cx, rc.Height);
if (!isSelected && theme.StartMarker != null && addrByte.ToLinear() == item.Address.ToLinear())
{
var pts = new Point[]
{
rc.Location,
rc.Location,
rc.Location,
};
pts[1].Offset(4, 0);
pts[2].Offset(0, 4);
g.FillClosedCurve(theme.StartMarker, pts);
}
g.DrawString(s, ctrl.Font, theme.Foreground, rc.Left + cellSize.Width / 2, rc.Top, StringFormat.GenericTypographic);
if (isCursor)
{
//.........这里部分代码省略.........
示例11: DrawEllipse
public void DrawEllipse(Graphics g, RectangleD worldRect, Rectangle canvasRect,
BrushesStorage brushStorage, PenStorage penStorage, Font font)
{
const int markerSize = 3;
var pen = penStorage.GetPen(Color, Selected ? 3f : 1f);
var screenPoints = new List<PointD>();
foreach (var pt in points)
{
screenPoints.Add(Conversion.WorldToScreen(new PointD(pt.X, pt.Y),
worldRect, canvasRect));
}
foreach (var pt in screenPoints)
{
g.DrawRectangle(pen, (float)pt.X - markerSize, (float)pt.Y - markerSize,
markerSize * 2F, markerSize * 2F);
}
if (screenPoints.Count == 2)
{
g.DrawLine(pen, screenPoints[0].ToPointF(), screenPoints[1].ToPointF());
}
if (screenPoints.Count == 3)
{
// нарисовать собственно эллипс
double newAngle;
float newCx, newCy, newA, newB;
correctEllipse = Geometry.GetEllipseParams(screenPoints[0].ToPointF(),
screenPoints[1].ToPointF(),
screenPoints[2].ToPointF(),
out newAngle, out newA, out newB, out newCx, out newCy);
if (correctEllipse) // можно построить эллипс - рисуем его
{
a = newA;
b = newB;
angle = newAngle;
cx = newCx;
cy = newCy;
var ellipseBezierPoints = Geometry.GetEllipseBezierPoints(newAngle, newA, newB, newCx, newCy);
g.DrawBeziers(pen, ellipseBezierPoints);
if (BrushAlpha > 0)
{
var brush = brushStorage.GetBrush(Color.FromArgb(BrushAlpha, BrushColor));
g.FillClosedCurve(brush, ellipseBezierPoints);
}
// строить касательную
if (BuildTangent)
DrawTangent(screenPoints, canvasRect, g,
penStorage, brushStorage, font);
}
else // построить эллипс по указанным координатам невозможно
{
g.DrawLine(pen, screenPoints[1].ToPointF(), screenPoints[2].ToPointF());
g.DrawLine(pen, screenPoints[0].ToPointF(), screenPoints[2].ToPointF());
}
}
// маркеры
if (Selected)
DrawComments(g, worldRect, canvasRect, penStorage, brushStorage);
}
示例12: RenderPolygons
private void RenderPolygons(Graphics g)
{
g.SmoothingMode = Settings.SmoothingMode;
foreach (Polygon poly in polyList)
{
Point centerPoint = CalculateCenterPoint(poly.Corners);
if (poly.Type == Type.POLYGON)
{
if (Settings.RoundedPolygons)
g.FillClosedCurve(new SolidBrush(Color.FromArgb(poly.Alpha,poly.FillColor.R,poly.FillColor.G,poly.FillColor.B)), poly.Corners);
else
g.FillPolygon(new SolidBrush(poly.FillColor), poly.Corners);
}
else
{
Range rX = MinMaxRangeFromPolygon(poly,true);
Range rY = MinMaxRangeFromPolygon(poly,false);
g.FillEllipse(new SolidBrush(poly.FillColor),new Rectangle(new Point(rX.Min,rY.Min),new Size(rX.Difference,rY.Difference)));
}
if (selectedIndex > -1)
{
if (poly == polyList[selectedIndex])
{
for (int i = 0; i < poly.Corners.Length; i++)
{
Point p = poly.Corners[i];
Color fillColor;
if (poly.SelectedCorner > -1 && p == poly.Corners[poly.SelectedCorner])
fillColor = Settings.DragSquareSelectionFillColor;
else
fillColor = Settings.DragSquareFillColor;
Rectangle dragSpotSize = PointToRectangle(p, Settings.DragSquareSize);
Rectangle dragSpotBorder = PointToRectangle(p, Settings.DragSquareSize);
g.FillRectangle(new SolidBrush(fillColor), dragSpotSize);
g.DrawRectangle(new Pen(new SolidBrush(Settings.DragSquareBorderColor), Settings.DragSquareBorderSize), dragSpotBorder);
}
if (Settings.DrawCenterPoint)
{
g.FillEllipse(new SolidBrush(Settings.DragCircleFillColor), PointToRectangle(centerPoint, Settings.DragCircleSize));
g.DrawEllipse(new Pen(new SolidBrush(Settings.DragCircleBorderColor), Settings.DragSquareBorderSize), PointToRectangle(centerPoint, Settings.DragCircleSize));
}
}
}
}
if (Mode == Modes.DRAWMODE && drawRect != null && mouseClicked && drawPolygon !=null)
{
if (Settings.DrawMode == DrawMode.POLYGON)
DrawSelectionPolygon(g);
else if (Settings.DrawMode == DrawMode.SELECTIONRECTANGLE)
DrawSelectionRectangle(g);
else{
DrawSelectionPolygon(g);
DrawSelectionRectangle(g);
}
}
}
示例13: DrawSelectionPolygon
private void DrawSelectionPolygon(Graphics g)
{
g.FillClosedCurve(new SolidBrush(drawPolygon.FillColor), drawPolygon.Corners);
}
示例14: Draw
/// <summary>
/// Draws the closed curve
/// </summary>
/// <param name="g">the graphics object</param>
internal override void Draw(Graphics g)
{
g.FillClosedCurve(myBrush, points);
}
示例15: DrawOne
private void DrawOne(Graphics g, int xmin, int xmax, int ymin, int ymax)
{
var shape = Shape.Arc;
var color = new Color();
var randomValue = RandomProvider.RandomGenerator.NextDouble();
foreach (var probabilitiesOfShape in ProbabilitiesOfShapes)
{
if (randomValue < probabilitiesOfShape.Probability)
{
shape = probabilitiesOfShape.Value;
break;
}
}
randomValue = RandomProvider.RandomGenerator.NextDouble();
foreach (var colorProbabilityPair in colorsCDFs)
{
if (randomValue < colorProbabilityPair.probability)
{
color = colorProbabilityPair.color;
break;
}
}
var pen = new Pen(color);
var x1 = RandomProvider.RandomGenerator.Next(xmin, xmax + 1);
var y1 = RandomProvider.RandomGenerator.Next(ymin, ymax + 1);
var x2 = RandomProvider.RandomGenerator.Next(xmin, xmax + 1);
var y2 = RandomProvider.RandomGenerator.Next(ymin, ymax + 1);
var x3 = RandomProvider.RandomGenerator.Next(xmin, xmax + 1);
var y3 = RandomProvider.RandomGenerator.Next(ymin, ymax + 1);
var x4 = RandomProvider.RandomGenerator.Next(xmin, xmax + 1);
var y4 = RandomProvider.RandomGenerator.Next(ymin, ymax + 1);
var w1 = RandomProvider.RandomGenerator.Next(x1, xmax + 1);
var h1 = RandomProvider.RandomGenerator.Next(y1, ymax + 1);
var angle1 = RandomProvider.RandomGenerator.Next(0, 360);
switch (shape)
{
case Shape.Arc:
g.DrawArc(pen, x1, y1, w1, h1, RandomProvider.RandomGenerator.Next(0, 360),
RandomProvider.RandomGenerator.Next(0, 360));
break;
case Shape.Bezier:
g.DrawBezier(pen, x1, y1, x2, y2, x3, y3, x4, y4);
break;
case Shape.ClosedCurve:
g.DrawClosedCurve(pen,
new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
break;
case Shape.Curve:
g.DrawCurve(pen,
new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
break;
case Shape.Ellipse:
g.DrawEllipse(pen, x1, y1, w1, h1);
break;
case Shape.Line:
g.DrawLine(pen, x1, y1, x2, y2);
break;
case Shape.Lines:
g.DrawLines(pen,
new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
break;
case Shape.Pie:
g.DrawPie(pen, x1, y1, w1, h1, RandomProvider.RandomGenerator.Next(0, 360),
RandomProvider.RandomGenerator.Next(0, 360));
break;
case Shape.Polygon:
g.DrawPolygon(pen,
new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
break;
case Shape.Rectangle:
g.DrawRectangle(pen, x1, y1, w1, h1);
break;
case Shape.String:
g.DrawString(EnglishWordsDictionary.GetRandomWord(),
new Font("Cambria", RandomProvider.RandomGenerator.Next(1, 50)), new SolidBrush(color),
new PointF(x1, y1));
break;
case Shape.FillClosedCurve:
g.FillClosedCurve(new SolidBrush(color),
new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
break;
case Shape.FillEllipse:
g.FillEllipse(new SolidBrush(color), x1, y1, w1, h1);
break;
case Shape.FillPie:
g.FillPie(new SolidBrush(color), x1, y1, w1, h1, RandomProvider.RandomGenerator.Next(0, 360),
RandomProvider.RandomGenerator.Next(0, 360));
break;
case Shape.FillPolygon:
g.FillPolygon(new SolidBrush(color),
//.........这里部分代码省略.........