本文整理汇总了C#中Cairo.Context.CopyPath方法的典型用法代码示例。如果您正苦于以下问题:C# Context.CopyPath方法的具体用法?C# Context.CopyPath怎么用?C# Context.CopyPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.CopyPath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Clone
public static Path Clone(this Path path)
{
Path newpath;
using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
g.AppendPath (path);
newpath = g.CopyPath ();
}
return newpath;
}
示例2: Execute
public void Execute(Context ctx)
{
PointD point;
var first = true;
using (var mpath = ctx.CopyPath())
{
var path = mpath.GetPath();
for (var i = 0; i < path.num_data; )
{
var hdr = path.GetPathHeader(i); //hdr.Dump();
switch (hdr.type)
{
case NativePath.cairo_path_data_type_t.CAIRO_PATH_MOVE_TO:
if (first)
{
ctx.NewPath();
first = false;
}
point = path.GetPathPoint(i + 1);
ctx.MoveTo(WarpPoint(point));
break;
case NativePath.cairo_path_data_type_t.CAIRO_PATH_LINE_TO:
point = path.GetPathPoint(i + 1);
ctx.LineTo(WarpPoint(point));
break;
case NativePath.cairo_path_data_type_t.CAIRO_PATH_CURVE_TO:
var p1 = WarpPoint(path.GetPathPoint(i + 1));
var p2 = WarpPoint(path.GetPathPoint(i + 2));
var p3 = WarpPoint(path.GetPathPoint(i + 3));
ctx.CurveTo(p1, p2, p3);
break;
case NativePath.cairo_path_data_type_t.CAIRO_PATH_CLOSE_PATH:
ctx.ClosePath();
break;
}
i += hdr.length;
}
}
}
示例3: OnMouseMove
protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
{
if (!is_dragging)
return;
Document doc = PintaCore.Workspace.ActiveDocument;
PointD new_offset = point;
double dx = origin_offset.X - new_offset.X;
double dy = origin_offset.Y - new_offset.Y;
using (Cairo.Context g = new Cairo.Context (doc.CurrentLayer.Surface)) {
Path old = doc.SelectionPath;
g.FillRule = FillRule.EvenOdd;
g.AppendPath (doc.SelectionPath);
g.Translate (dx, dy);
doc.SelectionPath = g.CopyPath ();
(old as IDisposable).Dispose ();
}
origin_offset = new_offset;
doc.ShowSelection = true;
(o as Gtk.DrawingArea).GdkWindow.Invalidate ();
}
示例4: OnMouseUp
protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
{
Document doc = PintaCore.Workspace.ActiveDocument;
base.OnMouseUp (canvas, args, point);
ImageSurface surf = doc.SelectionLayer.Surface;
using (Context g = new Context (surf)) {
if (path != null) {
g.AppendPath (path);
(path as IDisposable).Dispose ();
path = null;
}
g.FillRule = FillRule.EvenOdd;
g.ClosePath ();
doc.Selection.DisposeSelectionPreserve();
doc.Selection.SelectionPath = g.CopyPath ();
}
doc.Selection.SelectionPolygons.Add(lassoPolygon.ToList());
lassoPolygon.Clear();
doc.Workspace.Invalidate ();
}
示例5: OnMouseMove
protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
{
Document doc = PintaCore.Workspace.ActiveDocument;
if (!is_drawing)
return;
double x = Utility.Clamp (point.X, 0, doc.ImageSize.Width - 1);
double y = Utility.Clamp (point.Y, 0, doc.ImageSize.Height - 1);
doc.ShowSelection = true;
ImageSurface surf = doc.SelectionLayer.Surface;
using (Context g = new Context (surf)) {
g.Antialias = Antialias.Subpixel;
if (path != null) {
g.AppendPath (path);
(path as IDisposable).Dispose ();
} else {
g.MoveTo (x, y);
}
g.LineTo (x, y);
lassoPolygon.Add(new IntPoint((long)x, (long)y));
path = g.CopyPath ();
g.FillRule = FillRule.EvenOdd;
g.ClosePath ();
doc.Selection.DisposeSelectionPreserve();
doc.Selection.SelectionPath = g.CopyPath ();
}
doc.Workspace.Invalidate ();
}
示例6: OnMouseMove
protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
{
if (!is_drawing)
return;
double x = Utility.Clamp (point.X, 0, PintaCore.Workspace.ImageSize.Width - 1);
double y = Utility.Clamp (point.Y, 0, PintaCore.Workspace.ImageSize.Height - 1);
PintaCore.Layers.ShowSelection = true;
ImageSurface surf = PintaCore.Layers.ToolLayer.Surface;
using (Context g = new Context (surf)) {
g.Antialias = Antialias.Subpixel;
if (path != null) {
g.AppendPath (path);
(path as IDisposable).Dispose ();
}
g.LineTo (x, y);
path = g.CopyPath ();
g.FillRule = FillRule.EvenOdd;
g.ClosePath ();
Path old = PintaCore.Layers.SelectionPath;
PintaCore.Layers.SelectionPath = g.CopyPath ();
(old as IDisposable).Dispose ();
}
PintaCore.Workspace.Invalidate ();
}
示例7: OnMouseUp
protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
{
base.OnMouseUp (canvas, args, point);
ImageSurface surf = PintaCore.Layers.CurrentLayer.Surface;
using (Context g = new Context (surf)) {
if (path != null) {
g.AppendPath (path);
(path as IDisposable).Dispose ();
path = null;
}
g.FillRule = FillRule.EvenOdd;
g.ClosePath ();
Path old = PintaCore.Layers.SelectionPath;
PintaCore.Layers.SelectionPath = g.CopyPath ();
(old as IDisposable).Dispose ();
}
PintaCore.Workspace.Invalidate ();
}
示例8: OnMouseMove
protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
{
if (!is_dragging)
return;
PointD new_offset = new PointD (point.X, point.Y);
double dx = origin_offset.X - new_offset.X;
double dy = origin_offset.Y - new_offset.Y;
Path path = PintaCore.Layers.SelectionPath;
using (Cairo.Context g = new Cairo.Context (PintaCore.Layers.CurrentLayer.Surface)) {
g.AppendPath (path);
g.Translate (dx, dy);
PintaCore.Layers.SelectionPath = g.CopyPath ();
}
(path as IDisposable).Dispose ();
PintaCore.Layers.SelectionLayer.Offset = new PointD (PintaCore.Layers.SelectionLayer.Offset.X - dx, PintaCore.Layers.SelectionLayer.Offset.Y - dy);
origin_offset = new_offset;
(o as Gtk.DrawingArea).GdkWindow.Invalidate ();
}
示例9: OnMouseMove
protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
{
if (!is_dragging)
return;
Document doc = PintaCore.Workspace.ActiveDocument;
PointD new_offset = new PointD (point.X, point.Y);
double dx = origin_offset.X - new_offset.X;
double dy = origin_offset.Y - new_offset.Y;
using (Cairo.Context g = new Cairo.Context (doc.CurrentLayer.Surface)) {
g.AppendPath(doc.Selection.SelectionPath);
g.Translate (dx, dy);
doc.Selection.DisposeSelectionPreserve();
doc.Selection.SelectionPath = g.CopyPath ();
}
List<List<IntPoint>> newSelectionPolygons = new List<List<IntPoint>>();
foreach (List<IntPoint> ipL in doc.Selection.SelectionPolygons)
{
List<IntPoint> newPolygon = new List<IntPoint>();
foreach (IntPoint ip in ipL)
{
newPolygon.Add(new IntPoint(ip.X - (long)dx, ip.Y - (long)dy));
}
newSelectionPolygons.Add(newPolygon);
}
doc.Selection.SelectionPolygons = newSelectionPolygons;
doc.SelectionLayer.Offset = new PointD (doc.SelectionLayer.Offset.X - dx, doc.SelectionLayer.Offset.Y - dy);
origin_offset = new_offset;
(o as Gtk.DrawingArea).GdkWindow.Invalidate ();
}
示例10: OnMouseMove
protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
{
Document doc = PintaCore.Workspace.ActiveDocument;
if ((args.Event.State & Gdk.ModifierType.Button1Mask) == Gdk.ModifierType.Button1Mask) {
outline_color = PintaCore.Palette.PrimaryColor;
fill_color = PintaCore.Palette.SecondaryColor;
} else if ((args.Event.State & Gdk.ModifierType.Button3Mask) == Gdk.ModifierType.Button3Mask) {
outline_color = PintaCore.Palette.SecondaryColor;
fill_color = PintaCore.Palette.PrimaryColor;
} else {
last_point = point_empty;
return;
}
int x = (int)point.X;
int y = (int)point.Y;
if (last_point.Equals (point_empty)) {
last_point = new Point (x, y);
return;
}
if (doc.Workspace.PointInCanvas (point))
surface_modified = true;
doc.ToolLayer.Clear ();
ImageSurface surf = doc.ToolLayer.Surface;
using (Context g = new Context (surf)) {
doc.Selection.Clip(g);
g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;
if (path != null) {
g.AppendPath (path);
(path as IDisposable).Dispose ();
} else {
g.MoveTo (x, y);
}
g.LineTo (x, y);
path = g.CopyPath ();
g.ClosePath ();
g.LineWidth = BrushWidth;
g.LineJoin = LineJoin.Round;
g.LineCap = LineCap.Round;
g.FillRule = FillRule.EvenOdd;
if (FillShape && StrokeShape) {
g.Color = fill_color;
g.FillPreserve ();
g.Color = outline_color;
g.Stroke ();
} else if (FillShape) {
g.Color = outline_color;
g.Fill ();
} else {
g.Color = outline_color;
g.Stroke ();
}
}
doc.Workspace.Invalidate ();
last_point = new Point (x, y);
}
示例11: RenderToCairoPath
internal Path RenderToCairoPath(Context context, DirectWriteCairoTextRenderer render, TextLayout textLayout)
{
//Debug.WriteLine("Before `Draw`: Current point at <{0},{1}>", (float)context.CurrentPoint.X, (float)context.CurrentPoint.Y);
Draw(context.Handle, render, (float)context.CurrentPoint.X, (float)context.CurrentPoint.Y);
var result = context.CopyPath();
context.NewPath();
return result;
}