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


C# Rect.ToCairo方法代码示例

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


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

示例1: DrawImage

        public void DrawImage(IBitmap bitmap, double opacity, Rect sourceRect, Rect destRect)
        {
            var impl = bitmap.PlatformImpl as BitmapImpl;
            var size = new Size(impl.PixelWidth, impl.PixelHeight);
            var scaleX = destRect.Size.Width / sourceRect.Size.Width;
            var scaleY = destRect.Size.Height / sourceRect.Size.Height;

            _context.Save();
            _context.Scale(scaleX, scaleY);
            Gdk.CairoHelper.SetSourcePixbuf(_context, impl.Surface, (int)sourceRect.X, (int)sourceRect.Y);
            _context.Rectangle(sourceRect.ToCairo());
            _context.Fill();
            _context.Restore();
        }
开发者ID:healtech,项目名称:Perspex,代码行数:14,代码来源:DrawingContext.cs

示例2: DrawImage

        /// <summary>
        /// Draws a bitmap image.
        /// </summary>
        /// <param name="source">The bitmap image.</param>
        /// <param name="opacity">The opacity to draw with.</param>
        /// <param name="sourceRect">The rect in the image to draw.</param>
        /// <param name="destRect">The rect in the output to draw to.</param>
        public void DrawImage(IBitmap bitmap, double opacity, Rect sourceRect, Rect destRect)
        {
            var impl = bitmap.PlatformImpl as BitmapImpl;
            var size = new Size(impl.PixelWidth, impl.PixelHeight);
            var scale = new Vector(destRect.Width / sourceRect.Width, destRect.Height / sourceRect.Height);

            _context.Save();
            _context.Scale(scale.X, scale.Y);
            destRect /= scale;

			if (opacityOverride < 1.0f) {
				_context.PushGroup ();
				Gdk.CairoHelper.SetSourcePixbuf (
					_context, 
					impl.Surface, 
					-sourceRect.X + destRect.X, 
					-sourceRect.Y + destRect.Y);

				_context.Rectangle (destRect.ToCairo ());
				_context.Fill ();
				_context.PopGroupToSource ();
				_context.PaintWithAlpha (opacityOverride);
			} else {
				_context.PushGroup ();
				Gdk.CairoHelper.SetSourcePixbuf (
					_context, 
					impl.Surface, 
					-sourceRect.X + destRect.X, 
					-sourceRect.Y + destRect.Y);

				_context.Rectangle (destRect.ToCairo ());
				_context.Fill ();
				_context.PopGroupToSource ();
				_context.PaintWithAlpha (opacityOverride);			
			}
            _context.Restore();
        }
开发者ID:tshcherban,项目名称:Perspex,代码行数:44,代码来源:DrawingContext.cs

示例3: DrawImage

        /// <summary>
        /// Draws a bitmap image.
        /// </summary>
        /// <param name="source">The bitmap image.</param>
        /// <param name="opacity">The opacity to draw with.</param>
        /// <param name="sourceRect">The rect in the image to draw.</param>
        /// <param name="destRect">The rect in the output to draw to.</param>
        public void DrawImage(IBitmap bitmap, double opacity, Rect sourceRect, Rect destRect)
        {
			var impl = bitmap.PlatformImpl as BitmapImpl;
			var size = new Size(impl.PixelWidth, impl.PixelHeight);
			var scale = new Vector(destRect.Width / sourceRect.Width, destRect.Height / sourceRect.Height);

			_context.Save();

			Gdk.CairoHelper.SetSourcePixbuf (
				_context, 
				impl, 
				-sourceRect.X + destRect.X, 
				-sourceRect.Y + destRect.Y);
			impl.Scale (impl, (int)destRect.X, (int)destRect.Y, (int)destRect.Width, (int)destRect.Height, 0, 0, scale.X, scale.Y, Gdk.InterpType.Bilinear);

			_context.PushGroup ();
			_context.Rectangle (destRect.ToCairo ());
			_context.Fill ();
			_context.PopGroupToSource ();
			_context.PaintWithAlpha (opacityOverride);		
			_context.Restore();
        }
开发者ID:akrisiun,项目名称:Avalonia,代码行数:29,代码来源:DrawingContext.cs

示例4: PushClip

 /// <summary>
 /// Pushes a clip rectange.
 /// </summary>
 /// <param name="clip">The clip rectangle.</param>
 /// <returns>A disposable used to undo the clip rectangle.</returns>
 public void PushClip(Rect clip)
 {
     _context.Save();
     _context.Rectangle(clip.ToCairo());
     _context.Clip();
 }
开发者ID:akrisiun,项目名称:Avalonia,代码行数:11,代码来源:DrawingContext.cs

示例5: FillRectangle

 /// <summary>
 /// Draws a filled rectangle.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="rect">The rectangle bounds.</param>
 public void FillRectangle(IBrush brush, Rect rect, float cornerRadius)
 {
     using (var b = SetBrush(brush, rect.Size)) 
     {
         _context.Rectangle(rect.ToCairo ());
         _context.Fill();
     }
 }
开发者ID:akrisiun,项目名称:Avalonia,代码行数:13,代码来源:DrawingContext.cs

示例6: DrawRectangle

 /// <summary>
 /// Draws the outline of a rectangle.
 /// </summary>
 /// <param name="pen">The pen.</param>
 /// <param name="rect">The rectangle bounds.</param>
 public void DrawRectangle(Pen pen, Rect rect, float cornerRadius)
 {
     using (var p = SetPen(pen, rect.Size)) 
     {
         _context.Rectangle(rect.ToCairo ());
         _context.Stroke();
     }
 }
开发者ID:akrisiun,项目名称:Avalonia,代码行数:13,代码来源:DrawingContext.cs

示例7: PushClip

        /// <summary>
        /// Pushes a clip rectange.
        /// </summary>
        /// <param name="clip">The clip rectangle.</param>
        /// <returns>A disposable used to undo the clip rectangle.</returns>
        public IDisposable PushClip(Rect clip)
        {
            _context.Rectangle(clip.ToCairo());
            _context.Clip();

            return Disposable.Create(() => _context.ResetClip());
        }
开发者ID:tshcherban,项目名称:Perspex,代码行数:12,代码来源:DrawingContext.cs

示例8: FillRectange

 /// <summary>
 /// Draws a filled rectangle.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="rect">The rectangle bounds.</param>
 public void FillRectange(Brush brush, Rect rect, float cornerRadius)
 {
     SetBrush(brush, rect.Size);
     _context.Rectangle(rect.ToCairo());
     _context.Fill();
 }
开发者ID:healtech,项目名称:Perspex,代码行数:11,代码来源:DrawingContext.cs

示例9: FillRectange

 /// <summary>
 /// Draws a filled rectangle.
 /// </summary>
 /// <param name="brush">The brush.</param>
 /// <param name="rect">The rectangle bounds.</param>
 public void FillRectange(Perspex.Media.Brush brush, Rect rect, float cornerRadius)
 {
     this.SetBrush(brush);
     this.context.Rectangle(rect.ToCairo());
     this.context.Fill();
 }
开发者ID:Scellow,项目名称:Perspex,代码行数:11,代码来源:DrawingContext.cs

示例10: DrawRectange

 /// <summary>
 /// Draws the outline of a rectangle.
 /// </summary>
 /// <param name="pen">The pen.</param>
 /// <param name="rect">The rectangle bounds.</param>
 public void DrawRectange(Pen pen, Rect rect, float cornerRadius)
 {
     this.SetPen(pen);
     this.context.Rectangle(rect.ToCairo());
     this.context.Stroke();
 }
开发者ID:Scellow,项目名称:Perspex,代码行数:11,代码来源:DrawingContext.cs

示例11: DrawRectange

 /// <summary>
 /// Draws the outline of a rectangle.
 /// </summary>
 /// <param name="pen">The pen.</param>
 /// <param name="rect">The rectangle bounds.</param>
 public void DrawRectange(Pen pen, Rect rect)
 {
     this.SetPen(pen);
     this.context.Rectangle(rect.ToCairo());
     this.context.Stroke();
 }
开发者ID:MarkWalls,项目名称:Perspex,代码行数:11,代码来源:DrawingContext.cs


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