本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath类的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath类的具体用法?C# GraphicsPath怎么用?C# GraphicsPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsPath类属于System.Drawing.Drawing2D命名空间,在下文中一共展示了GraphicsPath类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
using (Graphics g = e.Graphics)
{
GraphicsPath path = new GraphicsPath();
path.AddLine(20, 20, 170, 20);
path.AddLine(20, 20, 20, 100);
// рисуем новую фигуру
path.StartFigure();
path.AddLine(240, 140, 240, 50);
path.AddLine(240, 140, 80, 140);
path.AddRectangle(new Rectangle(30, 30, 200, 100));
// локальное преобразование траектории
//Matrix X = new Matrix();
//X.RotateAt(45, new PointF(60.0f, 100.0f));
//path.Transform(X);
// рисуем path
Pen redPen = new Pen(Color.Red, 2);
g.FillPath(new SolidBrush(Color.Bisque), path);
g.DrawPath(redPen, path);
}
}
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:25,代码来源:Form1.cs
示例2: CalculateGraphicsPathFromBitmap
// From http://edu.cnzz.cn/show_3281.html
public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent)
{
GraphicsPath graphicsPath = new GraphicsPath();
if (colorTransparent == Color.Empty)
colorTransparent = bitmap.GetPixel(0, 0);
for(int row = 0; row < bitmap.Height; row ++)
{
int colOpaquePixel = 0;
for(int col = 0; col < bitmap.Width; col ++)
{
if(bitmap.GetPixel(col, row) != colorTransparent)
{
colOpaquePixel = col;
int colNext = col;
for(colNext = colOpaquePixel; colNext < bitmap.Width; colNext ++)
if(bitmap.GetPixel(colNext, row) == colorTransparent)
break;
graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1));
col = colNext;
}
}
}
return graphicsPath;
}
开发者ID:hanistory,项目名称:hasuite,代码行数:27,代码来源:DrawHelper.cs
示例3: Task1_Paint
private void Task1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
switch (_current)
{
case TextType.In:
e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.DarkSlateGray), 10, 75);
e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.Black), 12, 77);
break;
case TextType.Out:
e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.Black), 10, 75);
e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.DarkSlateGray), 12, 77);
break;
case TextType.Kon:
GraphicsPath path = new GraphicsPath();
path.AddString("Sample",
new FontFamily("Arial"),
(int) FontStyle.Italic,
50,
new Point(10, 75),
StringFormat.GenericDefault);
e.Graphics.DrawPath(new Pen(Color.Black), path);
break;
}
}
开发者ID:npzxcf,项目名称:ComputerGraphics,代码行数:25,代码来源:Task1.cs
示例4: GetBrush
public static System.Drawing.Brush GetBrush(this Brush brush, Rect frame)
{
var cb = brush as SolidBrush;
if (cb != null) {
return new System.Drawing.SolidBrush (cb.Color.GetColor ());
}
var lgb = brush as LinearGradientBrush;
if (lgb != null) {
var s = lgb.Absolute ? lgb.Start : frame.Position + lgb.Start * frame.Size;
var e = lgb.Absolute ? lgb.End : frame.Position + lgb.End * frame.Size;
var b = new System.Drawing.Drawing2D.LinearGradientBrush (GetPointF (s), GetPointF (e), System.Drawing.Color.Black, System.Drawing.Color.Black);
var bb = BuildBlend (lgb.Stops);
if (bb != null) {
b.InterpolationColors = bb;
}
return b;
}
var rgb = brush as RadialGradientBrush;
if (rgb != null) {
var r = rgb.GetAbsoluteRadius (frame);
var c = rgb.GetAbsoluteCenter (frame);
var path = new GraphicsPath ();
path.AddEllipse (GetRectangleF (new Rect (c - r, 2 * r)));
var b = new PathGradientBrush (path);
var bb = BuildBlend (rgb.Stops, true);
if (bb != null) {
b.InterpolationColors = bb;
}
return b;
}
throw new NotImplementedException ("Brush " + brush);
}
开发者ID:sami1971,项目名称:NGraphics,代码行数:35,代码来源:SystemDrawingPlatform.cs
示例5: createRoundedRectangles
private GraphicsPath createRoundedRectangles(int x, int y, int width, int height, int radius)
{
int xw = x + width;
int yh = y + height;
int xwr = xw - radius;
int yhr = yh - radius;
int xr = x + radius;
int yr = y + radius;
int r2 = radius * 2;
int xwr2 = xw - r2;
int yhr2 = yh - r2;
GraphicsPath p = new GraphicsPath();
p.StartFigure();
p.AddArc(x, y, r2, r2, 180, 90);
p.AddLine(xr, y, xwr, y);
p.AddArc(xwr2, y, r2, r2, 270, 90);
p.AddLine(xw, yr, xw, yhr);
p.AddArc(xwr2, yhr2, r2, r2, 0, 90);
p.AddLine(xwr, yh, xr, yh);
p.AddArc(x, yhr2, r2, r2, 90, 90);
p.AddLine(x, yhr, x, yr);
p.CloseFigure();
return p;
}
开发者ID:stormholder,项目名称:dotnet_alarmclock,代码行数:25,代码来源:Form1.cs
示例6: DrawRegionRepresentation
public override void DrawRegionRepresentation(Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
{
if (m_Param.Path.PointCount > 0)
{
GraphicsPath fill = new GraphicsPath();
RectangleF rect = m_Param.Path.GetBounds();
PointD refPt = (PointD)rect.Location + ((PointD)rect.Size.ToPointF()) / 2;
// this will draw beyond the shape's location
for (double i = -rect.Height; i < rect.Height; i++)
{
PointD pt1 = refPt + PointD.Orthogonal(m_Param.V) * i * drawMethods.Spacing(m_Param.C);
PointD pt2 = pt1 + m_Param.V * rect.Width * rect.Height;
PointD pt3 = pt1 - m_Param.V * rect.Width * rect.Height;
fill.StartFigure();
fill.AddLine((Point)pt2, (Point)pt3);
}
GraphicsContainer c = gc.BeginContainer();
gc.SetClip((Tools.Model.VectorPath)m_Param.Path);
gc.DrawPath(r.RegionGuides, fill);
gc.EndContainer(c);
}
}
开发者ID:rhfung,项目名称:KinematicTemplates,代码行数:26,代码来源:FakeHatchingFilter.cs
示例7: SimpleShapedForm_Load
private void SimpleShapedForm_Load(object sender, EventArgs e)
{
GraphicsPath path = new GraphicsPath();
path.AddEllipse(0, 0, this.Width, this.Height);
this.Region = new Region(path);
}
开发者ID:ehershey,项目名称:development,代码行数:7,代码来源:SimpleShapedForm.cs
示例8: GetTopRoundedRect
//public static GraphicsPath GetBottomRoundRect(RectangleF r, int offset)
//{
// int left = Math.Min((int)r.Left, (int)r.Right);
// int right = Math.Max((int)r.Left, (int)r.Right);
// int top = Math.Min((int)r.Top, (int)r.Bottom);
// int bottom = Math.Max((int)r.Top, (int)r.Bottom);
// GraphicsPath path = new GraphicsPath();
// path.AddLine(r.Right, r.Top, r.Right, r.Top);
// path.AddArc(right - offset, bottom - offset, offset, offset, 0.0f, 90.0f);
// path.AddArc(left, bottom - offset, offset, offset, 90.0f, 90.0f);
// path.AddLine(r.Left, r.Top, r.Left, r.Top);
// path.CloseFigure();
// return path;
//}
public static GraphicsPath GetTopRoundedRect(RectangleF r, int offset)
{
int left = Math.Min((int)r.Left, (int)r.Right);
int right = Math.Max((int)r.Left, (int)r.Right);
int top = Math.Min((int)r.Top, (int)r.Bottom);
int bottom = Math.Max((int)r.Top, (int)r.Bottom);
GraphicsPath path = new GraphicsPath();
try
{
path.AddArc(right - offset, top, offset, offset, 270.0f, 90.0f);
path.AddLine(r.Right, r.Bottom, r.Right, r.Bottom);
path.AddLine(r.Left, r.Bottom, r.Left, r.Bottom);
path.AddArc(left, top, offset, offset, 180.0f, 90.0f);
path.CloseFigure();
return path;
}
catch
{
path.Dispose();
throw;
}
}
开发者ID:helgihaf,项目名称:Alpha,代码行数:39,代码来源:PathHelper.cs
示例9: MeasureTextHeight
public static float MeasureTextHeight(Font font, string text, bool bold)
{
using (var sf = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near })
{
using (var path = new GraphicsPath())
{
var sb = new StringBuilder(text);
bool newLine = false;
const int leftMargin = 0;
int pathPointsStart = -1;
DrawText(font, sf, path, sb, false, bold, false, 0, 0, ref newLine, leftMargin, ref pathPointsStart);
float height = 0;
var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!!
int index = list.Length - 80;
if (index < 0)
index = 0;
for (int i = index; i < list.Length; i += 2)
{
if (list[i].Y > height)
height = list[i].Y;
}
for (int i = 0; i < list.Length; i += 2)
{
if (list[i].Y > height)
height = list[i].Y;
}
return height;
}
}
}
开发者ID:socialpercon,项目名称:subtitleedit,代码行数:34,代码来源:TextDraw.cs
示例10: AddTabBorder
public override void AddTabBorder(GraphicsPath path, Rectangle tabBounds)
{
switch (tabControl.Alignment)
{
case TabAlignment.Top:
path.AddLine(tabBounds.X, tabBounds.Bottom, tabBounds.X, tabBounds.Y + this.radius);
path.AddArc(tabBounds.X, tabBounds.Y, this.radius * 2, this.radius * 2, 180, 90);
path.AddLine(tabBounds.X + this.radius, tabBounds.Y, tabBounds.Right - this.radius, tabBounds.Y);
path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Y, this.radius * 2, this.radius * 2, 270, 90);
path.AddLine(tabBounds.Right, tabBounds.Y + this.radius, tabBounds.Right, tabBounds.Bottom);
break;
case TabAlignment.Bottom:
path.AddLine(tabBounds.Right, tabBounds.Y, tabBounds.Right, tabBounds.Bottom - this.radius);
path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 0, 90);
path.AddLine(tabBounds.Right - this.radius, tabBounds.Bottom, tabBounds.X + this.radius, tabBounds.Bottom);
path.AddArc(tabBounds.X, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 90, 90);
path.AddLine(tabBounds.X, tabBounds.Bottom - this.radius, tabBounds.X, tabBounds.Y);
break;
case TabAlignment.Left:
path.AddLine(tabBounds.Right, tabBounds.Bottom, tabBounds.X + this.radius, tabBounds.Bottom);
path.AddArc(tabBounds.X, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 90, 90);
path.AddLine(tabBounds.X, tabBounds.Bottom - this.radius, tabBounds.X, tabBounds.Y + this.radius);
path.AddArc(tabBounds.X, tabBounds.Y, this.radius * 2, this.radius * 2, 180, 90);
path.AddLine(tabBounds.X + this.radius, tabBounds.Y, tabBounds.Right, tabBounds.Y);
break;
case TabAlignment.Right:
path.AddLine(tabBounds.X, tabBounds.Y, tabBounds.Right - this.radius, tabBounds.Y);
path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Y, this.radius * 2, this.radius * 2, 270, 90);
path.AddLine(tabBounds.Right, tabBounds.Y + this.radius, tabBounds.Right, tabBounds.Bottom - this.radius);
path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 0, 90);
path.AddLine(tabBounds.Right - this.radius, tabBounds.Bottom, tabBounds.X, tabBounds.Bottom);
break;
}
}
开发者ID:h3tch,项目名称:ProtoFX,代码行数:35,代码来源:TabStyleRoundedProvider.cs
示例11: DrawRoundedRectangle
public static void DrawRoundedRectangle(Graphics newGraphics, Color boxColor, Color gradFillColor1, Color gradFillColor2, int xPosition, int yPosition,
int height, int width, int cornerRadius)
{
using (var boxPen = new Pen(boxColor))
{
using (var path = new GraphicsPath())
{
path.AddLine(xPosition + cornerRadius, yPosition, xPosition + width - (cornerRadius * 2), yPosition);
path.AddArc(xPosition + width - (cornerRadius * 2), yPosition, cornerRadius * 2, cornerRadius * 2, 270, 90);
path.AddLine(xPosition + width, yPosition + cornerRadius, xPosition + width,
yPosition + height - (cornerRadius * 2));
path.AddArc(xPosition + width - (cornerRadius * 2), yPosition + height - (cornerRadius * 2), cornerRadius * 2,
cornerRadius * 2, 0, 90);
path.AddLine(xPosition + width - (cornerRadius * 2), yPosition + height, xPosition + cornerRadius,
yPosition + height);
path.AddArc(xPosition, yPosition + height - (cornerRadius * 2), cornerRadius * 2, cornerRadius * 2, 90, 90);
path.AddLine(xPosition, yPosition + height - (cornerRadius * 2), xPosition, yPosition + cornerRadius);
path.AddArc(xPosition, yPosition, cornerRadius * 2, cornerRadius * 2, 180, 90);
path.CloseFigure();
newGraphics.DrawPath(boxPen, path);
var b = new LinearGradientBrush(new Point(xPosition, yPosition),
new Point(xPosition + width, yPosition + height), gradFillColor1,
gradFillColor2);
newGraphics.FillPath(b, path);
}
}
}
开发者ID:hithto,项目名称:Captcha,代码行数:29,代码来源:HtmlExtensions.cs
示例12: MakePath
public override GraphicsPath MakePath()
{
GraphicsPath path1 = new GraphicsPath(FillMode.Winding);
RectangleF ef1 = this.Bounds;
path1.AddEllipse(ef1.X, ef1.Y, ef1.Width, ef1.Height);
return path1;
}
开发者ID:JBTech,项目名称:Dot.Utility,代码行数:7,代码来源:EllipseGraph.cs
示例13: Get
public override GraphicsPath Get()
{
var shape = new GraphicsPath();
var bounds = new Rectangle(this.state.Left, this.state.Top, this.state.Width, this.state.Height);
shape.AddEllipse(bounds);
return shape;
}
开发者ID:attila3453,项目名称:alsing,代码行数:7,代码来源:EllipseShape.cs
示例14: DrawYourSelf
/// <summary>
/// Изчертава елипсите.
/// </summary>
/// <param name="graphics"></param>
public override void DrawYourSelf(Graphics graphics)
{
GraphicsPath path = new GraphicsPath();
path.StartFigure();
path.AddEllipse(Location.X + ModelSize.Width / 3, Location.Y + ModelSize.Height / 3, ModelSize.Width / 3, ModelSize.Height / 3);
path.CloseFigure();
path.StartFigure();
path.AddLine(Location.X + (ModelSize.Width * 2) / 3, Location.Y + ModelSize.Height / 2, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 2);
path.CloseFigure();
path.AddEllipse(new RectangleF(Location, ModelSize));
path.CloseFigure();
path.Transform(this.TMatrix.TransformationMatrix);
/*
* Създава се Pen, който изчертава контура, като използва
* цвят и дебелина (определят се от конструктора)
*/
Pen pen = new Pen(this.BorderColor, this.BorderWidth);
// Правим същото, но за запълването
if (IS_FILLED)
{
SolidBrush brush = new SolidBrush(this.FillColor);
graphics.FillPath(brush, path);
}
graphics.DrawPath(pen, path);
if (this.Selected)
{
this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
this.selectionUnit.DrawYourSelf(graphics);
}
}
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:35,代码来源:ConnectedEllipses.cs
示例15: Draw
public new void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons) {
GraphicsPath gpSeekPosition = new GraphicsPath();
gpSeekPosition.AddLine(new PointF(6.0F, 2), new PointF(this.SeekerBounds.Width - this.SeekerPosition * (this.SeekerBounds.Width - 15) - 5, 2));
gpSeekPosition.Widen(this.m_pOneWidth);
this.DrawBwShape(g, gpSeekPosition, this.ButtonOpacity, 4.0F, Color.Black, ControlPaint.LightLight(Color.LightSeaGreen));
if (this.m_isMouseDown == true) {
if (pntMouseLocation.X < pntDrawOffset.X) {
this.SeekerPosition = 0.0F;
}
else if (pntMouseLocation.X > pntDrawOffset.X + this.SeekerBounds.Width - 15) {
this.SeekerPosition = 1.0F;
}
else {
this.SeekerPosition = (pntMouseLocation.X - pntDrawOffset.X - 6) / (this.SeekerBounds.Width - 15);
}
}
float xBeginningOffset = pntDrawOffset.X;
pntDrawOffset.X += this.SeekerPosition * (this.SeekerBounds.Width - 15);
this.HotSpot = new RectangleF(-pntDrawOffset.X + xBeginningOffset, -15, this.SeekerBounds.Width, 20);
base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);
gpSeekPosition.Dispose();
}
开发者ID:EBassie,项目名称:Procon-1,代码行数:30,代码来源:MapTimelineSeekButton.cs
示例16: CreateRoundPath
/// <summary>
/// 建立带有圆角样式的路径。
/// </summary>
/// <param name="rect">用来建立路径的矩形。</param>
/// <param name="radius">圆角的大小。</param>
/// <returns>建立的路径。</returns>
public static GraphicsPath CreateRoundPath(Rectangle rect, int radius)
{
GraphicsPath path = new GraphicsPath();
int radiusCorrection = 1;
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
path.AddArc(
rect.Right - radius - radiusCorrection,
rect.Y,
radius,
radius,
270,
90);
path.AddArc(
rect.Right - radius - radiusCorrection,
rect.Bottom - radius - radiusCorrection,
radius,
radius, 0, 90);
path.AddArc(
rect.X,
rect.Bottom - radius - radiusCorrection,
radius,
radius,
90,
90);
path.CloseFigure();
return path;
}
开发者ID:hdkn235,项目名称:MyControls,代码行数:33,代码来源:RenderHelper.cs
示例17: Draw
/// <summary>
/// The graphics device and clip rectangle are in the parent coordinates.
/// </summary>
/// <param name="g"></param>
/// <param name="clipRectangle"></param>
/// <param name="symbol">The symbol to use for drawing.</param>
public void Draw(Graphics g, Rectangle clipRectangle, ISymbol symbol)
{
Color topLeft;
Color bottomRight;
if (_isSelected)
{
topLeft = _selectionColor.Darker(.3F);
bottomRight = _selectionColor.Lighter(.3F);
}
else
{
topLeft = _backColor.Lighter(.3F);
bottomRight = _backColor.Darker(.3F);
}
LinearGradientBrush b = new LinearGradientBrush(_bounds, topLeft, bottomRight, LinearGradientMode.ForwardDiagonal);
GraphicsPath gp = new GraphicsPath();
gp.AddRoundedRectangle(Bounds, _roundingRadius);
g.FillPath(b, gp);
gp.Dispose();
b.Dispose();
Matrix old = g.Transform;
Matrix shift = g.Transform;
shift.Translate(_bounds.Left + _bounds.Width / 2, _bounds.Top + _bounds.Height / 2);
g.Transform = shift;
if (symbol != null)
{
OnDrawSymbol(g, symbol);
}
g.Transform = old;
}
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:39,代码来源:SizeBox.cs
示例18: GetPath
protected virtual GraphicsPath GetPath(int index)
{
Rectangle rect = base.GetTabRect(index);
GraphicsPath gp = new GraphicsPath();
switch (base.Alignment)
{
case TabAlignment.Top:
gp.AddLine(rect.Left + 1, rect.Bottom, rect.Left + 1, rect.Top);
gp.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom);
break;
case TabAlignment.Bottom:
gp.AddLine(rect.Left + 1, rect.Top - 1, rect.Left + 1, rect.Bottom);
gp.AddLine(rect.Right, rect.Bottom, rect.Right, rect.Top - 1);
break;
case TabAlignment.Left:
gp.AddLine(rect.Right + 1, rect.Top + 1, rect.Left + 1, rect.Top + 1);
gp.AddLine(rect.Left + 1, rect.Bottom, rect.Right, rect.Bottom);
break;
case TabAlignment.Right:
gp.AddLine(rect.Left - 1, rect.Top + 1, rect.Right - 2, rect.Top + 1);
gp.AddLine(rect.Right - 2, rect.Bottom, rect.Left - 1, rect.Bottom);
break;
}
return gp;
}
开发者ID:sagar1589,项目名称:Delta.Cryptography,代码行数:27,代码来源:CustomTabControl.cs
示例19: Paint
/// <summary>
/// Repaints the form with cool background and stuff
/// </summary>
/// <param name="graph">The graphics object to paint to, the element will be drawn to 0, 0</param>
public override void Paint(Graphics graph)
{
//Draws Rectangular Shapes
if (Shape == ModelShape.Arrow)
{
_arrowPath = new GraphicsPath();
//Draws the basic shape
Pen arrowPen;
if (Highlight < 1)
arrowPen = new Pen(Color.Cyan, 3F);
else
arrowPen = new Pen(Color.Black, 3F);
//Draws the curved arrow
Point[] lineArray = new Point[4];
lineArray[0] = new Point(_startPoint.X, _startPoint.Y);
lineArray[1] = new Point(_startPoint.X - ((_startPoint.X - _stopPoint.X) / 3), _startPoint.Y);
lineArray[2] = new Point(_stopPoint.X - ((_stopPoint.X - _startPoint.X) / 3), _stopPoint.Y);
lineArray[3] = new Point(_stopPoint.X, _stopPoint.Y);
graph.DrawBeziers(arrowPen, lineArray);
_arrowPath.AddBeziers(lineArray);
_arrowPath.Flatten();
//Draws the arrow head
Point[] arrowArray = new Point[3];
arrowArray[0] = _stopPoint;
arrowArray[1] = new Point(_stopPoint.X - (5 * Math.Sign(_stopPoint.X - _startPoint.X)), _stopPoint.Y - 2);
arrowArray[2] = new Point(_stopPoint.X - (5 * Math.Sign(_stopPoint.X - _startPoint.X)), _stopPoint.Y + 2);
graph.DrawPolygon(arrowPen, arrowArray);
//Garbage collection
arrowPen.Dispose();
}
}
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:39,代码来源:ArrowElement.cs
示例20: CreateRoundedRectangle
public static GraphicsPath CreateRoundedRectangle(SizeF size, PointF location)
{
int cornerSize = (int)GraphConstants.CornerSize * 2;
int connectorSize = (int)GraphConstants.ConnectorSize;
int halfConnectorSize = (int)Math.Ceiling(connectorSize / 2.0f);
var height = size.Height;
var width = size.Width;
var halfWidth = width / 2.0f;
var halfHeight = height / 2.0f;
var connectorOffset = (int)Math.Floor((GraphConstants.MinimumItemHeight - GraphConstants.ConnectorSize) / 2.0f);
var left = location.X;
var top = location.Y;
var right = location.X + width;
var bottom = location.Y + height;
var path = new GraphicsPath(FillMode.Winding);
path.AddArc(left, top, cornerSize, cornerSize, 180, 90);
path.AddArc(right - cornerSize, top, cornerSize, cornerSize, 270, 90);
path.AddArc(right - cornerSize, bottom - cornerSize, cornerSize, cornerSize, 0, 90);
path.AddArc(left, bottom - cornerSize, cornerSize, cornerSize, 90, 90);
path.CloseFigure();
return path;
}
开发者ID:fluffyfreak,项目名称:Graph,代码行数:25,代码来源:GraphRenderer.cs
注:本文中的System.Drawing.Drawing2D.GraphicsPath类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论