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


C# Cairo.PaintWithAlpha方法代码示例

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


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

示例1: OnRender

		protected override void OnRender (Cairo.Context context)
		{
			if (surfaceCache == null) {
				// will improve with CGLayer surfaces
				surfaceCache = new SurfaceWrapper (context, pbuf);
			}
			int x = (int)((Width - pbuf.Width) * XAlign);
			int y = (int)((Height - pbuf.Height) * YAlign);
			context.SetSourceSurface (surfaceCache.Surface, x, y);
			double opacity = Opacity;
			if (opacity == 1)
				context.Paint ();
			else
				context.PaintWithAlpha (Opacity);

			base.OnRender (context);
		}
开发者ID:jassmith,项目名称:Xamarin.Canvas,代码行数:17,代码来源:ImageCanvasElement.cs

示例2: RenderLivePreviewLayer

		// Used by the workspace drawing area expose render loop.
		// Takes care of the clipping.
		public void RenderLivePreviewLayer (Cairo.Context ctx, double opacity)
		{
			if (!IsEnabled)
				throw new InvalidOperationException ("Tried to render a live preview after live preview has ended.");
						
			// TODO remove seam around selection during live preview.
			
			ctx.Save ();
			if (selection_path != null) {
				
				// Paint area outsize of the selection path, with the pre-effect image.
				var imageSize = PintaCore.Workspace.ImageSize;
				ctx.Rectangle (0, 0, imageSize.Width, imageSize.Height);
				ctx.AppendPath (selection_path);
				ctx.Clip ();
				layer.Draw(ctx, layer.Surface, opacity);
				ctx.ResetClip ();
				
				// Paint area inside the selection path, with the post-effect image.
				ctx.AppendPath (selection_path);
				ctx.Clip ();
				
				layer.Draw(ctx, live_preview_surface, opacity);
				ctx.PaintWithAlpha (opacity);
				
				ctx.AppendPath (selection_path);
				ctx.FillRule = Cairo.FillRule.EvenOdd;
				ctx.Clip ();			
			} else {
				
				layer.Draw(ctx, live_preview_surface, opacity);
			}
			ctx.Restore ();
		}
开发者ID:ericksson,项目名称:Pinta,代码行数:36,代码来源:LivePreviewManager.cs

示例3: RenderAnimation

        private void RenderAnimation(Cairo.Context cr)
        {
            if (stage.Actor == null) {
                // We are not in a transition, just render
                RenderStage (cr, current_track, current_image);
                return;
            }

            if (current_track == null) {
                // Fade in the whole stage, nothing to fade out
                CairoExtensions.PushGroup (cr);
                RenderStage (cr, incoming_track, incoming_image);
                CairoExtensions.PopGroupToSource (cr);

                cr.PaintWithAlpha (stage.Actor.Percent);
                return;
            }

            // Draw the old cover art more and more translucent
            CairoExtensions.PushGroup (cr);
            RenderCoverArt (cr, current_image);
            CairoExtensions.PopGroupToSource (cr);
            cr.PaintWithAlpha (1.0 - stage.Actor.Percent);

            // Draw the new cover art more and more opaque
            CairoExtensions.PushGroup (cr);
            RenderCoverArt (cr, incoming_image);
            CairoExtensions.PopGroupToSource (cr);
            cr.PaintWithAlpha (stage.Actor.Percent);

            bool same_artist_album = incoming_track != null ? incoming_track.ArtistAlbumEqual (current_track) : false;
            bool same_track = incoming_track != null ? incoming_track.Equals (current_track) : false;

            if (same_artist_album) {
                RenderTrackInfo (cr, incoming_track, same_track, true);
            }

            // Don't xfade the text since it'll look bad (overlapping words); instead, fade
            // the old out, and then the new in
            if (stage.Actor.Percent <= 0.5) {
                // Fade out old text
                CairoExtensions.PushGroup (cr);
                RenderTrackInfo (cr, current_track, !same_track, !same_artist_album);
                CairoExtensions.PopGroupToSource (cr);

                cr.PaintWithAlpha (1.0 - (stage.Actor.Percent * 2.0));
            } else {
                // Fade in new text
                CairoExtensions.PushGroup (cr);
                RenderTrackInfo (cr, incoming_track, !same_track, !same_artist_album);
                CairoExtensions.PopGroupToSource (cr);

                cr.PaintWithAlpha ((stage.Actor.Percent - 0.5) * 2.0);
            }
        }
开发者ID:dufoli,项目名称:banshee,代码行数:55,代码来源:TrackInfoDisplay.cs

示例4: DrawPixbuf

		void DrawPixbuf (Cairo.Context ctx, Gdk.Pixbuf img, double x, double y, ImageDescription idesc)
		{
			ctx.Save ();
			ctx.Translate (x, y);
			ctx.Scale (idesc.Size.Width / (double)img.Width, idesc.Size.Height / (double)img.Height);
			Gdk.CairoHelper.SetSourcePixbuf (ctx, img, 0, 0);

			#pragma warning disable 618
			using (var pattern = ctx.Source as Cairo.SurfacePattern) {
				if (pattern != null) {
					if (idesc.Size.Width > img.Width || idesc.Size.Height > img.Height) {
						// Fixes blur issue when rendering on an image surface
						pattern.Filter = Cairo.Filter.Fast;
					} else
						pattern.Filter = Cairo.Filter.Good;
				}
			}
			#pragma warning restore 618

			if (idesc.Alpha >= 1)
				ctx.Paint ();
			else
				ctx.PaintWithAlpha (idesc.Alpha);
			ctx.Restore ();
		}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:25,代码来源:ImageHandler.cs

示例5: DrawPixbuf

 void DrawPixbuf(Cairo.Context ctx, Gdk.Pixbuf img, double x, double y, ImageDescription idesc)
 {
     ctx.Save ();
     ctx.Translate (x, y);
     ctx.Scale (idesc.Size.Width / (double)img.Width, idesc.Size.Height / (double)img.Height);
     Gdk.CairoHelper.SetSourcePixbuf (ctx, img, 0, 0);
     if (idesc.Alpha == 1)
         ctx.Paint ();
     else
         ctx.PaintWithAlpha (idesc.Alpha);
     ctx.Restore ();
 }
开发者ID:neiz,项目名称:xwt,代码行数:12,代码来源:ImageHandler.cs

示例6: RenderIcon

		void RenderIcon (Cairo.Context context, SurfaceWrapper surface, double opacity)
		{
			context.SetSourceSurface (surface.Surface, 
			                          Allocation.X + (Allocation.Width - surface.Width) / 2,
			                          Allocation.Y + (Allocation.Height - surface.Height) / 2);

			context.PaintWithAlpha (opacity);
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:8,代码来源:DockBarItem.cs

示例7: RenderPreview

		void RenderPreview (Cairo.Context context, Gdk.Point position, double opacity)
		{
			if (brandedIcon != null) {
				if (previewSurface == null) {
					previewSurface = new SurfaceWrapper (context, brandedIcon);
				}
				double scale = PreviewSize / previewSurface.Width;

				context.Save ();
				context.Translate (position.X, position.Y);
				context.Scale (scale * IconScale, scale * IconScale);
				context.SetSourceSurface (previewSurface.Surface, -previewSurface.Width / 2, -previewSurface.Height / 2);
				context.PaintWithAlpha (opacity);
				context.Restore ();
			}
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:16,代码来源:WelcomePageFirstRun.cs

示例8: DrawVertForecast

		/// <summary>
		/// Paints an overview of the forecast including high/low temps and a condition icon.
		/// </summary>
		/// <param name="cr">
		/// A <see cref="Cairo.Context"/> to do the painting.
		/// </param>
		void DrawVertForecast (Cairo.Context cr)
		{
			int cellHeight = (int) ((Allocation.Height - BUTTON_SIZE) / WeatherController.Weather.ForecastDays / 1.5);
			double xOffset = 0;
			double yOffset = cellHeight / 4.0;
			
			using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) {
				Pango.Rectangle inkRect, logicalRect;
				
				layout.FontDescription = new Gtk.Style().FontDescription;
				layout.FontDescription.Weight = Pango.Weight.Bold;
				layout.Ellipsize = Pango.EllipsizeMode.None;
				layout.Width = Pango.Units.FromPixels (cellHeight);
				
				for (int day = 0; day < WeatherController.Weather.ForecastDays; day++) {
					layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (cellHeight / 5));
					
					cr.Color = colorTitle;
					layout.SetText (string.Format ("{0}", WeatherForecast.DayShortName (WeatherController.Weather.Forecasts [day].dow)));
					layout.GetPixelExtents (out inkRect, out logicalRect);
					cr.MoveTo (xOffset + (cellHeight - inkRect.Width) / 2, yOffset);
					Pango.CairoHelper.LayoutPath (cr, layout);
					cr.Fill ();
					
					cr.Color = colorHigh;
					layout.SetText (string.Format ("{0}{1}", WeatherController.Weather.Forecasts [day].high, AbstractWeatherSource.TempUnit));
					layout.GetPixelExtents (out inkRect, out logicalRect);
					cr.MoveTo (xOffset + (cellHeight - inkRect.Width) / 2, yOffset + (cellHeight - logicalRect.Height) / 2);
					Pango.CairoHelper.LayoutPath (cr, layout);
					cr.Fill ();
					
					cr.Color = colorLow;
					layout.SetText (string.Format ("{0}{1}", WeatherController.Weather.Forecasts [day].low, AbstractWeatherSource.TempUnit));
					layout.GetPixelExtents (out inkRect, out logicalRect);
					cr.MoveTo (xOffset + (cellHeight - inkRect.Width) / 2, yOffset + cellHeight - logicalRect.Height);
					Pango.CairoHelper.LayoutPath (cr, layout);
					cr.Fill ();
					
					using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (WeatherController.Weather.Forecasts [day].image, cellHeight - 5)) {
						Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, xOffset + 5 + cellHeight, yOffset + 2);
						cr.PaintWithAlpha (WeatherController.Weather.Forecasts [day].chanceOf ? .6 : 1);
					}
					
					if (WeatherController.Weather.Forecasts [day].chanceOf) {
						layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (cellHeight / 2));
						
						layout.SetText ("?");
						
						layout.GetPixelExtents (out inkRect, out logicalRect);
						cr.MoveTo (xOffset + cellHeight + (cellHeight - inkRect.Width) / 2, yOffset + (cellHeight - logicalRect.Height) / 2);
						
						cr.LineWidth = 4;
						cr.Color = new Cairo.Color (0, 0, 0, 0.3);
						Pango.CairoHelper.LayoutPath (cr, layout);
						cr.StrokePreserve ();
						
						cr.Color = new Cairo.Color (1, 1, 1, .6);
						cr.Fill ();
					}
					
					yOffset += (int) (1.5 * cellHeight);
				}
				
				layout.FontDescription.Dispose ();
				layout.Context.Dispose ();
			}
		}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:73,代码来源:WeatherPainter.cs

示例9: DrawPixbuf

        void DrawPixbuf(Cairo.Context ctx, Gdk.Pixbuf img, double x, double y, ImageDescription idesc)
        {
            ctx.Save ();
            ctx.Translate (x, y);
            ctx.Scale (idesc.Size.Width / (double)img.Width, idesc.Size.Height / (double)img.Height);
            Gdk.CairoHelper.SetSourcePixbuf (ctx, img, 0, 0);

            // Fixes blur issue when rendering on an image surface
            ((Cairo.SurfacePattern)ctx.GetSource ()).Filter = Cairo.Filter.Fast;

            if (idesc.Alpha >= 1)
                ctx.Paint ();
            else
                ctx.PaintWithAlpha (idesc.Alpha);
            ctx.Restore ();
        }
开发者ID:jijamw,项目名称:xwt,代码行数:16,代码来源:ImageHandler.cs


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