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


C# Context.ClosePath方法代码示例

本文整理汇总了C#中Cairo.Context.ClosePath方法的典型用法代码示例。如果您正苦于以下问题:C# Context.ClosePath方法的具体用法?C# Context.ClosePath怎么用?C# Context.ClosePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cairo.Context的用法示例。


在下文中一共展示了Context.ClosePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Image_Loaded

 private void Image_Loaded(object sender, RoutedEventArgs e)
 {
     Image image = (Image)sender;
     using (ImageSurface surface = new ImageSurface(Format.Argb32, (int)image.Width, (int)image.Height))
     {
         using (Context context = new Context(surface))
         {
             PointD p = new PointD(10.0, 10.0);
             PointD p2 = new PointD(100.0, 10.0);
             PointD p3 = new PointD(100.0, 100.0);
             PointD p4 = new PointD(10.0, 100.0);
             context.MoveTo(p);
             context.LineTo(p2);
             context.LineTo(p3);
             context.LineTo(p4);
             context.LineTo(p);
             context.ClosePath();
             context.Fill();
             context.MoveTo(140.0, 110.0);
             context.SetFontSize(32.0);
             context.SetSourceColor(new Color(0.0, 0.0, 0.8, 1.0));
             context.ShowText("Hello Cairo!");
             surface.Flush();
             RgbaBitmapSource source = new RgbaBitmapSource(surface.Data, surface.Width);
             image.Source = source;
         }
     }
 }
开发者ID:zwcloud,项目名称:CairoSharp,代码行数:28,代码来源:MainWindow.xaml.cs

示例2: OvalPath

	void OvalPath (Context cr, double xc, double yc, double xr, double yr)
	{
		Matrix m = cr.Matrix;

		cr.Translate (xc, yc);
		cr.Scale (1.0, yr / xr);
		cr.MoveTo (xr, 0.0);
		cr.Arc (0, 0, xr, 0, 2 * Math.PI);
		cr.ClosePath ();

		cr.Matrix = m;
	}
开发者ID:ystk,项目名称:debian-gtk-sharp2,代码行数:12,代码来源:CairoSample.cs

示例3: 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

示例4: OnMouseMove

		protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
		                                              int x, int y, int lastX, int lastY)
		{
			int line_width = (int)g.LineWidth;
			int size;

			// we want a minimum size of 2 for the splatter (except for when the brush width is 1), since a splatter of size 1 is very small
			if (line_width == 1)
			{
				size = 1;
			}
			else
			{
				size = Random.Next (2, line_width);
			}

			Rectangle r = new Rectangle (x - Random.Next (-15, 15), y - Random.Next (-15, 15), size, size);

			double rx = r.Width / 2;
			double ry = r.Height / 2;
			double cx = r.X + rx;
			double cy = r.Y + ry;
			double c1 = 0.552285;

			g.Save ();

			g.MoveTo (cx + rx, cy);

			g.CurveTo (cx + rx, cy - c1 * ry, cx + c1 * rx, cy - ry, cx, cy - ry);
			g.CurveTo (cx - c1 * rx, cy - ry, cx - rx, cy - c1 * ry, cx - rx, cy);
			g.CurveTo (cx - rx, cy + c1 * ry, cx - c1 * rx, cy + ry, cx, cy + ry);
			g.CurveTo (cx + c1 * rx, cy + ry, cx + rx, cy + c1 * ry, cx + rx, cy);

			g.ClosePath ();

			Rectangle dirty = g.FixedStrokeExtents ();

			g.Fill ();
			g.Restore ();

			return dirty.ToGdkRectangle ();
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:42,代码来源:SplatterBrush.cs

示例5: 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

示例6: 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

示例7: CreateRoundedRectPath

 public void CreateRoundedRectPath(Context gc, double x, double y, double width, double height, double radius)
 {
     double x1, y1;
     x1 = x + width;
     y1 = y + height;
     if (width / 2 < radius) {
         if (height / 2 < radius) {
             gc.MoveTo (x, (y + y1) / 2);
             gc.CurveTo (x ,y, x, y, (x + x1) / 2, y);
             gc.CurveTo (x1, y, x1, y, x1, (y + y1) / 2);
             gc.CurveTo (x1, y1, x1, y1, (x1 + x) / 2, y1);
             gc.CurveTo (x, y1, x, y1, x, (y + y1) / 2);
         } else {
             gc.MoveTo (x, y + radius);
             gc.CurveTo (x, y, x, y, (x + x1) / 2, y);
             gc.CurveTo (x1, y, x1, y, x1, y + radius);
             gc.LineTo (x1 , y1 - radius);
             gc.CurveTo (x1, y1, x1, y1, (x1 + x) / 2, y1);
             gc.CurveTo (x, y1, x, y1, x, y1 - radius);
         }
     } else {
         if (height / 2 < radius) {
             gc.MoveTo (x, (y + y1) / 2);
             gc.CurveTo (x , y, x, y, x + radius, y);
             gc.LineTo (x1 - radius, y);
             gc.CurveTo (x1, y, x1, y, x1, (y + y1) / 2);
             gc.CurveTo (x1, y1, x1, y1, x1 - radius, y1);
             gc.LineTo (x + radius, y1);
             gc.CurveTo (x, y1, x, y1, x, (y + y1) / 2);
         } else {
             gc.MoveTo (x, y + radius);
             gc.CurveTo (x , y, x , y, x + radius, y);
             gc.LineTo (x1 - radius, y);
             gc.CurveTo (x1, y, x1, y, x1, y + radius);
             gc.LineTo (x1, y1 - radius);
             gc.CurveTo (x1, y1, x1, y1, x1 - radius, y1);
             gc.LineTo (x + radius, y1);
             gc.CurveTo (x, y1, x, y1, x, y1 - radius);
         }
     }
     gc.ClosePath ();
 }
开发者ID:codebutler,项目名称:meshwork,代码行数:42,代码来源:ZoomableCairoArea.cs

示例8: paintBackground

 private void paintBackground(Context ctx, int w, int h)
 {
     ctx.Color = BlueprintStyle.BluePrint;
     ctx.Rectangle(0.0d, 0.0d, w, h);
     ctx.Fill();
     ctx.Color = BlueprintStyle.SoftWhite;
     ctx.Rectangle(Offset, Offset, w-2*Offset, h-2*Offset);
     ctx.ClosePath();
     ctx.Rectangle(Offset2, Offset2, w-2*Offset2, h-2*Offset2);
     ctx.ClosePath();
     ctx.Fill();
     double W = w-2*Offset2;
     int n = (int)Math.Round((double)W/LineDelta);
     double dx = (double)W/n;
     ctx.LineWidth = 0.5d;
     for(int i = 1; i < n; i++) {
         ctx.MoveTo(dx*i+Offset2, Offset2);
         ctx.RelLineTo(0.0d, h-2*Offset2);
         ctx.Stroke();
     }
     double H = h-2*Offset2;
     n = (int)Math.Round((double)H/LineDelta);
     double dy = (double)H/n;
     for(int i = 1; i < n; i++) {
         ctx.MoveTo(Offset2, dy*i+Offset2);
         ctx.RelLineTo(w-2.0d*Offset2, 0.0d);
         ctx.Stroke();
     }
 }
开发者ID:KommuSoft,项目名称:ParVis,代码行数:29,代码来源:BlueprintParallelStatePainter.cs

示例9: Render

        public virtual void Render(Context cr, Gdk.Rectangle area, Color color, bool showEmptyStars, bool isHovering,
            int hoverValue, double fillOpacity, double hoverFillOpacity, double strokeOpacity)
        {
            if (Value == MinRating && !isHovering && !showEmptyStars) {
                return;
            }

            cr.Save ();

            Cairo.Color fill_color = color;
            fill_color.A = fillOpacity;
            Cairo.Color stroke_color = fill_color;
            stroke_color.A = strokeOpacity;
            Cairo.Color hover_fill_color = fill_color;
            hover_fill_color.A = hoverFillOpacity;

            double x, y;
            ComputePosition (area, out x, out y);

            cr.LineWidth = 1.0;
            cr.Translate (0.5, 0.5);

            for (int i = MinRating + 1, s = isHovering || showEmptyStars ? MaxRating : Value; i <= s; i++, x += Size) {
                bool fill = i <= Value && Value > MinRating;
                bool hover_fill = i <= hoverValue && hoverValue > MinRating;
                double scale = fill || hover_fill ? Size : Size - 2;
                double ofs = fill || hover_fill ? 0 : 1;

                for (int p = 0, n = star_plot.GetLength (0); p < n; p++) {
                    double px = x + ofs + star_plot[p, 0] * scale;
                    double py = y + ofs + star_plot[p, 1] * scale;
                    if (p == 0) {
                        cr.MoveTo (px, py);
                    } else {
                        cr.LineTo (px, py);
                    }
                }
                cr.ClosePath ();

                if (fill || hover_fill) {
                    if (!isHovering || hoverValue >= Value) {
                        cr.SetSourceColor (fill ? fill_color : hover_fill_color);
                    } else {
                        cr.SetSourceColor (hover_fill ? fill_color : hover_fill_color);
                    }
                    cr.Fill ();
                } else {
                    cr.SetSourceColor (stroke_color);
                    cr.Stroke ();
                }
            }
            cr.Restore ();
        }
开发者ID:GNOME,项目名称:hyena,代码行数:53,代码来源:RatingRenderer.cs

示例10: 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

示例11: DrawShape

        void DrawShape(Context g, int width, int height)
        {
            int inner_x = radius + border + inner;
            int cx = Center.X;
            int cy = Center.Y;

            g.Operator = Operator.Source;
            g.SetSource (new SolidPattern (new Cairo.Color (0,0,0,0)));
            g.Rectangle (0, 0, width, height);
            g.Paint ();

            g.NewPath ();
            g.Translate (cx, cy);
            g.Rotate (angle);

            g.SetSource (new SolidPattern (new Cairo.Color (0.2, 0.2, 0.2, .6)));
            g.Operator = Operator.Over;
            g.Rectangle (0, - (border + inner), inner_x, 2 * (border + inner));
            g.Arc (inner_x, 0, inner + border, 0, 2 * Math.PI);
            g.Arc (0, 0, radius + border, 0, 2 * Math.PI);
            g.Fill ();

            g.SetSource (new SolidPattern (new Cairo.Color (0, 0, 0, 1.0)));
            g.Operator = Operator.DestOut;
            g.Arc (inner_x, 0, inner, 0, 2 * Math.PI);
            #if true
            g.Fill ();
            #else
            g.FillPreserve ();

            g.Operator = Operator.Over;
            RadialGradient rg = new RadialGradient (inner_x - (inner * 0.3), inner * 0.3 , inner * 0.1, inner_x, 0, inner);
            rg.AddColorStop (0, new Cairo.Color (0.0, 0.2, .8, 0.5));
            rg.AddColorStop (0.7, new Cairo.Color (0.0, 0.2, .8, 0.1));
            rg.AddColorStop (1.0, new Cairo.Color (0.0, 0.0, 0.0, 0.0));
            g.Source = rg;
            g.Fill ();
            rg.Destroy ();
            #endif
            g.Operator = Operator.Over;
            g.Matrix = new Matrix ();
            g.Translate (cx, cy);
            if (source != null)
            CairoHelper.SetSourcePixbuf (g, source, -source.Width / 2, -source.Height / 2);

            g.Arc (0, 0, radius, 0, 2 * Math.PI);
            g.Fill ();

            if (overlay != null) {
                CairoHelper.SetSourcePixbuf (g, overlay, -overlay.Width / 2, -overlay.Height / 2);
                g.Arc (0, 0, radius, angle, angle + Math.PI);
                g.ClosePath ();
                g.FillPreserve ();
                g.SetSource (new SolidPattern (new Cairo.Color (1.0, 1.0, 1.0, 1.0)));
                g.Stroke ();
            }
        }
开发者ID:Yetangitu,项目名称:f-spot,代码行数:57,代码来源:Loupe.cs

示例12: curve_rectangle

		public void curve_rectangle(Context cr, int width, int height)
		{
			// a custom shape, that could be wrapped in a function
			double x0	   = 0.1,   //< parameters like cairo_rectangle
			       y0	   = 0.1,
			       rect_width  = 0.8,
		    	   rect_height = 0.8,
				   radius = 0.4;   //< and an approximate curvature radius

			double x1,y1;

			Normalize(cr, width, height);

			x1=x0+rect_width;
			y1=y0+rect_height;

			if (rect_width/2<radius) {
				if (rect_height/2<radius) {
					cr.MoveTo(x0, (y0 + y1)/2);
					cr.CurveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, (y0 + y1)/2);
					cr.CurveTo(x1, y1, x1, y1, (x1 + x0)/2, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, (y0 + y1)/2);
				} else {
					cr.MoveTo(x0, y0 + radius);
					cr.CurveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, y0 + radius);
					cr.LineTo(x1 , y1 - radius);
					cr.CurveTo(x1, y1, x1, y1, (x1 + x0)/2, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, y1- radius);
				}
			} else {
				if (rect_height/2<radius) {
					cr.MoveTo(x0, (y0 + y1)/2);
					cr.CurveTo(x0 , y0, x0 , y0, x0 + radius, y0);
					cr.LineTo(x1 - radius, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, (y0 + y1)/2);
					cr.CurveTo(x1, y1, x1, y1, x1 - radius, y1);
					cr.LineTo(x0 + radius, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, (y0 + y1)/2);
				} else {
					cr.MoveTo(x0, y0 + radius);
					cr.CurveTo(x0 , y0, x0 , y0, x0 + radius, y0);
					cr.LineTo(x1 - radius, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, y0 + radius);
					cr.LineTo(x1 , y1 - radius);
					cr.CurveTo(x1, y1, x1, y1, x1 - radius, y1);
					cr.LineTo(x0 + radius, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, y1- radius);
				}
			}
			cr.ClosePath();

			// and fill/stroke it
			cr.Color = new Color (0.5, 0.5, 1);
			cr.FillPreserve();
			cr.Color = new Color (0.5, 0, 0, 0.5);
			cr.Stroke();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:59,代码来源:Snippets.cs

示例13: OnMouseUp

        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            doc.ToolLayer.Hidden = true;

            if (surface_modified)
                PintaCore.History.PushNewItem (new SimpleHistoryItem (Icon, Name, undo_surface, doc.CurrentUserLayerIndex));
            else if (undo_surface != null)
                (undo_surface as IDisposable).Dispose ();

            surface_modified = false;
            ImageSurface surf = doc.CurrentUserLayer.Surface;

            using (Context g = new Context (surf)) {
                g.AppendPath (doc.Selection.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

                if (path != null) {
                    g.AppendPath (path);
                    (path as IDisposable).Dispose ();
                    path = null;
                }

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

示例14: 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

示例15: SetClip

        private static void SetClip(Context ctx, Region region)
        {
            foreach (Gdk.Rectangle area in region.GetRectangles ()) {
                ctx.MoveTo (area.Left, area.Top);
                ctx.LineTo (area.Right, area.Top);
                ctx.LineTo (area.Right, area.Bottom);
                ctx.LineTo (area.Left, area.Bottom);

                ctx.ClosePath ();
            }
            ctx.Clip ();
        }
开发者ID:iainlane,项目名称:f-spot,代码行数:12,代码来源:ImageDisplay.cs


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