本文整理汇总了C#中Cairo.Context.CreatePolygonPath方法的典型用法代码示例。如果您正苦于以下问题:C# Context.CreatePolygonPath方法的具体用法?C# Context.CreatePolygonPath怎么用?C# Context.CreatePolygonPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.CreatePolygonPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnFillRegionComputed
protected unsafe override void OnFillRegionComputed(Point[][] polygonSet)
{
SimpleHistoryItem hist = new SimpleHistoryItem (Icon, Name);
hist.TakeSnapshotOfLayer (PintaCore.Layers.CurrentLayer);
using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
g.AppendPath (PintaCore.Layers.SelectionPath);
g.FillRule = FillRule.EvenOdd;
g.Clip ();
// Reset FillRule to the default
g.FillRule = FillRule.Winding;
g.AppendPath (g.CreatePolygonPath (polygonSet));
g.Antialias = Antialias.Subpixel;
g.Color = fill_color;
g.Fill ();
}
PintaCore.History.PushNewItem (hist);
PintaCore.Workspace.Invalidate ();
}
示例2: Invert
/// <summary>
/// Inverts the selection.
/// </summary>
/// <param name="surface">
/// Surface for the selection path.
/// </param>
/// <param name='imageSize'>
/// The size of the document.
/// </param>
public void Invert(Surface surface, Gdk.Size imageSize)
{
List<List<IntPoint>> resultingPolygons = new List<List<IntPoint>> ();
var documentPolygon = CreateRectanglePolygon (new Rectangle (0, 0, imageSize.Width, imageSize.Height));
// Create a rectangle that is the size of the entire image,
// and subtract all of the polygons in the current selection from it.
SelectionClipper.AddPolygon (documentPolygon, PolyType.ptSubject);
SelectionClipper.AddPolygons (SelectionPolygons, PolyType.ptClip);
SelectionClipper.Execute (ClipType.ctDifference, resultingPolygons);
SelectionClipper.Clear ();
SelectionPolygons = resultingPolygons;
using (Context g = new Context (surface)) {
SelectionPath = g.CreatePolygonPath (ConvertToPolygonSet (resultingPolygons));
}
}
示例3: OnUpdateTransform
protected override void OnUpdateTransform(Matrix transform)
{
base.OnUpdateTransform (transform);
List<List<IntPoint>> newSelectionPolygons = DocumentSelection.Transform (original_selection, transform);
Document doc = PintaCore.Workspace.ActiveDocument;
doc.Selection.SelectionClipper.Clear ();
doc.Selection.SelectionPolygons = newSelectionPolygons;
using (var g = new Cairo.Context (doc.CurrentUserLayer.Surface)) {
doc.Selection.SelectionPath = g.CreatePolygonPath (DocumentSelection.ConvertToPolygonSet (newSelectionPolygons));
g.FillRule = FillRule.EvenOdd;
g.AppendPath (doc.Selection.SelectionPath);
}
doc.ShowSelection = true;
doc.SelectionLayer.Transform.InitMatrix (original_transform);
doc.SelectionLayer.Transform.Multiply (transform);
PintaCore.Workspace.Invalidate ();
}
示例4: OnFillRegionComputed
protected override void OnFillRegionComputed(Point[][] polygonSet)
{
SelectionHistoryItem undoAction = new SelectionHistoryItem (this.Icon, this.Name);
undoAction.TakeSnapshot ();
Path path = PintaCore.Layers.SelectionPath;
using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
PintaCore.Layers.SelectionPath = g.CreatePolygonPath (polygonSet);
switch (combineMode) {
case CombineMode.Union:
g.AppendPath (path);
break;
case CombineMode.Xor:
//not supported
break;
case CombineMode.Exclude:
//not supported
break;
case CombineMode.Replace:
//do nothing
break;
}
}
(path as IDisposable).Dispose ();
//Selection.PerformChanging();
//Selection.SetContinuation(polygonSet, this.combineMode);
//Selection.CommitContinuation();
//Selection.PerformChanged();
PintaCore.History.PushNewItem (undoAction);
PintaCore.Workspace.Invalidate ();
}
示例5: OnFillRegionComputed
protected override void OnFillRegionComputed(Point[][] polygonSet)
{
Document doc = PintaCore.Workspace.ActiveDocument;
SelectionHistoryItem undoAction = new SelectionHistoryItem(this.Icon, this.Name);
undoAction.TakeSnapshot();
//Convert Pinta's passed in Polygon Set to a Clipper Polygon collection.
List<List<IntPoint>> newPolygons = DocumentSelection.ConvertToPolygons(polygonSet);
using (Context g = new Context(PintaCore.Layers.CurrentLayer.Surface))
{
//Make sure time isn't wasted if the CombineMode is Replace - Replace is much simpler than the other 4 selection modes.
if (combineMode == CombineMode.Replace)
{
//Clear any previously stored Polygons.
doc.Selection.SelectionPolygons.Clear();
//Set the resulting selection path to the new selection path.
doc.Selection.SelectionPolygons = newPolygons;
doc.Selection.SelectionPath = g.CreatePolygonPath(polygonSet);
}
else
{
List<List<IntPoint>> resultingPolygons = new List<List<IntPoint>>();
//Specify the Clipper Subject (the previous Polygons) and the Clipper Clip (the new Polygons).
//Note: for Union, ignore the Clipper Library instructions - the new polygon(s) should be Clips, not Subjects!
doc.Selection.SelectionClipper.AddPolygons(doc.Selection.SelectionPolygons, PolyType.ptSubject);
doc.Selection.SelectionClipper.AddPolygons(newPolygons, PolyType.ptClip);
switch (combineMode)
{
case CombineMode.Xor:
//Xor means "Combine both Polygon sets, but leave out any areas of intersection between the two."
doc.Selection.SelectionClipper.Execute(ClipType.ctXor, resultingPolygons);
break;
case CombineMode.Exclude:
//Exclude == Difference
//Exclude/Difference means "Subtract any overlapping areas of the new Polygon set from the old Polygon set."
doc.Selection.SelectionClipper.Execute(ClipType.ctDifference, resultingPolygons);
break;
case CombineMode.Intersect:
//Intersect means "Leave only the overlapping areas between the new and old Polygon sets."
doc.Selection.SelectionClipper.Execute(ClipType.ctIntersection, resultingPolygons);
break;
default:
//Default should only be *CombineMode.Union*, but just in case...
//Union means "Combine both Polygon sets, and keep any overlapping areas as well."
doc.Selection.SelectionClipper.Execute(ClipType.ctUnion, resultingPolygons);
break;
}
//After using Clipper, it has to be cleared so there are no conflicts with its next usage.
doc.Selection.SelectionClipper.Clear();
//Set the resulting selection path to the calculated ("clipped") selection path.
doc.Selection.SelectionPolygons = resultingPolygons;
doc.Selection.SelectionPath = g.CreatePolygonPath(DocumentSelection.ConvertToPolygonSet(resultingPolygons));
}
}
doc.History.PushNewItem(undoAction);
doc.Workspace.Invalidate();
}