本文整理汇总了C#中Cairo.Context.CreateEllipsePath方法的典型用法代码示例。如果您正苦于以下问题:C# Context.CreateEllipsePath方法的具体用法?C# Context.CreateEllipsePath怎么用?C# Context.CreateEllipsePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.CreateEllipsePath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawShape
protected override Rectangle DrawShape(Rectangle r, Layer l)
{
Path path = PintaCore.Layers.SelectionPath;
using (Context g = new Context (l.Surface))
PintaCore.Layers.SelectionPath = g.CreateEllipsePath (r);
(path as IDisposable).Dispose ();
return r;
}
示例2: DrawShape
protected override Rectangle DrawShape(Rectangle r, Layer l)
{
Document doc = PintaCore.Workspace.ActiveDocument;
Path path = doc.SelectionPath;
using (Context g = new Context (l.Surface))
doc.SelectionPath = g.CreateEllipsePath (r);
(path as IDisposable).Dispose ();
return r;
}
示例3: CreateEllipseSelection
/// <summary>
/// Create an elliptical Selection from a bounding Rectangle.
/// </summary>
/// <param name="selectionSurface">The selection surface to use for calculating the elliptical Path.</param>
/// <param name="r">The bounding Rectangle surrounding the ellipse.</param>
public void CreateEllipseSelection(Surface selectionSurface, Rectangle r)
{
using (Context g = new Context(selectionSurface))
{
SelectionPath = g.CreateEllipsePath(r);
}
//These values were calculated in the static CreateEllipsePath method
//in Pinta.Core.CairoExtensions, so they were used here as well.
double rx = r.Width / 2; //1/2 of the bounding Rectangle Width.
double ry = r.Height / 2; //1/2 of the bounding Rectangle Height.
double cx = r.X + rx; //The middle of the bounding Rectangle, horizontally speaking.
double cy = r.Y + ry; //The middle of the bounding Rectangle, vertically speaking.
double c1 = 0.552285; //A constant factor used to give the least approximation error.
//Clear the Selection Polygons collection to start from a clean slate.
SelectionPolygons.Clear();
//Calculate an appropriate interval at which to increment t based on
//the bounding Rectangle's Width and Height properties. The increment
//for t determines how many intermediate Points to calculate for the
//ellipse. For each curve, t will go from tInterval to 1. The lower
//the value of tInterval, the higher number of intermediate Points
//that will be calculated and stored into the Polygon collection.
double tInterval = 1d / (r.Width + r.Height);
//Create a new Polygon to store the upcoming ellipse.
List<IntPoint> newPolygon = new List<IntPoint>();
//These values were also calculated in the CreateEllipsePath method. This is where
//the ellipse's 4 curves (and all of the Points on each curve) are determined.
//Note: each curve is consecutive to the previous one, but they *do not* overlap,
//other than the first/last Point (which is how it is supposed to work).
//The starting Point.
newPolygon.Add(new IntPoint((long)(cx + rx), (long)cy));
//Curve 1.
newPolygon.AddRange(CalculateCurvePoints(tInterval,
cx + rx, cy,
cx + rx, cy - c1 * ry,
cx + c1 * rx, cy - ry,
cx, cy - ry));
//Curve 2.
newPolygon.AddRange(CalculateCurvePoints(tInterval,
cx, cy - ry,
cx - c1 * rx, cy - ry,
cx - rx, cy - c1 * ry,
cx - rx, cy));
//Curve 3.
newPolygon.AddRange(CalculateCurvePoints(tInterval,
cx - rx, cy,
cx - rx, cy + c1 * ry,
cx - c1 * rx, cy + ry,
cx, cy + ry));
//Curve 4.
newPolygon.AddRange(CalculateCurvePoints(tInterval,
cx, cy + ry,
cx + c1 * rx, cy + ry,
cx + rx, cy + c1 * ry,
cx + rx, cy));
//Add the newly calculated elliptical Polygon.
SelectionPolygons.Add(newPolygon);
}