CopyPath() 공개 메소드

public CopyPath ( ) : Path
리턴 Path
예제 #1
0
        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;

            Path path = doc.SelectionPath;

            using (Cairo.Context g = new Cairo.Context(doc.CurrentLayer.Surface)) {
                g.AppendPath(path);
                g.Translate(dx, dy);
                doc.SelectionPath = g.CopyPath();
            }

            (path as IDisposable).Dispose();

            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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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;
        }
        private void Render(Clutter.CairoTexture texture, int with_state, bool outwards)
        {
            texture.Clear();
            Cairo.Context context = texture.Create();

            double lwidth  = 1;
            double hlwidth = lwidth * 0.5;

            //Draw outline rectangles:
            context.Rectangle(hlwidth, hlwidth, texture.Width - lwidth, texture.Height - lwidth);
            context.SetSourceRGB(1.0, 1.0, 1.0);
            context.LineWidth = lwidth;
            context.StrokePreserve();
            double sat = (with_state == 0 ? 0.4 : (with_state == 1 ? 0.6 : 0.8));

            context.SetSourceRGB(sat, sat, sat);
            context.Fill();

            double dim = 4;

            context.MoveTo(-dim, 0);
            context.LineTo(outwards ? 0 : -dim, outwards ? 0 : dim);
            context.LineTo(0, dim);
            context.MoveTo(-dim, dim);
            context.LineTo(0, 0);
            context.ClosePath();
            Cairo.Path arrow = context.CopyPath();
            context.NewPath();

            double margin = 2 + hlwidth;
            PointD center = new PointD(texture.Width * 0.5, texture.Height * 0.5);
            PointD transl = new PointD(center.X - margin, -(center.Y - margin));

            context.LineWidth = lwidth;
            sat = (with_state == 1 ? 0.0 : 1.0);
            context.SetSourceRGB(sat, sat, sat);

            context.Translate(center.X, center.Y);
            for (int i = 0; i < 4; i++)
            {
                context.Rotate(Math.PI * 0.5 * i);
                context.Translate(transl.X, transl.Y);
                context.AppendPath(arrow);
                context.Stroke();
                context.Translate(-transl.X, -transl.Y);
            }

            ((IDisposable)arrow).Dispose();
            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
        }
예제 #5
0
        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();
        }
예제 #6
0
		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;
				}
			}
		}
예제 #7
0
        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 ();
        }
예제 #8
0
        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 ();
        }
예제 #9
0
        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 ();
        }
예제 #10
0
        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 ();
        }
예제 #11
0
        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 ();
        }
예제 #12
0
        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 ();
        }
예제 #13
0
        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 ();
        }
예제 #14
0
        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);
        }
예제 #15
0
 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;
 }