当前位置: 首页>>代码示例>>C#>>正文


C# Context.CopyPath方法代码示例

本文整理汇总了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;
        }
开发者ID:asbjornu,项目名称:Pinta,代码行数:11,代码来源:CairoExtensions.cs

示例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;
				}
			}
		}
开发者ID:pruiz,项目名称:Mono.CairoWarp,代码行数:43,代码来源:Warp.cs

示例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 ();
        }
开发者ID:RodH257,项目名称:Pinta,代码行数:26,代码来源:MoveSelectionTool.cs

示例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 ();
        }
开发者ID:Kharevich,项目名称:Pinta,代码行数:28,代码来源:LassoSelectTool.cs

示例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 ();
        }
开发者ID:Kharevich,项目名称:Pinta,代码行数:39,代码来源:LassoSelectTool.cs

示例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 ();
        }
开发者ID:joehillen,项目名称:Pinta,代码行数:35,代码来源:LassoSelectTool.cs

示例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 ();
        }
开发者ID:joehillen,项目名称:Pinta,代码行数:24,代码来源:LassoSelectTool.cs

示例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 ();
        }
开发者ID:deckarep,项目名称:Pinta,代码行数:26,代码来源:MoveSelectedTool.cs

示例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 ();
        }
开发者ID:cameronwhite,项目名称:Pinta,代码行数:41,代码来源:MoveSelectedTool.cs

示例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);
        }
开发者ID:bodicsek,项目名称:Pinta,代码行数:69,代码来源:FreeformShapeTool.cs

示例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;
 }
开发者ID:zwcloud,项目名称:ZWCloud.DwriteCairo,代码行数:8,代码来源:TextLayout.cs


注:本文中的Cairo.Context.CopyPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。