本文整理汇总了C#中System.Drawing.Graphics.DrawBezier方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawBezier方法的具体用法?C# Graphics.DrawBezier怎么用?C# Graphics.DrawBezier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.DrawBezier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawEdge
public static void DrawEdge( Graphics g, Edge edge )
{
// Line
if( edge.IsComplex )
{
var old_end_cap = edge.LinePen.EndCap;
edge.LinePen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
for( int seg_ind = 0; seg_ind < edge.Segments.Length - 1; ++seg_ind )
{
var segment = edge.Segments[seg_ind];
if( segment.IsLinear )
g.DrawLine(edge.LinePen, segment.Points[0], segment.Points[1]);
else
g.DrawBezier(edge.LinePen, segment.Points[0], segment.Points[1], segment.Points[2], segment.Points[3]);
}
edge.LinePen.EndCap = old_end_cap;
var last_segment = edge.Segments[edge.Segments.Length - 1];
if( last_segment.IsLinear )
g.DrawLine(edge.LinePen, last_segment.Points[0], last_segment.Points[1]);
else
g.DrawBezier(edge.LinePen, last_segment.Points[0], last_segment.Points[1], last_segment.Points[2], last_segment.Points[3]);
}
else
{
g.DrawLine(edge.LinePen, edge.StartPosition, edge.EndPosition);
}
// Label
if( edge.LabelText != null )
g.DrawString(edge.LabelText, edge.LabelFont, edge.LabelBrush,
edge.LabelPosition.X, edge.LabelPosition.Y);
}
示例2: Draw
public override void Draw(Graphics g)
{
if (this.lineComponent.IsSelected)
{
g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.StartPoint.X, this.lineComponent.StartPoint.Y, this.lineComponent.ControlPoint1.X, this.lineComponent.ControlPoint1.Y);
g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.EndPoint.X, this.lineComponent.EndPoint.Y, this.lineComponent.ControlPoint2.X, this.lineComponent.ControlPoint2.Y);
}
if (this.lineComponent.ParentMoving)
{
g.DrawBezier(ViewFactory.LinePen,
this.lineComponent.StartPoint.MakePointF(),
this.lineComponent.ControlPoint1.MakePointF(),
this.lineComponent.ControlPoint2.MakePointF(),
this.lineComponent.EndPoint.MakePointF());
}
else
{
g.DrawLines(ViewFactory.LinePen, this.lineComponent.points.ToArray());
/*DrawPoint(g, new FlowChartPoint(points[points.Count/2].X,points[points.Count/2].Y),
GraphicsSettings.LabelPen, GraphicsSettings.EdgeBoxWidth);*/
}
DrawArrow(g, this.lineComponent.EndPoint, this.lineComponent.ControlPoint2,
ViewFactory.ArrowBrush,
ViewFactory.ArrowPen,
ViewFactory.ArrowLength);
if (this.lineComponent.IsSelected)
{
DrawPoint(g, this.lineComponent.ControlPoint1, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
DrawPoint(g, this.lineComponent.ControlPoint2, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
}
base.Draw(g);
}
示例3: lines
public void lines(Graphics g, int[,] A, Point[] P, Pen pen)
{
for (int i = 0; i < A.GetLength(0); i++)
{
for (int j = 0; j < A.GetLength(0); j++)
{
if (A[i,j] == 1)
{
Point p1 = normDistance(P[i], P[j]);
Point p2 = normDistance(P[j], P[i]);
g.DrawLine(pen, p1,p2);
}
if (A[i,i] != 0)
{
Pen self = new Pen(Color.FromArgb(0,255,255),8);
int Xs = P[i].X, Ys = P[i].Y + 20;
int Xe = Xs, Ye = Ys;
int p1X = Xs - 100;
int p1Y = Ys + 50;
int p2X = Xs + 100;
int p2Y = Ys + 50;
g.DrawBezier(self, Xs, Ys, p1X, p1Y, p2X, p2Y, Xe, Ye);
}
}
}
}
示例4: DrawLeftToRightArrow
public static void DrawLeftToRightArrow(Graphics g, int x1, int y1, int x2, int y2)
{
int startLine = 7;
int endLine = 15;
int bezierStregth = 10;
float arrowLength = 7.0f;
float arrowWidth = 3.2f;
// Shadow
g.DrawLine(ArrowShadowPen,x1+1,y1+1,x1+startLine+2,y1+1);
g.DrawLine(ArrowShadowPen,x2-endLine,y2+1,x2+1-8,y2+1);
g.DrawBezier(ArrowShadowPen,
x1+startLine+1,y1+1,
x1+startLine+bezierStregth+1,y1+1,
x2-endLine-bezierStregth+1,y2+1,
x2-endLine+1,y2+1);
// Head shadow
PointF[] arrowPointsShadow = {
new PointF(x2-5-arrowLength+1,y2-arrowWidth+1),
new PointF(x2-5+1,y2+1),
new PointF(x2-5-arrowLength+1,y2+arrowWidth+1)
};
GraphicsPath arrowPathShadow = new GraphicsPath();
arrowPathShadow.AddPolygon(arrowPointsShadow);
g.FillPath(ArrowShadowBrush,arrowPathShadow);
// Line
g.DrawLine(LeftToRightArrowPen,x1,y1,x1+startLine+1,y1);
g.DrawLine(LeftToRightArrowPen,x2-endLine-1,y2,x2-8,y2);
g.DrawBezier(LeftToRightArrowPen,
x1+startLine,y1,
x1+startLine+bezierStregth,y1,
x2-endLine-bezierStregth,y2,
x2-endLine,y2);
// Head
PointF[] arrowPoints = {
new PointF(x2-5-arrowLength,y2-arrowWidth),
new PointF(x2-5,y2),
new PointF(x2-5-arrowLength,y2+arrowWidth)
};
GraphicsPath arrowPath = new GraphicsPath();
arrowPath.AddPolygon(arrowPoints);
g.FillPath(LeftToRightArrowBrush,arrowPath);
}
示例5: DrawGraphics
public override void DrawGraphics(Graphics destination)
{
DrawGraphics();
using (var pen = Style.CreatePen())
{
destination.DrawBezier(pen, ControlPoints[0], ControlPoints[1], ControlPoints[2], ControlPoints[3]);
}
EditablegeometryCue.DrawGeometry(destination);
}
示例6: Paint
public override void Paint(Graphics graphics)
{
Point pointN = SupplierViewer.GetOutputLineConnectionPoint(Item);
Point pointM = ConsumerViewer.GetInputLineConnectionPoint(Item);
Point pointN2 = new Point(pointN.X, pointN.Y - Math.Max((int)((pointN.Y - pointM.Y) / 2), 40));
Point pointM2 = new Point(pointM.X, pointM.Y + Math.Max((int)((pointN.Y - pointM.Y) / 2), 40));
using (Pen pen = new Pen(DataCache.IconAverageColour(Item.Icon), 3f))
{
graphics.DrawBezier(pen, pointN, pointN2, pointM2, pointM);
}
}
示例7: DrawBezier
private void DrawBezier(Graphics g)
{
// Draw a black Bezier curve.
Pen pen = new Pen(Color.Black);
pen.Width = 5;
pen.DashStyle = DashStyle.Dash;
// Specify which type of drawing must occur at the ends of the stroke
pen.StartCap = LineCap.RoundAnchor;
pen.EndCap = LineCap.ArrowAnchor;
g.DrawBezier(
pen,
new Point(10, 30),
new Point(30, 200),
new Point(50, -100),
new Point(70, 100));
}
示例8: DrawAxons
private static void DrawAxons(this Network network, Graphics graphic)
{
foreach (Axon axon in network.Axons)
{
Point source = Translate(network, axon.Source).Add(5);
Point target = Translate(network, axon.Target).Add(5);
Point s2 = source.Shift(50, 0);
Point t2 = target.Shift(-50, 0);
Color color = Blend(Color.Gray, Color.Red, axon.Signal);
float width = (float)axon.Weight*2;
Pen axonpen = new Pen(color, width);
graphic.DrawBezier(axonpen, source, s2, t2, target);
}
}
示例9: DrawBezier
public static void DrawBezier(Graphics g, DiagramView view, System.Drawing.Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
{
if (pen != null)
{
g.DrawBezier(pen, x1, y1, x2, y2, x3, y3, x4, y4);
}
}
示例10: DrawToGraphics
public override void DrawToGraphics(Graphics graphics)
{
Pen pen = Pens.Black;
switch (this.CurrentState)
{
case ItemState.Free:
pen = new Pen(ColorDefinition.GetColorWhenFree());
break;
case ItemState.Hover:
pen = new Pen(ColorDefinition.GetColorWhenHover());
break;
case ItemState.Selected:
pen = new Pen(ColorDefinition.GetColorWhenSelected());
break;
default:
break;
} // switch
List<PointF> tempNails = new List<PointF>();
tempNails.Add(this.GetStartingPoint());
foreach (NailItem nail in this.Nails)
tempNails.Add(nail.Center());
tempNails.Add(this.GetEndPoint());
float R = NailItem.R;
if (this.CurrentState == ItemState.Free)
R = NailItem.R + 5;
PointF[] points = new PointF[3];
PointF firstNail = PointF.Empty;
firstNail = tempNails[0];
for (int i = 0; i < tempNails.Count - 1; i++)
{
points[1] = tempNails[i + 1];
points[0] = GraphUltility.FindPointByDistance(points[1], firstNail, R);
graphics.DrawLine(pen, firstNail, points[0]);
if (i + 2 < tempNails.Count)
{
points[2] = GraphUltility.FindPointByDistance(points[1], tempNails[i + 2], R);
firstNail = points[2];
//Make the intersection curved
if (this.CurrentState == ItemState.Free)
graphics.DrawBezier(pen, points[0], points[1], points[1], points[2]);
}
}
DrawRouteWithBigArrow(graphics, pen, firstNail, tempNails[tempNails.Count - 1]);
Label.Value = _weight;
Label.CurrentState = this.CurrentState;
Label.DrawToGraphics(graphics);
}
示例11: DrawItem
//.........这里部分代码省略.........
c0 = new Point(x0, (int)(y0 * (1.0f - severity) + y1 * severity));
c1 = new Point(x1, (int)(y1 * (1.0f - severity) + y0 * severity));
}
for (int i = drawBorder ? 0 : 2; i < 3; i++)
{
Pen penLine = null;
if (i == 0)
{
penLine = _whiteBorderPen;
}
else if (i == 1)
{
penLine = _blackBorderPen;
}
else
{
if (brushLineColorPen == null)
brushLineColorPen = new Pen(brushLineColor, _laneLineWidth);
penLine = brushLineColorPen;
}
if (laneInfo.ConnectLane == lane)
{
wa.DrawLine
(
penLine,
new Point(mid, top - 1),
new Point(mid, top + _rowHeight + 2)
);
}
else
{
wa.DrawBezier
(
penLine,
new Point(mid, top - 1),
new Point(mid, top + _rowHeight + 2),
new Point(mid + (laneInfo.ConnectLane - lane) * _laneWidth, top - 1),
new Point(mid + (laneInfo.ConnectLane - lane) * _laneWidth, top + _rowHeight + 2)
);
}
}
}
finally
{
if (brushLineColorPen != null)
((IDisposable)brushLineColorPen).Dispose();
if (brushLineColor != null)
((IDisposable)brushLineColor).Dispose();
}
}
}
// Reset the clip region
wa.Clip = oldClip;
{
// Draw node
var nodeRect = new Rectangle
(
wa.RenderingOrigin.X + (_laneWidth - _nodeDimension) / 2 + row.NodeLane * _laneWidth,
wa.RenderingOrigin.Y + (_rowHeight - _nodeDimension) / 2,
_nodeDimension,
_nodeDimension
);
示例12: DrawChildren
private void DrawChildren(Graphics g, IList<INative> children)
{
foreach (var child in children)
{
if (child is IPin)
{
var pin = child as IPin;
var color = Color.FromArgb(0xFF, 0x00, 0x00, 0x00);
Brush brush = new SolidBrush(color);
double x = pin.Point.X - 4.0;
double y = pin.Point.Y - 4.0;
double width = 8.0;
double height = 8.0;
g.FillEllipse(
brush,
(float)x,
(float)y,
(float)width,
(float)height);
brush.Dispose();
}
else if (child is ILine)
{
var line = child as ILine;
Pen pen = new Pen(
ToNativeColor(line.Stroke),
(float)line.StrokeThickness);
g.DrawLine(
pen,
(float)line.Point1.X,
(float)line.Point1.Y,
(float)line.Point2.X,
(float)line.Point2.Y);
pen.Dispose();
}
else if (child is IBezier)
{
var bezier = child as IBezier;
Pen pen = new Pen(
ToNativeColor(bezier.Stroke),
(float)bezier.StrokeThickness);
g.DrawBezier(
pen,
(float)bezier.Start.X,
(float)bezier.Start.Y,
(float)bezier.Point1.X,
(float)bezier.Point1.Y,
(float)bezier.Point2.X,
(float)bezier.Point2.Y,
(float)bezier.Point3.X,
(float)bezier.Point3.Y);
pen.Dispose();
}
else if (child is IQuadraticBezier)
{
var quadraticBezier = child as IQuadraticBezier;
Pen pen = new Pen(
ToNativeColor(quadraticBezier.Stroke),
(float)quadraticBezier.StrokeThickness);
double x1 = quadraticBezier.Start.X;
double y1 = quadraticBezier.Start.Y;
double x2 = quadraticBezier.Start.X + (2.0 * (quadraticBezier.Point1.X - quadraticBezier.Start.X)) / 3.0;
double y2 = quadraticBezier.Start.Y + (2.0 * (quadraticBezier.Point1.Y - quadraticBezier.Start.Y)) / 3.0;
double x3 = x2 + (quadraticBezier.Point2.X - quadraticBezier.Start.X) / 3.0;
double y3 = y2 + (quadraticBezier.Point2.Y - quadraticBezier.Start.Y) / 3.0;
double x4 = quadraticBezier.Point2.X;
double y4 = quadraticBezier.Point2.Y;
g.DrawBezier(
pen,
(float)x1,
(float)y1,
(float)x2,
(float)y2,
(float)x3,
(float)y3,
(float)x4,
(float)y4);
pen.Dispose();
}
else if (child is IArc)
{
var arc = child as IArc;
double x = Math.Min(arc.Point1.X, arc.Point2.X);
double y = Math.Min(arc.Point1.Y, arc.Point2.Y);
double width = Math.Abs(arc.Point2.X - arc.Point1.X);
double height = Math.Abs(arc.Point2.Y - arc.Point1.Y);
if (width > 0.0 && height > 0.0)
{
//.........这里部分代码省略.........
示例13: DrawConnectors
private void DrawConnectors(DiagramShapeControlBase parentShape, Graphics g, Pen pen, Brush brush, DiagramLayoutDirection direction, DiagramConnectorType connectorType)
{
if (parentShape.Expanded)
{
Point startPoint = new Point();
Point endPoint = new Point();
if (showExpanders)
{
startPoint.X = parentShape.expander.Left + parentShape.expander.Width / 2;
startPoint.Y = parentShape.expander.Top + parentShape.expander.Height / 2;
}
else
{
if (direction == DiagramLayoutDirection.Vertical)
{
startPoint.X = parentShape.Left + parentShape.Width / 2;
startPoint.Y = parentShape.Bottom;
}
else if (direction == DiagramLayoutDirection.Horizontal)
{
startPoint.Y = parentShape.Top + parentShape.Height / 2;
startPoint.X = parentShape.Right;
}
}
foreach (DiagramShapeControlBase shape in parentShape.childShapes)
{
if (direction == DiagramLayoutDirection.Vertical)
{
endPoint.Y = shape.Top;
endPoint.X = shape.Left + (shape.Width / 2);
}
else if (direction == DiagramLayoutDirection.Horizontal)
{
endPoint.Y = shape.Top + (shape.Height / 2);
endPoint.X = shape.Left;
}
switch (connectorType)
{
case DiagramConnectorType.Standard:
g.DrawLine(pen, startPoint, endPoint);
break;
case DiagramConnectorType.Bezier:
Point pt1 = Point.Empty;
Point pt2 = Point.Empty;
if (direction == DiagramLayoutDirection.Vertical)
{
pt1 = new Point(startPoint.X, startPoint.Y + 20);
pt2 = new Point(endPoint.X, endPoint.Y - 20);
}
else if (direction == DiagramLayoutDirection.Horizontal)
{
pt1 = new Point(startPoint.X + 20, startPoint.Y);
pt2 = new Point(endPoint.X - 20, endPoint.Y);
}
g.DrawBezier(pen, startPoint, pt1, pt2, endPoint);
break;
}
// Draw arrows
if (drawArrows)
{
Point anglePoint = new Point(endPoint.X - startPoint.X, endPoint.Y - startPoint.Y);
float angle = (float)(Math.Atan2(anglePoint.Y, anglePoint.X) * (180.0 / Math.PI));
if (connectorType == DiagramConnectorType.Bezier)
{
if (direction == DiagramLayoutDirection.Horizontal)
angle *= 0.5f;
else
angle = 90.0f + (angle - 90.0f) * 0.5f;
}
g.TranslateTransform(endPoint.X, endPoint.Y);
g.RotateTransform(angle);
g.FillPath(brush, arrowPath);
g.ResetTransform();
}
DrawConnectors(shape, g, pen, brush, direction, connectorType);
}
}
}
示例14: 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),
//.........这里部分代码省略.........
示例15: DrawSelectedString
private void DrawSelectedString(Graphics g)
{
// highlight the selected cells
g.DrawImage(texSelected, new Point(0,0));
// draw the wiring
if (cellPoints.Length > 1) {
g.DrawLines(new Pen(Color.FromArgb(80, Color.Black), 3.0f), cellPoints);
g.DrawLines(new Pen(Color.LightYellow, 1.0f), cellPoints);
}
// draw the bypass diode arcs
int ndiodes = CellString.BypassDiodes.Count;
for (int i = 0; i < ndiodes; i++) {
ArraySpec.BypassDiode diode = CellString.BypassDiodes[i];
PointF pA = junctionPoints[diode.CellIxs.First];
PointF pB = junctionPoints[diode.CellIxs.Second + 1];
float perpX = (pB.Y - pA.Y) * 0.2f;
float perpY = (pA.X - pB.X) * 0.2f;
PointF pMidA = new PointF(
pA.X * 0.7f + pB.X * 0.3f + perpX,
pA.Y * 0.7f + pB.Y * 0.3f + perpY);
PointF pMidB = new PointF(
pA.X * 0.3f + pB.X * 0.7f + perpX,
pA.Y * 0.3f + pB.Y * 0.7f + perpY);
g.DrawBezier(new Pen(Color.FromArgb(200, Color.Black), 5f), pA, pMidA, pMidB, pB);
g.DrawBezier(new Pen(Color.Red, 3f), pA, pMidA, pMidB, pB);
}
// draw the bypass diode endpoints
foreach(int i in bypassJunctions){
DrawJunction(g, junctionPoints[i], Brushes.Red);
}
}