本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.Clone方法的具体用法?C# GraphicsPath.Clone怎么用?C# GraphicsPath.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.Clone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRegionImage
public static Image GetRegionImage(Image surfaceImage, GraphicsPath regionFillPath, GraphicsPath regionDrawPath, SurfaceOptions options)
{
if (regionFillPath != null)
{
Image img;
Rectangle regionArea = Rectangle.Round(regionFillPath.GetBounds());
Rectangle screenRectangle = CaptureHelpers.GetScreenBounds0Based();
Rectangle newRegionArea = Rectangle.Intersect(regionArea, screenRectangle);
using (GraphicsPath gp = (GraphicsPath)regionFillPath.Clone())
{
MoveGraphicsPath(gp, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y));
img = ImageHelpers.CropImage(surfaceImage, newRegionArea, gp);
if (options.DrawBorder)
{
GraphicsPath gpOutline = regionDrawPath ?? regionFillPath;
using (GraphicsPath gp2 = (GraphicsPath)gpOutline.Clone())
{
MoveGraphicsPath(gp2, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y));
img = ImageHelpers.DrawOutline(img, gp2);
}
}
}
return img;
}
return null;
}
示例2: Read
///<summary>
/// Converts a <see cref="GraphicsPath"/> to a Geometry, flattening it first.
///</summary>
/// <param name="shp">The <see cref="GraphicsPath"/></param>
/// <param name="flatness">The flatness parameter to use</param>
/// <param name="geomFact">The GeometryFactory to use</param>
/// <returns>A Geometry representing the shape</returns>
public static IGeometry Read(GraphicsPath shp, double flatness, IGeometryFactory geomFact)
{
var path = (GraphicsPath)shp.Clone();
path.Flatten(InvertY, (float)flatness);
var pathIt = new GraphicsPathIterator(path);
return Read(pathIt, geomFact);
}
示例3: ApplyRegionPathToImage
public static Image ApplyRegionPathToImage(Image backgroundImage, GraphicsPath regionFillPath, RegionCaptureOptions options)
{
if (backgroundImage != null && regionFillPath != null)
{
Image img;
Rectangle regionArea = Rectangle.Round(regionFillPath.GetBounds());
Rectangle screenRectangle = CaptureHelpers.GetScreenBounds0Based();
Rectangle newRegionArea = Rectangle.Intersect(regionArea, screenRectangle);
using (GraphicsPath gp = (GraphicsPath)regionFillPath.Clone())
{
using (Matrix matrix = new Matrix())
{
gp.CloseFigure();
matrix.Translate(-Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y));
gp.Transform(matrix);
}
img = ImageHelpers.CropImage(backgroundImage, newRegionArea, gp);
}
return img;
}
return null;
}
示例4: ClipPath
public static GraphicsPath ClipPath(GraphicsPath subjectPath, CombineMode combineMode, GraphicsPath clipPath)
{
GpcWrapper.Polygon.Validate(combineMode);
GpcWrapper.Polygon basePoly = new GpcWrapper.Polygon(subjectPath);
GraphicsPath clipClone = (GraphicsPath)clipPath.Clone();
clipClone.CloseAllFigures();
GpcWrapper.Polygon clipPoly = new GpcWrapper.Polygon(clipClone);
clipClone.Dispose();
GpcWrapper.Polygon clippedPoly = GpcWrapper.Polygon.Clip(combineMode, basePoly, clipPoly);
GraphicsPath returnPath = clippedPoly.ToGraphicsPath();
returnPath.CloseAllFigures();
return returnPath;
}
示例5: DrawBwShape
protected void DrawBwShape(Graphics g, GraphicsPath gpPass, float flOpacity, float flOutlineWidth, Color clBackground, Color clForecolour) {
if (flOpacity > 0.0F) {
GraphicsPath gp = (GraphicsPath)gpPass.Clone();
Matrix m = new Matrix();
m.Translate(this.m_pntDrawOffset.X, this.m_pntDrawOffset.Y);
gp.Transform(m);
Pen pen = new Pen(Color.FromArgb((int)(255.0F * flOpacity), clBackground), flOutlineWidth);
pen.LineJoin = LineJoin.Round;
g.DrawPath(pen, gp);
SolidBrush brush = new SolidBrush(Color.FromArgb((int)(255.0F * flOpacity), clForecolour));
g.FillPath(brush, gp);
brush.Dispose();
pen.Dispose();
m.Dispose();
gp.Dispose();
}
}
示例6: Flatten_Arc
public void Flatten_Arc ()
{
GraphicsPath path = new GraphicsPath ();
path.AddArc (0f, 0f, 100f, 100f, 30, 30);
GraphicsPath clone = (GraphicsPath) path.Clone ();
path.Flatten ();
CompareFlats (path, clone);
}
示例7: Flatten_Curve
public void Flatten_Curve ()
{
GraphicsPath path = new GraphicsPath ();
path.AddCurve (new Point[4] {
new Point (0, 0), new Point (40, 20),
new Point (20, 40), new Point (40, 40)
});
GraphicsPath clone = (GraphicsPath) path.Clone ();
path.Flatten ();
CompareFlats (path, clone);
}
示例8: Flatten_Empty
public void Flatten_Empty ()
{
GraphicsPath path = new GraphicsPath ();
GraphicsPath clone = (GraphicsPath) path.Clone ();
// this is a no-op as there's nothing in the path
path.Flatten ();
ComparePaths (path, clone);
}
示例9: Flatten_NullFloat
public void Flatten_NullFloat ()
{
GraphicsPath path = new GraphicsPath ();
GraphicsPath clone = (GraphicsPath) path.Clone ();
// this is a no-op as there's nothing in the path
// an no matrix to apply
path.Flatten (null, 1f);
ComparePaths (path, clone);
}
示例10: Flatten_Rectangle
public void Flatten_Rectangle ()
{
GraphicsPath path = new GraphicsPath ();
path.AddRectangle (new Rectangle (0, 0, 100, 100));
GraphicsPath clone = (GraphicsPath) path.Clone ();
path.Flatten ();
ComparePaths (path, clone);
}
示例11: IsOutlineVisible1
public void IsOutlineVisible1(Graphics g)
{
GraphicsPath myPath = new GraphicsPath();
Rectangle rect = new Rectangle(20, 20, 100, 100);
myPath.AddRectangle(rect);
Pen testPen = new Pen(Color.AliceBlue, 20);
var widePath = (GraphicsPath)myPath.Clone();
widePath.Widen(testPen);
g.FillPath(Brushes.Wheat, widePath);
g.DrawPath(Pens.Black, myPath);
var point = new PointF(100, 50);
bool visible = myPath.IsOutlineVisible(point, testPen, g);
g.FillRectangle(Brushes.Red, new RectangleF(point.X, point.Y, 2, 2));
// Show the result.
g.DrawString("Visible = " + visible, new Font("Arial", 12), Brushes.Red, point.X + 10, point.Y);
point.X = 115;
point.Y = 80;
visible = myPath.IsOutlineVisible(point, testPen, g);
g.FillRectangle(Brushes.Green, new RectangleF(point.X, point.Y, 2, 2));
// Show the result.
g.DrawString("Visible = " + visible, new Font("Arial", 12), Brushes.Green, point.X + 10, point.Y);
}
示例12: TransformPath
public GraphicsPath TransformPath(GraphicsPath path)
{
var p = (GraphicsPath)path.Clone();
p.Flatten(_Transform, 0.1f);
return p;
}
示例13: Flatten_Pie
public void Flatten_Pie ()
{
GraphicsPath path = new GraphicsPath ();
path.AddPie (0, 0, 100, 100, 30, 30);
GraphicsPath clone = (GraphicsPath) path.Clone ();
path.Flatten ();
CompareFlats (path, clone);
}
示例14: Paint
public void Paint(GraphicsPath path, Graphics g, int time, float opacity)
{
int num1 = 0;
int num2 = 0;
AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
path.FillMode = FillMode.Alternate;
g.SmoothingMode = base.OwnerDocument.SmoothingMode;
SpreadMethods methods1 = this.SpreadMethod;
bool flag1 = this.Units == Units.UserSpaceOnUse;
float single1 = this.CX;
float single2 = this.CY;
float single3 = this.R;
float single4 = this.FX;
float single5 = this.FY;
PointF[] tfArray2 = new PointF[7] { new PointF(single1, single2), new PointF(single1 + single3, single2), new PointF(single1 + (single3 * ((float) Math.Sin(1.8325957145940459))), single2 + (single3 * ((float) Math.Cos(1.8325957145940459)))), new PointF(single1 + (single3 * ((float) Math.Sin(1.3089969389957472))), single2 + (single3 * ((float) Math.Cos(1.3089969389957472)))), new PointF(single1, single2 + single3), PointF.Empty, PointF.Empty } ;
this.boundsPoints = tfArray2;
GraphicsPath path1 = this.gradientpath;
path1.Reset();
path1.AddEllipse((float) (single1 - single3), (float) (single2 - single3), (float) (2f * single3), (float) (2f * single3));
RectangleF ef1 = RectangleF.Empty;
RectangleF ef2 = PathFunc.GetBounds(path);
RectangleF ef3 = RectangleF.Empty;
this.coord.Reset();
if (flag1)
{
ef3 = ((SVG) base.OwnerDocument.DocumentElement).ViewPort;
}
else
{
ef2 = new RectangleF(0f, 0f, 1f, 1f);
ef3 = ef2;
ef1 = PathFunc.GetBounds(path);
this.coord.Translate(ef1.X, ef1.Y);
this.coord.Scale(ef1.Width, ef1.Height);
}
//if (this.stops.Count==0)return;
ColorBlend blend1 = new ColorBlend(this.Stops.Count);
Color[] colorArray1 = new Color[this.Stops.Count];
float[] singleArray1 = new float[this.Stops.Count];
SvgElementCollection collection1 = this.Stops;
for (int num3 = 0; num3 < collection1.Count; num3++)
{
GradientStop stop1 = (GradientStop) collection1[num3];
AnimFunc.CreateAnimateValues(stop1, time, out num1, out num2);
int num4 = 0xff;
if ((stop1.Opacity >= 0f) && (stop1.Opacity <= 255f))
{
if (stop1.Opacity <= 1f)
{
num4 = (int) (stop1.Opacity * 255f);
}
else
{
num4 = (int) stop1.Opacity;
}
}
num4 = (int) Math.Min((float) (opacity * 255f), (float) num4);
Color color1 = stop1.Color;
float single6 = Math.Min((float) 1f, Math.Max((float) 0f, stop1.ColorOffset));
colorArray1[num3] = Color.FromArgb(num4, color1.R, color1.G, color1.B);
singleArray1[num3] = single6;
}
float[] singleArray2 = (float[]) singleArray1.Clone();
Color[] colorArray2 = (Color[]) colorArray1.Clone();
Array.Sort(singleArray2, colorArray2);
Color color2 = colorArray2[0];
Color color3 = colorArray2[colorArray2.Length - 1];
if (singleArray2[0] != 0f)
{
float[] singleArray3 = (float[]) singleArray2.Clone();
Color[] colorArray3 = (Color[]) colorArray2.Clone();
singleArray2 = new float[singleArray2.Length + 1];
colorArray2 = new Color[colorArray2.Length + 1];
colorArray3.CopyTo(colorArray2, 1);
singleArray3.CopyTo(singleArray2, 1);
singleArray2[0] = 0f;
colorArray2[0] = color2;
}
if (singleArray2[singleArray2.Length - 1] != 1f)
{
float[] singleArray4 = (float[]) singleArray2.Clone();
Color[] colorArray4 = (Color[]) colorArray2.Clone();
singleArray2 = new float[singleArray2.Length + 1];
singleArray4.CopyTo(singleArray2, 0);
singleArray2[singleArray2.Length - 1] = 1f;
colorArray2 = new Color[colorArray2.Length + 1];
colorArray4.CopyTo(colorArray2, 0);
colorArray2[colorArray2.Length - 1] = color3;
}
if (methods1 == SpreadMethods.Pad)
{
float single7 = Math.Min((float) (single1 - single3), ef2.X);
float single8 = Math.Min((float) (single2 - single3), ef2.Y);
float single9 = Math.Max(single3, (float) (ef2.Width / 2f));
float single10 = this.cx - single3;
float single11 = this.r;
for (int num5 = 0; num5 < singleArray2.Length; num5++)
{
singleArray2[num5] = ((single10 + (single11 * singleArray2[num5])) - single7) / single9;
//.........这里部分代码省略.........
示例15: PPath
/// <summary>
/// Constructs a new PPath wrapping the given
/// <see cref="System.Drawing.Drawing2D.GraphicsPath">
/// System.Drawing.Drawing2D.GraphicsPath</see>.
/// </summary>
/// <param name="path">The path to wrap.</param>
public PPath(GraphicsPath path) {
pen = DEFAULT_PEN;
this.path = (GraphicsPath)path.Clone();
UpdateBoundsFromPath();
}