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


C# Context.Paint方法代码示例

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


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

示例1: DrawBackground

		protected override void DrawBackground (Context context, Gdk.Rectangle region)
		{
			LayoutRoundedRectangle (context, region);
			context.Clip ();

			context.SetSourceColor (CairoExtensions.ParseColor ("D3E6FF"));
			context.Paint ();

			context.Save ();
			context.Translate (region.X + region.Width / 2.0, region.Y + region.Height);

			using (var rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) {
				var color = CairoExtensions.ParseColor ("E5F0FF");
				rg.AddColorStop (0, color);
				color.A = 0;
				rg.AddColorStop (1, color);

				context.Scale (region.Width / (double)region.Height, 1.0);
				context.SetSource (rg);
				context.Paint ();
			}

			context.Restore ();

			LayoutRoundedRectangle (context, region, -3, -3, 2);
			context.SetSourceRGBA (1, 1, 1, 0.4);
			context.LineWidth = 1;
			context.StrokePreserve ();

			context.Clip ();

			int boxSize = 11;
			int x = region.Left + (region.Width % boxSize) / 2;
			for (; x < region.Right; x += boxSize) {
				context.MoveTo (x + 0.5, region.Top);
				context.LineTo (x + 0.5, region.Bottom);
			}

			int y = region.Top + (region.Height % boxSize) / 2;
			y += boxSize / 2;
			for (; y < region.Bottom; y += boxSize) {
				context.MoveTo (region.Left, y + 0.5);
				context.LineTo (region.Right, y + 0.5);
			}

			context.SetSourceRGBA (1, 1, 1, 0.2);
			context.Stroke ();

			context.ResetClip ();
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:50,代码来源:StatusAreaBuildTheme.cs

示例2: Draw

    void Draw(Context cr, int width, int height)
    {
        double radius = 0.5 * Math.Min (width, height) - 10;
        int xc = width / 2;
        int yc = height / 2;

        Surface overlay = cr.Target.CreateSimilar (Content.ColorAlpha, width, height);
        Surface punch   = cr.Target.CreateSimilar (Content.Alpha, width, height);
        Surface circles = cr.Target.CreateSimilar (Content.ColorAlpha, width, height);

        FillChecks (cr, 0, 0, width, height);
        cr.Save ();

        // Draw a black circle on the overlay
        using (Context cr_overlay = new Context (overlay)) {
            cr_overlay.Color = new Color (0.0, 0.0, 0.0);
            OvalPath (cr_overlay, xc, yc, radius, radius);
            cr_overlay.Fill ();

            // Draw 3 circles to the punch surface, then cut
            // that out of the main circle in the overlay
            using (Context cr_tmp = new Context (punch))
                Draw3Circles (cr_tmp, xc, yc, radius, 1.0);

            cr_overlay.Operator = Operator.DestOut;
            cr_overlay.SetSourceSurface (punch, 0, 0);
            cr_overlay.Paint ();

            // Now draw the 3 circles in a subgroup again
            // at half intensity, and use OperatorAdd to join up
            // without seams.
            using (Context cr_circles = new Context (circles)) {
                cr_circles.Operator = Operator.Over;
                Draw3Circles (cr_circles, xc, yc, radius, 0.5);
            }

            cr_overlay.Operator = Operator.Add;
            cr_overlay.SetSourceSurface (circles, 0, 0);
            cr_overlay.Paint ();
        }

        cr.SetSourceSurface (overlay, 0, 0);
        cr.Paint ();

        overlay.Destroy ();
        punch.Destroy ();
        circles.Destroy ();
    }
开发者ID:nuxleus,项目名称:gtk-sharp,代码行数:48,代码来源:CairoSample.cs

示例3: Clear

 public static void Clear(this ImageSurface surface)
 {
     using (Context g = new Context (surface)) {
         g.Operator = Operator.Clear;
         g.Paint ();
     }
 }
开发者ID:bodicsek,项目名称:Pinta,代码行数:7,代码来源:CairoExtensions.cs

示例4: Create

        public static ImageSurface Create (Gdk.Pixbuf pixbuf, bool disposePixbuf)
        {
            if (pixbuf == null || pixbuf.Handle == IntPtr.Zero) {
                return null;
            }

            if (!PlatformDetection.IsWindows) {
                try {
                    return new PixbufImageSurface (pixbuf, disposePixbuf);
                } catch {
                    return null;
                }
            } else {
                // FIXME:
                // Windows has some trouble running the PixbufImageSurface, so as a
                // workaround a slower but working version of this factory method is
                // implemented. One day we can come back and optimize this by finding
                // out what's causing the PixbufImageSurface to result in access
                // violations when the object is disposed.
                ImageSurface target = new ImageSurface (Format.ARGB32, pixbuf.Width, pixbuf.Height);
                Context context = new Context (target);
                try {
                    Gdk.CairoHelper.SetSourcePixbuf (context, pixbuf, 0, 0);
                    context.Paint ();
                } finally {
                    ((IDisposable)context).Dispose ();
                    if (disposePixbuf) {
                        ((IDisposable)pixbuf).Dispose ();
                    }
                }

                return target;
            }
        }
开发者ID:Yetangitu,项目名称:f-spot,代码行数:34,代码来源:PixbufImageSurface.cs

示例5: ImageInfo

		public ImageInfo (ImageInfo info, Gdk.Rectangle allocation)
		{
			#if false
			Surface = new ImageSurface (Format.RGB24,
						    allocation.Width,
						    allocation.Height);
			Context ctx = new Context (Surface);
			#else
			Console.WriteLine ("source status = {0}", info.Surface.Status);
			Surface = info.Surface.CreateSimilar (Content.Color,
							      allocation.Width,
							      allocation.Height);
			
			System.Console.WriteLine ("status = {1} pointer = {0}", Surface.Handle.ToString (), Surface.Status);
			Context ctx = new Context (Surface);
			#endif
			Bounds = allocation;
			
			ctx.Matrix = info.Fill (allocation);
			Pattern p = new SurfacePattern (info.Surface);
			ctx.Source = p;
			ctx.Paint ();
			((IDisposable)ctx).Dispose ();
			p.Destroy ();
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:25,代码来源:ImageInfo.cs

示例6: Convert

		public bool Convert (FilterRequest req)
		{
			string source = req.Current.LocalPath;
			Uri dest = req.TempUri (Path.GetExtension (source));
			
			using (ImageFile img = ImageFile.Create (source)) {
				using (Pixbuf pixbuf = img.Load ()) {
					using (ImageInfo info = new ImageInfo (pixbuf)) {
						MemorySurface surface = new MemorySurface (Format.Argb32, 
											   pixbuf.Width,
											   pixbuf.Height);
	
						Context ctx = new Context (surface);
						ctx.Matrix = info.Fill (info.Bounds, angle);
						Pattern p = new SurfacePattern (info.Surface);
						ctx.Source = p;
						ctx.Paint ();
						((IDisposable)ctx).Dispose ();
						p.Destroy ();
						using (Pixbuf result = CairoUtils.CreatePixbuf (surface)) {
							using (Stream output = File.OpenWrite (dest.LocalPath)) {
								img.Save (result, output);
							}
						}
						surface.Flush ();
						info.Dispose ();
						req.Current = dest;
						return true;
					}
				}
			}
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:32,代码来源:TiltFilter.cs

示例7: Draw

        protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress)
        {
            cr.Color = new Color (0, 0, 0);
            if (next != null) {
                double scale = Math.Min ((double)width/(double)next.Width, (double)height/(double)next.Height);
                cr.Save ();

                cr.Translate (width * (1.0 - progress), 0);

                cr.Rectangle (0, 0, width, .5 * (height - scale*next.Height));
                cr.Fill ();

                cr.Rectangle (0, height - .5 * (height - scale*next.Height), width, .5 * (height - scale*next.Height));
                cr.Fill ();

                cr.Rectangle (0, 0, .5 * (width - scale*next.Width), height);
                cr.Fill ();

                cr.Rectangle (width - .5 * (width - scale*next.Width), 0, .5 * (width - scale*next.Width), height);
                cr.Fill ();

                cr.Rectangle (0, 0, width, height);
                cr.Scale (scale, scale);
                CairoHelper.SetSourcePixbuf (cr, next, .5 * ((double)width/scale - next.Width), .5 * ((double)height/scale - next.Height));
                cr.Paint ();
                cr.Restore ();
            }
        }
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:28,代码来源:Cover.cs

示例8: Form1_Shown

        private void Form1_Shown(object sender, EventArgs e)
        {
            Debug.WriteLine("Form1_Shown");

            Win32Surface = new Win32Surface(this.CreateGraphics().GetHdc());
            FontContext = new Context(Win32Surface);

            //CRITICAL: Format of Win32Surface and ImageSurface must be identical!

            ImageSurface = new ImageSurface(Format.Rgb24, ClientSize.Width, ClientSize.Height);
            BackContext = new Context(ImageSurface);

            //Clear Surface2
            BackContext.SetSourceColor(new Color(1,1,1));
            BackContext.Operator = Operator.Source;
            BackContext.Paint();
            BackContext.Operator = Operator.Over;

            var textFormat = DWriteCairo.CreateTextFormat(
                "Arial",
                FontWeight.Normal,
                FontStyle.Normal,
                FontStretch.Normal,
                32f);
            
            Debug.Assert(Math.Abs(textFormat.FontSize - 32f) < 0.0001);
            
            const string s = "Hello World";
            textLayout = DWriteCairo.CreateTextLayout(s, textFormat, 300, 40);

        }
开发者ID:zwcloud,项目名称:ZWCloud.DwriteCairo,代码行数:31,代码来源:Form1.cs

示例9: using

        /*public static Pango.Layout CreateCairoLayout (Gtk.Widget widget, Cairo.Context cairo_context)
        {
            var layout = PangoCairoHelper.CreateLayout (cairo_context);
            layout.FontDescription = widget.PangoContext.FontDescription;

            double resolution = widget.Screen.Resolution;
            if (resolution != -1) {
                using (var context = PangoCairoHelper.LayoutGetContext (layout)) {
                    PangoCairoHelper.ContextSetResolution (context, resolution);
                }
            }

            return layout;
        }*/
        public static Surface CreateSurfaceForPixbuf(this Cairo.Context cr, Gdk.Pixbuf pixbuf)
        {
            var surface = cr.Target.CreateSimilar (cr.Target.Content, pixbuf.Width, pixbuf.Height);
            using (var surface_cr = new Context (surface)) {
                Gdk.CairoHelper.SetSourcePixbuf (surface_cr, pixbuf, 0, 0);
                surface_cr.Paint ();
                return surface;
            }
        }
开发者ID:mono,项目名称:maigre,代码行数:23,代码来源:ContextExtensions.cs

示例10: CreateSurfaceForPixbuf

 public static Surface CreateSurfaceForPixbuf (Cairo.Context cr, Gdk.Pixbuf pixbuf)
 {
     Surface surface = cr.Target.CreateSimilar (cr.Target.Content, pixbuf.Width, pixbuf.Height);
     Cairo.Context surface_cr = new Context (surface);
     Gdk.CairoHelper.SetSourcePixbuf (surface_cr, pixbuf, 0, 0);
     surface_cr.Paint ();
     ((IDisposable)surface_cr).Dispose ();
     return surface;
 }
开发者ID:rubenv,项目名称:tripod,代码行数:9,代码来源:CairoExtensions.cs

示例11: PlacedSurface

        public PlacedSurface(ImageSurface source, Gdk.Rectangle roi)
        {
            where = roi.Location;
            what = new ImageSurface (Format.Argb32, roi.Width, roi.Height);

            using (Context g = new Context (what)) {
                g.SetSourceSurface (source, -roi.X, -roi.Y);
                g.Paint ();
            }
        }
开发者ID:RudoCris,项目名称:Pinta,代码行数:10,代码来源:PlacedSurface.cs

示例12: create_big_starred_image

        public static Gtk.Image create_big_starred_image(string pic_path)
        {
            using (Cairo.ImageSurface img_surface = new ImageSurface(pic_path)) {
                using (Cairo.ImageSurface surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, img_surface.Width + 2, img_surface.Height + 2)) {
                    using (Cairo.Context context = new Context(surface)) {
                        Gdk.Pixbuf tmp_pixbuf = new Gdk.Pixbuf(pic_path);
                        if (!tmp_pixbuf.HasAlpha) { // img_surface.Format not available...
                            context.Rectangle(0, 0, img_surface.Width+2, img_surface.Height+2);
                            context.Fill();
                            context.Stroke();
                        }

                        context.SetSource(img_surface, 1, 1);
                        context.Paint();

                        // evil hack because the interface to cairo is pretty bad

                        Assembly asm = Assembly.GetCallingAssembly();

                        Stream s = asm.GetManifestResourceStream("big_star.png");

                        FileStream fs = new System.IO.FileStream(tmp_image_path, FileMode.Create);

                        for (int i = 0; i < s.Length; ++i)
                            fs.WriteByte((byte)s.ReadByte());

                        fs.Close();

                        using (Cairo.ImageSurface star_surface = new ImageSurface(tmp_image_path)) {
                            System.IO.File.Delete(tmp_image_path);

                            context.SetSource(star_surface, img_surface.Width-star_surface.Width, img_surface.Height-star_surface.Height);
                            context.Paint();

                            surface.WriteToPng(tmp_image_path);
                            Gtk.Image img = new Gtk.Image(tmp_image_path);
                            System.IO.File.Delete(tmp_image_path);
                            return img;
                        }
                    }
                }
            }
        }
开发者ID:GNOME,项目名称:nemo,代码行数:43,代码来源:Cairo.cs

示例13: Surface

 public Surface(int width, int height, Image image, bool warnOnDispose = true)
 {
     this.warnOnDispose = warnOnDispose;
     surface = new ImageSurface (Format.ARGB32, width, height);
     if (image != null) {
         using (Context context = new Context (surface)) {
             Gdk.CairoHelper.SetSourcePixbuf (context, image.Value, 0, 0);
             context.Paint ();
         }
     }
 }
开发者ID:GNOME,项目名称:longomatch,代码行数:11,代码来源:Surface.cs

示例14: Clone

        public static ImageSurface Clone(this ImageSurface surf)
        {
            ImageSurface newsurf = new ImageSurface (surf.Format, surf.Width, surf.Height);

            using (Context g = new Context (newsurf)) {
                g.SetSource (surf);
                g.Paint ();
            }

            return newsurf;
        }
开发者ID:pzsysa,项目名称:gtk-sharp-forms,代码行数:11,代码来源:CairoExtensions.cs

示例15: CreateSurfaceForPixbuf

        public static Surface CreateSurfaceForPixbuf (Context cr, Pixbuf pixbuf)
        {
			Surface surface;
			using (var t = cr.GetTarget ()) {
				surface = t.CreateSimilar (t.Content, pixbuf.Width, pixbuf.Height);
			}
			using (Context surface_cr = new Context (surface)) {
				CairoHelper.SetSourcePixbuf (surface_cr, pixbuf, 0, 0);
				surface_cr.Paint ();
				surface_cr.Dispose ();
			}
            return surface;
        }
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:13,代码来源:CairoExtensions.cs


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