本文整理汇总了C#中Graphics.DrawBezier方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawBezier方法的具体用法?C# Graphics.DrawBezier怎么用?C# Graphics.DrawBezier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphics
的用法示例。
在下文中一共展示了Graphics.DrawBezier方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run()
{
// ExStart:DrawingBezier
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages();
// Creates an instance of FileStream
using (FileStream stream = new FileStream(dataDir + "DrawingBezier_out.bmp", FileMode.Create))
{
// Create an instance of BmpOptions and set its various properties
BmpOptions saveOptions = new BmpOptions();
saveOptions.BitsPerPixel = 32;
// Set the Source for BmpOptions and Create an instance of Image
saveOptions.Source = new StreamSource(stream);
using (Image image = Image.Create(saveOptions, 100, 100))
{
// Create and initialize an instance of Graphics class and clear Graphics surface
Graphics graphic = new Graphics(image);
graphic.Clear(Color.Yellow);
// Initializes the instance of PEN class with black color and width
Pen BlackPen = new Pen(Color.Black, 3);
float startX = 10;
float startY = 25;
float controlX1 = 20;
float controlY1 = 5;
float controlX2 = 55;
float controlY2 = 10;
float endX = 90;
float endY = 25;
// Draw a Bezier shape by specifying the Pen object having black color and co-ordinate Points and save all changes.
graphic.DrawBezier(BlackPen, startX, startY, controlX1, controlY1, controlX2, controlY2, endX, endY);
image.Save();
}
}
// ExEnd:DrawingBezier
}
示例2: DrawTab
public static void DrawTab(Graphics g, Rectangle r, Corners corner, GradientType gradient, Color darkColor, Color lightColor, Color edgeColor, bool closed)
{
//dims
Point[] points;
GraphicsPath path;
Region Region;
LinearGradientBrush linearBrush;
Brush brush = null;
Pen pen;
r.Inflate(- 1, - 1);
//set brushes
switch (gradient)
{
case GradientType.Flat:
brush = new SolidBrush(darkColor);
break;
case GradientType.Linear:
brush = new LinearGradientBrush(r, darkColor, lightColor, LinearGradientMode.Vertical);
break;
case GradientType.Bell:
linearBrush = new LinearGradientBrush(r, darkColor, lightColor, LinearGradientMode.Vertical);
linearBrush.SetSigmaBellShape((float) (0.17F), (float) (0.67F));
brush = linearBrush;
break;
}
pen = new pen(edgeColor, 1);
//generic points
points = new Point[12] {new Point(r.Left, r.Bottom), new Point(r.Left, r.Bottom - bshift), new Point(r.Left, r.Top + bshift), new Point(r.Left, r.Top), new Point(r.Left + bshift, r.Top), new Point(r.Right - bshift, r.Top), new Point(r.Right, r.Top), new Point(r.Right, r.Top + bshift), new Point(r.Right, r.Bottom - bshift), new Point(r.Right, r.Bottom), new Point(r.Right - bshift, r.Bottom), new Point(r.Left + bshift, r.Bottom)};
path = new GraphicsPath();
switch (corner)
{
case Corners.LeftBottom:
path.AddLine(points[3], points[1]);
path.AddBezier(points[1], points[0], points[0], points[11]);
path.AddLine(points[11], points[9]);
path.AddLine(points[9], points[6]);
path.AddLine(points[6], points[3]);
Region = new Region(path);
g.FillRegion(brush, Region);
g.DrawLine(pen, points[3], points[1]);
g.DrawBezier(pen, points[1], points[0], points[0], points[11]);
g.DrawLine(pen, points[11], points[9]);
g.DrawLine(pen, points[9], points[6]);
if (closed)
{
g.DrawLine(pen, points[6], points[3]);
}
break;
case Corners.LeftTop:
path.AddLine(points[0], points[2]);
path.AddBezier(points[2], points[3], points[3], points[4]);
path.AddLine(points[4], points[6]);
path.AddLine(points[6], points[9]);
path.AddLine(points[9], points[0]);
Region = new Region(path);
g.FillRegion(brush, Region);
g.DrawLine(pen, points[0], points[2]);
g.DrawBezier(pen, points[2], points[3], points[3], points[4]);
g.DrawLine(pen, points[4], points[6]);
g.DrawLine(pen, points[6], points[9]);
if (closed)
{
g.DrawLine(pen, points[9], points[0]);
}
break;
case Corners.Bottom:
path.AddLine(points[1], points[3]);
path.AddBezier(points[1], points[0], points[0], points[11]);
path.AddLine(points[11], points[10]);
path.AddBezier(points[10], points[9], points[9], points[8]);
path.AddLine(points[8], points[6]);
path.AddLine(points[6], points[3]);
Region = new Region(path);
g.FillRegion(brush, Region);
g.DrawLine(pen, points[1], points[3]);
g.DrawBezier(pen, points[1], points[0], points[0], points[11]);
g.DrawLine(pen, points[11], points[10]);
g.DrawBezier(pen, points[10], points[9], points[9], points[8]);
g.DrawLine(pen, points[8], points[6]);
if (closed)
{
g.DrawLine(pen, points[6], points[3]);
}
break;
case Corners.Top:
path.AddLine(points[0], points[2]);
path.AddBezier(points[2], points[3], points[3], points[4]);
path.AddLine(points[4], points[5]);
path.AddBezier(points[5], points[6], points[6], points[7]);
path.AddLine(points[7], points[9]);
path.AddLine(points[9], points[0]);
Region = new Region(path);
g.FillRegion(brush, Region);
//.........这里部分代码省略.........
示例3: Bezier
/// <summary>
/// This method draws a Bezier curve.
/// </summary>
/// <param name="graphics">It receives the Graphics instance</param>
/// <param name="array">An array of (x,y) pairs of coordinates used to draw the curve.</param>
public static void Bezier(Graphics graphics, int[] array)
{
Pen pen;
pen = manager.GetPen(graphics);
graphics.DrawBezier(pen, array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7]);
}
示例4: Draw
//.........这里部分代码省略.........
}
}
else
{
if (((Automata)this).getInstruction(i, car).Contains(j))
{
CsTran += ((CsTran.Length == 0) ? (car.ToString()) : ("/" + car.ToString()));
}
}
}
else
foreach (Object MotObj in ((Gfa)this).Read)
{
string Mot = MotObj.ToString();
if (((Gfa)this).getInstruction(i, Mot).Contains(j))
{
CsTran += ((CsTran.Length == 0) ? (Mot.ToString()) : ("/" + Mot));
}
}
#region //DrawTransition(i, j, CsTran);
AdjustableArrowCap Fleche = new AdjustableArrowCap(5, 5, true);
Pen FlechePen = new Pen(Color.Red, 2);
FlechePen.CustomEndCap = Fleche;
if (CsTran.Length != 0) // il existe une transition de Si vers Sj
{
Point p1 = myPointArray[i];
Point p2 = myPointArray[j];
Point t1 = new Point();
Point t2 = new Point();
Point t3 = new Point();
Point t4 = new Point();
/*if (p2.X < p1.X)
{
t2.X = p1.X;
t1.X = p2.X + 30;
t3.X = t4.X = ((t1.X + t2.X) / 2) - (20 * i);
}
else {
t2.X = p1.X + 30;
t1.X = p2.X;
t3.X = t4.X = ((t1.X + t2.X) / 2) + (20 * i);
}
if (p2.Y < p1.Y)
{
t2.Y = p1.Y + 15;
t1.Y = p2.Y + 15;
t3.Y = t4.Y = ((t1.Y + t2.Y) / 2) - (20 * i);
}
else
{
t2.Y = p1.Y + 15;
t1.Y = p2.Y + 15;
t3.Y = t4.Y = ((t1.Y + t2.Y) / 2) + (20 * i);
}
Dessin.DrawBezier(FlechePen,t1,t3 ,t4,t2);
*/
if (p2 != p1)
{
Dessin.DrawBezier(FlechePen, p1.X + ((p1.X > p2.X) ? (0) : (30)), p1.Y + 10 + (2 * i), ((p2.X + p1.X) / 2), ((6 * p1.Y + p2.Y) / 7) - 40 + Ran.Next(80), (p2.X + p1.X) / 2, ((6 * p1.Y + p2.Y) / 7) - 40 + Ran.Next(80), p2.X + ((p1.X > p2.X) ? (30) : (0)), p2.Y + 10 + +(2 * i));
Dessin.DrawString(CsTran, myfont, pinceau, ((p2.X + p1.X) / 2), (4 * p1.Y + p2.Y) / 5);
grImage.DrawBezier(FlechePen, p1.X + ((p1.X > p2.X) ? (0) : (30)), p1.Y + 10 + (2 * i), ((p2.X + p1.X) / 2), ((6 * p1.Y + p2.Y) / 7) - 40 + Ran.Next(80), (p2.X + p1.X) / 2, ((6 * p1.Y + p2.Y) / 7) - 40 + Ran.Next(80), p2.X + ((p1.X > p2.X) ? (30) : (0)), p2.Y + 10 + +(2 * i));
grImage.DrawString(CsTran, myfont, pinceau, ((p2.X + p1.X) / 2), (4 * p1.Y + p2.Y) / 5);
}
else //Si -> Si
{
Dessin.DrawBezier(FlechePen, p1.X, p1.Y + 15, p1.X + 2, p1.Y + 60, p1.X + 25, p1.Y + 60, p1.X + 30, p1.Y + 15);
Dessin.DrawString(CsTran, myfont, pinceau, p1.X + 15, p1.Y + 30);
grImage.DrawBezier(FlechePen, p1.X, p1.Y + 15, p1.X + 2, p1.Y + 60, p1.X + 25, p1.Y + 60, p1.X + 30, p1.Y + 15);
grImage.DrawString(CsTran, myfont, pinceau, p1.X + 15, p1.Y + 30);
}
}
SolidBrush Fill = new SolidBrush(Color.White);
Dessin.FillEllipse(Fill, p.X + 3, p.Y + 3, 30 - 6, 30 - 6);
Dessin.DrawString("S" + i, myfont, pinceau, (p.X + 5), (p.Y + 8));
grImage.FillEllipse(Fill, p.X + 3, p.Y + 3, 30 - 6, 30 - 6);
grImage.DrawString("S" + i, myfont, pinceau, (p.X + 5), (p.Y + 8));
#endregion
}
}
//DrawPanel.Refresh();
}
示例5: Draw
// Draw this path object.
public override void Draw(Graphics graphics, Pen pen)
{
graphics.DrawBezier(pen, x1, y1, x2, y2, x3, y3, x4, y4);
}