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


C# Cairo.LinearGradient.AddColorStopRgb方法代码示例

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


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

示例1: SetBrush

        private void SetBrush(Brush brush, Size destinationSize)
        {
            var solid = brush as SolidColorBrush;
            var linearGradientBrush = brush as LinearGradientBrush;

            if (solid != null)
            {
                _context.SetSourceRGBA(
                    solid.Color.R / 255.0,
                    solid.Color.G / 255.0,
                    solid.Color.B / 255.0,
                    solid.Color.A / 255.0);
            }
            else if (linearGradientBrush != null)
            {
                Cairo.LinearGradient g = new Cairo.LinearGradient(linearGradientBrush.StartPoint.X * destinationSize.Width, linearGradientBrush.StartPoint.Y * destinationSize.Height, linearGradientBrush.EndPoint.X * destinationSize.Width, linearGradientBrush.EndPoint.Y * destinationSize.Height);

                foreach (var s in linearGradientBrush.GradientStops)
                    g.AddColorStopRgb(s.Offset, new Cairo.Color(s.Color.R, s.Color.G, s.Color.B, s.Color.A));

                g.Extend = Cairo.Extend.Pad;

                _context.SetSource(g);
            }
        }
开发者ID:healtech,项目名称:Perspex,代码行数:25,代码来源:DrawingContext.cs

示例2: OnExposeEvent

		protected override bool OnExposeEvent (Gdk.EventExpose e)
		{
			using (Cairo.Context cr = Gdk.CairoHelper.Create (e.Window)) {
				cr.Rectangle (0, 0, Allocation.Width, upperGradientHeight);
				using (var pattern = new Cairo.LinearGradient (0, 0, 0, upperGradientHeight)) {
					pattern.AddColorStopRgb (0, new Cairo.Color (0.6, 0.8, 0.6));
					pattern.AddColorStopRgb (1, new Cairo.Color (0.8, 1.0, 0.8));
					cr.Pattern = pattern;
					cr.Fill ();
				}
				
				cr.Rectangle (0, upperGradientHeight, Allocation.Width, Allocation.Height - upperGradientHeight);
				using (var pattern = new Cairo.LinearGradient (0, upperGradientHeight, 0, Allocation.Height)) {
					pattern.AddColorStop (0, new Cairo.Color (0.8, 1.0, 0.8));
					pattern.AddColorStop (1, new Cairo.Color (0.6, 0.8, 0.6));
					cr.Pattern = pattern;
					cr.Fill ();
				}
				
				cr.LineWidth = 1;
				cr.Line (0, 0, Allocation.Width, 0);
				cr.Color = new Cairo.Color (0.4, 0.6, 0.4);
				cr.Stroke ();
				
				double xPos = padding, yPos = padding;
				var layout = PangoUtil.CreateLayout (this);
				int w, h;
				layout.SetText (new string ('X', maxLength));
				layout.GetPixelSize (out w, out h);
				
				foreach (Category cat in categories) {
					yPos = padding;
					cr.MoveTo (xPos, yPos);
					layout.SetMarkup ("<b>" + cat.Title + "</b>");
					cr.Color = (HslColor)Style.Text (StateType.Normal);
					cr.ShowLayout (layout);
					layout.SetMarkup ("");
					int w2, h2;
					layout.GetPixelSize (out w2, out h2);
					yPos += h2;
					yPos += headerDistance;
					var startY = yPos;
					int curItem = 0;
					int row = 0;
					var iconHeight = Math.Max (h, cat.Items [0].Icon.Height + 2);
					if (cat.FirstVisibleItem > 0) {
						Gtk.Style.PaintArrow (Style, e.Window, State, ShadowType.None, 
								new Rectangle ((int)xPos, (int)yPos, w, h), 
								this, 
								"", 
								ArrowType.Up, 
								true, 
								(int)xPos, 
								(int)yPos, 
								w, 
								h);
						yPos += iconHeight;
						curItem++;
					}
					
					for (int i = cat.FirstVisibleItem; i < cat.Items.Count; i++) {
						var item = cat.Items [i];
						
						if (curItem + 1 >= maxItems && row + 1 >= maxRows && i + 1 < cat.Items.Count) {
							Gtk.Style.PaintArrow (Style, e.Window, State, ShadowType.None, 
								new Rectangle ((int)xPos, (int)yPos, w, h), 
								this, 
								"", 
								ArrowType.Down, 
								true, 
								(int)xPos, 
								(int)yPos, 
								w, 
								h);
							break;
						}
						
						if (item == ActiveItem) {
							cr.Rectangle (xPos + 0.5, yPos + 0.5, w + item.Icon.Width + 2, iconHeight);
							
							using (var pattern = new Cairo.LinearGradient (xPos, yPos, xPos, yPos + iconHeight * 2)) {
								pattern.AddColorStop (0, (HslColor)Style.Base (StateType.Selected));
								pattern.AddColorStop (1, new Cairo.Color (0.8, 1.0, 0.8));
								cr.Pattern = pattern;
								cr.FillPreserve ();
							}
							
							cr.Color = (HslColor)Style.Base (StateType.Selected);
							cr.Stroke ();
							cr.Color = (HslColor)Style.Text (StateType.Selected);
						} else if (item == hoverItem) {
							cr.Rectangle (xPos + 0.5, yPos + 0.5, w + item.Icon.Width + 2, iconHeight);
							using (var pattern = new Cairo.LinearGradient (xPos, yPos, xPos, yPos + iconHeight)) {
								pattern.AddColorStop (0, new Cairo.Color (0.6, 0.8, 0.6));
								pattern.AddColorStop (1, new Cairo.Color (0.8, 1.0, 0.8));
								cr.Pattern = pattern;
								cr.Fill ();
							}
							cr.Color = (HslColor)Style.Text (StateType.Normal);
						} else {
//.........这里部分代码省略.........
开发者ID:raufbutt,项目名称:monodevelop-old,代码行数:101,代码来源:DocumentSwitcher.cs


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