本文整理汇总了C#中GraphicsPath类的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath类的具体用法?C# GraphicsPath怎么用?C# GraphicsPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsPath类属于命名空间,在下文中一共展示了GraphicsPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResimOlustur
private void ResimOlustur(int genislik, int yukseklik)
{
Bitmap bitmap = new Bitmap(genislik, yukseklik, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bitmap);
g.SmoothingMode = SmoothingMode.AntiAlias;
Rectangle rect = new Rectangle(0, 0, genislik, yukseklik);
HatchBrush hatchBrush = new HatchBrush(HatchStyle.SmallConfetti, Color.LightGray, Color.White);
g.FillRectangle(hatchBrush, rect);
SizeF size;
float fontSize = rect.Height + 1;
Font font;
do
{
fontSize--;
font = new Font(System.Drawing.FontFamily.GenericSerif.Name, fontSize, FontStyle.Bold);
size = g.MeasureString(this.text, font);
} while (size.Width > rect.Width);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
GraphicsPath path = new GraphicsPath();
path.AddString(this.text, font.FontFamily, (int)font.Style, font.Size, rect, format);
float v = 4F;
PointF[] points =
{
new PointF(this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v),
new PointF(rect.Width - this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v),
new PointF(this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v),
new PointF(rect.Width - this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v)
};
Matrix matrix = new Matrix();
matrix.Translate(0F, 0F);
path.Warp(points, rect, matrix, WarpMode.Perspective, 0F);
hatchBrush = new HatchBrush(HatchStyle.LargeConfetti, Color.LightGray, Color.DarkGray);
g.FillPath(hatchBrush, path);
int m = Math.Max(rect.Width, rect.Height);
for (int i = 0; i < (int)(rect.Width * rect.Height / 30F); i++)
{
int x = this.random.Next(rect.Width);
int y = this.random.Next(rect.Height);
int w = this.random.Next(m / 50);
int h = this.random.Next(m / 50);
g.FillEllipse(hatchBrush, x, y, w, h);
}
font.Dispose();
hatchBrush.Dispose();
g.Dispose();
this.Image = bitmap;
}
示例2: MainForm_Paint
void MainForm_Paint (object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
GraphicsPath path = new GraphicsPath ();
Rectangle borderect = new Rectangle (49, 49, 252, 252);
g.FillRectangle (new SolidBrush (Color.White), borderect);
int Diameter = 16;
Rectangle baserect = new Rectangle (50, 50, 249, 249);
Rectangle arcrect = new Rectangle (baserect.Location, new Size (Diameter, Diameter));
// handle top left corner
path.AddArc (arcrect, 180, 90);
// handle top right corner
arcrect.X = baserect.Right - Diameter;
path.AddArc (arcrect, 270, 90);
// handle baserect right corner
arcrect.Y = baserect.Bottom - Diameter;
path.AddArc (arcrect, 0, 90);
// handle bottom left corner
arcrect.X = baserect.Left;
path.AddArc (arcrect, 90, 90);
path.CloseFigure ();
g.DrawPath (Pens.SteelBlue, path);
}
示例3: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
e.Graphics.CompositingMode = CompositingMode.SourceOver;
GraphicsPath stroke = new GraphicsPath();
stroke.AddString(this.Text, this.Font.FontFamily, (int)FontStyle.Regular, this.Font.Size * 1.2f, new Point(0, 0), StringFormat.GenericDefault);
string tmp = this.Text;
while (stroke.GetBounds().Width > this.Width - 8) {
tmp = tmp.Substring(0, tmp.Length - 1);
stroke = new GraphicsPath();
stroke.AddString(tmp + "...", this.Font.FontFamily, (int)FontStyle.Regular, this.Font.Size * 1.2f, new Point(0, 0), StringFormat.GenericDefault);
}
RectangleF bounds = stroke.GetBounds();
Matrix translationMatrix = new Matrix();
if (this.TextAlign == ContentAlignment.TopRight || this.TextAlign == ContentAlignment.MiddleRight || this.TextAlign == ContentAlignment.BottomRight) {
translationMatrix.Translate(this.Width - bounds.Width - 8, 0);
} else if (this.TextAlign == ContentAlignment.TopCenter || this.TextAlign == ContentAlignment.MiddleCenter || this.TextAlign == ContentAlignment.BottomCenter) {
translationMatrix.Translate((this.Width - bounds.Width - 8) / 2, 0);
}
if (this.TextAlign == ContentAlignment.MiddleLeft || this.TextAlign == ContentAlignment.MiddleRight || this.TextAlign == ContentAlignment.MiddleCenter) {
translationMatrix.Translate(0, (this.Height - bounds.Height - 5) / 2);
} else if (this.TextAlign == ContentAlignment.BottomLeft || this.TextAlign == ContentAlignment.BottomCenter || this.TextAlign == ContentAlignment.BottomRight) {
translationMatrix.Translate(0, (this.Height - bounds.Height - 5));
}
stroke.Transform(translationMatrix);
e.Graphics.DrawPath(new Pen(Brushes.Black, 3.0f), stroke); /* Stroke */
e.Graphics.FillPath(Brushes.White, stroke); /* Text */
}
示例4: OnPaint
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
GraphicsPath grPath = new GraphicsPath();
grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
this.Region = new System.Drawing.Region(grPath);
base.OnPaint(e);
}
示例5: DrawPath
public override void DrawPath(GraphicsPath gfxPath)
{
throw new NotSupportedException();
//gx.DrawPath(internalPen, gfxPath.InnerPath as System.Drawing.Drawing2D.GraphicsPath);
}
示例6: DrawPath
public override void DrawPath(GraphicsPath gfxPath)
{
//convert graphics path to skia path
using (SKPath p = ResolveGraphicsPath(gfxPath))
{
skCanvas.DrawPath(p, stroke);
}
}
示例7: OnResize
protected override void OnResize(EventArgs e)
{
using (var path = new GraphicsPath())
{
path.AddEllipse(new Rectangle(2, 2, this.Width - 4, this.Height - 4));
this.Region = new Region(path);
}
base.OnResize(e);
}
示例8: Quadrilateral
/// <summary>
/// Initilizes <c>Quadrilateral</c> object with given corner points.
/// </summary>
/// <param name="point1">
/// First <c>PointF</c>.
/// </param>
/// <param name="point2">
/// Second <c>PointF</c>.
/// </param>
/// <param name="point3">
/// Third <c>PointF</c>.
/// </param>
/// <param name="point4">
/// Fourth <c>PointF</c>.
/// </param>
/// <param name="toClose">
/// Indicator should the quadrilateral be closed by the line.
/// </param>
public Quadrilateral(PointF point1, PointF point2, PointF point3, PointF point4, bool toClose)
{
byte[] pointTypes = (byte[])s_quadrilateralPointTypes.Clone();
if (toClose)
pointTypes[3] |= (byte)PathPointType.PathPointTypeCloseSubpath;//CloseSubpath;
m_path = new GraphicsPath();//new GraphicsPath(new PointF[] { point1, point2, point3, point4 }, pointTypes);
//m_path.
}
示例9: MainForm_Load
void MainForm_Load (object sender, EventArgs e)
{
GraphicsPath gp = new GraphicsPath ();
gp.AddArc (_changeShapeButton.ClientRectangle, 0.0f, 360.0f);
_changeShapeButton.Region = new Region (gp);
InstructionsForm instructionsForm = new InstructionsForm ();
instructionsForm.Show ();
}
示例10: OnResize
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
using (var gp = new GraphicsPath())
{
gp.AddEllipse(new Rectangle(0, 0, this.Width - 1, this.Height - 1));
this.Region = new Region(gp);
}
}
示例11: CustomLineCap
public CustomLineCap(GraphicsPath fillPath,
GraphicsPath strokePath,
LineCap baseCap, float baseInset)
{
this.fillPath = fillPath;
this.strokePath = strokePath;
this.baseCap = baseCap;
this.baseInset = baseInset;
}
示例12: CreateRound
static internal GraphicsPath CreateRound(Rectangle r, int slope)
{
CreateRoundPath = new GraphicsPath(FillMode.Winding);
CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180f, 90f);
CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270f, 90f);
CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0f, 90f);
CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90f, 90f);
CreateRoundPath.CloseFigure();
return CreateRoundPath;
}
示例13: GetArrowLinePath
public static GraphicsPath GetArrowLinePath(float x1, float y1, float x2, float y2, bool include_arrow, float extra_thickness = 0)
{
var newPoints = GetArrowLinePoints(x1, y1, x2, y2, extra_thickness);
var path = new GraphicsPath(FillMode.Winding);
path.AddLines(newPoints.ToArray());
//if (include_arrow)
// path.AddLines(GetArrowPoints(x2, y2, extra_thickness).ToArray());
//path.CloseFigure();
return path;
}
示例14: RoundRect
public static GraphicsPath RoundRect(Rectangle rect, int Curve)
{
GraphicsPath P = new GraphicsPath();
int ArcRectWidth = Curve * 2;
P.AddArc(new Rectangle(rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -180, 90);
P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -90, 90);
P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 0, 90);
P.AddArc(new Rectangle(rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 90, 90);
P.AddLine(new Point(rect.X, rect.Height - ArcRectWidth + rect.Y), new Point(rect.X, Curve + rect.Y));
return P;
}
示例15: CustomLineCap
public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
{
IntPtr fill = IntPtr.Zero;
IntPtr stroke = IntPtr.Zero;
if (fillPath != null)
fill = fillPath.nativePath;
if (strokePath != null)
stroke = strokePath.nativePath;
Status status = GDIPlus.GdipCreateCustomLineCap (fill, stroke, baseCap, baseInset, out nativeObject);
GDIPlus.CheckStatus (status);
}