• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Cairo.LinearGradient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: draw

	static void draw (Cairo.Context gr, int width, int height)
	{
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		LinearGradient pat;		
		
		pat = new LinearGradient (0.0, 0.0,  0.0, 1.0);
		pat.AddColorStop (1, new Color (0, 0, 0, 1) );
		pat.AddColorStop (0, new Color (1, 1, 1, 1) );
		gr.Rectangle ( new PointD (0, 0),
			       1, 1
			       );
		
		gr.Pattern =  pat;
		gr.Fill ();
		pat.Destroy ();

		RadialGradient pat2 = new RadialGradient (0.45, 0.4, 0.1,
				     0.4,  0.4, 0.5);
		
		pat2.AddColorStop (0, new Color (1, 1, 1, 1) );
		pat2.AddColorStop (1, new Color (0, 0, 0, 1) );
		gr.Pattern =  pat2;
		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Fill ();
		pat2.Destroy ();
	}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:27,代码来源:gradient.cs


示例2: Render

		protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
		{
			using (Cairo.Context gr = Gdk.CairoHelper.Create (window)) {
				gr.Rectangle (cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);
				gr.Color = (HslColor)widget.Style.Base ((flags & CellRendererState.Selected) == CellRendererState.Selected ? StateType.Selected : StateType.Normal);
				gr.Fill ();
				var size = Math.Max (0, cell_area.Width - cell_area.Width * Time / 100.0);
				var linearGradient = new LinearGradient (cell_area.X, cell_area.Y, cell_area.Right, cell_area.Bottom);
				linearGradient.AddColorStop (0, new Cairo.Color (1, 0, 0));
				linearGradient.AddColorStop (1, new Cairo.Color (1, 1, 1));
				gr.Pattern = linearGradient;
				
				gr.Rectangle (cell_area.X + size, cell_area.Y + 2, cell_area.Width - size, cell_area.Height - 4);
				gr.Fill ();
				
				var layout = gr.CreateLayout ();
				layout.FontDescription = widget.PangoContext.FontDescription;
				layout.SetText (string.Format ("{0:0.0}", Time));
				int w, h;
				layout.GetPixelSize (out w, out h);
				gr.MoveTo (cell_area.X + cell_area.Width - 2 - w, cell_area.Y + (cell_area.Height - h) / 2);
				gr.Color = new Cairo.Color (0, 0, 0);
				gr.ShowLayout (layout);
				layout.Dispose ();
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:26,代码来源:TimeCellRenderer.cs


示例3: DrawColumnHighlight

        public void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color)
        {
            Cairo.Color light_color = CairoExtensions.ColorShade (color, 1.6);
            Cairo.Color dark_color = CairoExtensions.ColorShade (color, 1.3);

            LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom - 1);
            grad.AddColorStop (0, light_color);
            grad.AddColorStop (1, dark_color);

            cr.SetSource (grad);
            cr.Rectangle (alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2);
            cr.Fill ();
            grad.Dispose ();
        }
开发者ID:stsundermann,项目名称:cubano,代码行数:14,代码来源:CubanoTheme.cs


示例4: Render

        public override void Render(Context cr)
        {
            if (!CanResize) {
                return;
            }

            var selected_color = CairoExtensions.GdkColorToCairoColor (Window.Style.Dark (StateType.Active));
            var grad = new LinearGradient (0, 0, 0, Allocation.Height);

            selected_color.A = 0.4;
            grad.AddColorStop (0, selected_color);
            selected_color.A = 1.0;
            grad.AddColorStop (1, selected_color);

            cr.Pattern = grad;
            cr.LineWidth = 1.0;
            cr.Rectangle (0.5, 0.5, Allocation.Width - 1, Allocation.Height - 1);
            cr.Stroke ();

            selected_color.A = 0.5;
            cr.Color = selected_color;

            double handle_size = 8;
            double ty = 0.5 + Allocation.Height - handle_size - 3;
            double tx = 0.5 + (Window.Direction == TextDirection.Ltr
                ? Allocation.Width - handle_size - 3
                : 3);

            cr.Translate (tx, ty);

            for (double i = 0; i < 3; i++) {
                if (Window.Direction == TextDirection.Ltr) {
                    cr.MoveTo (i * 3, handle_size);
                    cr.LineTo (handle_size, i * 3);
                } else {
                    cr.MoveTo (0, i * 3);
                    cr.LineTo (handle_size - i * 3, handle_size);
                }
            }

            cr.Stroke ();

            cr.Translate (-tx, -ty);
        }
开发者ID:abock,项目名称:cubano,代码行数:44,代码来源:CubanoWindowDecorator.cs


示例5: OnExposeEvent

		protected override bool OnExposeEvent (Gdk.EventExpose evnt)
		{
			Pango.Layout la = new Pango.Layout (PangoContext);
			int w, h;
			if (UseMarkup)
				la.SetMarkup (Text);
			else
				la.SetText (Text);

			la.GetPixelSize (out w, out h);

			int tx = Allocation.X + (int) Xpad + (int) ((float)(Allocation.Width - (int)(Xpad*2) - w) * Xalign);
			int ty = Allocation.Y + (int) Ypad + (int) ((float)(Allocation.Height - (int)(Ypad*2) - h) * Yalign);

			using (var ctx = CairoHelper.Create (evnt.Window)) {
				ctx.SetSourceColor (Style.Text (State).ToCairoColor ());
				ctx.MoveTo (tx, ty);

				// In order to get the same result as in MonoDevelop.Components.DockNotebook.TabStrip.DrawTab()
				// (document tabs) we need to draw using a LinearGradient (because of issues below),
				// but we don't want to mask the actual text here, like in the doc tabs.
				// Therefore we use a LinearGradient and mask only the last vertical pixel line
				// of the label with 0.99 alpha, which forces Cairo to render the whole layout
				// in the desired way.

				// Semi-transparent gradient disables sub-pixel rendering of the label (reverting to grayscale antialiasing).
				// As Mac sub-pixel font rendering looks stronger than grayscale rendering, the label used in pad tabs
				// looked different. We need to simulate same gradient treatment as we have in document tabs.

				using (var lg = new LinearGradient (tx + w - 1, 0, tx + w, 0)) {
					var color = Style.Text (State).ToCairoColor ();
					lg.AddColorStop (0, color);
					color.A = 0.99;
					lg.AddColorStop (1, color);
					ctx.SetSource (lg);
					Pango.CairoHelper.ShowLayout (ctx, la);
				}
			}
			
			la.Dispose ();
			return true;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:42,代码来源:ExtendedLabel.cs


示例6: Render

		public void Render (Cairo.Context context, StatusArea.RenderArg arg)
		{
			context.CachedDraw (surface: ref backgroundSurface, 
			                    region: arg.Allocation,
			                    draw: (c, o) => DrawBackground (c, new Gdk.Rectangle (0, 0, arg.Allocation.Width, arg.Allocation.Height)));

			if (arg.BuildAnimationOpacity > 0.001f)
				DrawBuildEffect (context, arg.Allocation, arg.BuildAnimationProgress, arg.BuildAnimationOpacity);

			if (arg.ErrorAnimationProgress > 0.001 && arg.ErrorAnimationProgress < .999) {
				DrawErrorAnimation (context, arg);
			}

			DrawBorder (context, arg.Allocation);

			if (arg.HoverProgress > 0.001f)
			{
				context.Clip ();
				int x1 = arg.Allocation.X + arg.MousePosition.X - 200;
				int x2 = x1 + 400;
				using (Cairo.LinearGradient gradient = new LinearGradient (x1, 0, x2, 0))
				{
					Cairo.Color targetColor = Styles.StatusBarFill1Color;
					Cairo.Color transparentColor = targetColor;
					targetColor.A = .7;
					transparentColor.A = 0;

					targetColor.A = .7 * arg.HoverProgress;

					gradient.AddColorStop (0.0, transparentColor);
					gradient.AddColorStop (0.5, targetColor);
					gradient.AddColorStop (1.0, transparentColor);

					context.Pattern = gradient;

					context.Rectangle (x1, arg.Allocation.Y, x2 - x1, arg.Allocation.Height);
					context.Fill ();
				}
				context.ResetClip ();
			} else {
				context.NewPath ();
			}

			int progress_bar_x = arg.ChildAllocation.X;
			int progress_bar_width = arg.ChildAllocation.Width;

			if (arg.CurrentPixbuf != null) {
				int y = arg.Allocation.Y + (arg.Allocation.Height - arg.CurrentPixbuf.Height) / 2;
				Gdk.CairoHelper.SetSourcePixbuf (context, arg.CurrentPixbuf, arg.ChildAllocation.X, y);
				context.Paint ();
				progress_bar_x += arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
				progress_bar_width -= arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
			}

			int center = arg.Allocation.Y + arg.Allocation.Height / 2;

			Gdk.Rectangle progressArea = new Gdk.Rectangle (progress_bar_x, center - Styles.ProgressBarHeight / 2, progress_bar_width, Styles.ProgressBarHeight);
			if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0) {
				DrawProgressBar (context, arg.ProgressBarFraction, progressArea, arg);
				ClipProgressBar (context, progressArea);
			}

			int text_x = progress_bar_x + Styles.ProgressBarInnerPadding;
			int text_width = progress_bar_width - (Styles.ProgressBarInnerPadding * 2);

			double textTweenValue = arg.TextAnimationProgress;

			if (arg.LastText != null) {
				double opacity = Math.Max (0.0f, 1.0f - textTweenValue);
				DrawString (arg.LastText, arg.LastTextIsMarkup, context, text_x, 
				            center - (int)(textTweenValue * arg.Allocation.Height * 0.3), text_width, opacity, arg.Pango, arg);
			}

			if (arg.CurrentText != null) {
				DrawString (arg.CurrentText, arg.CurrentTextIsMarkup, context, text_x, 
				            center + (int)((1.0f - textTweenValue) * arg.Allocation.Height * 0.3), text_width, Math.Min (textTweenValue, 1.0), arg.Pango, arg);
			}

			if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0)
				context.ResetClip ();
		}
开发者ID:wickedshimmy,项目名称:monodevelop,代码行数:81,代码来源:StatusAreaTheme.cs


示例7: DrawBackground

		protected virtual void DrawBackground (Cairo.Context context, Gdk.Rectangle region)
		{	
			LayoutRoundedRectangle (context, region);
			context.ClipPreserve ();

			using (LinearGradient lg = new LinearGradient (region.X, region.Y, region.X, region.Y + region.Height)) {
				lg.AddColorStop (0, Styles.StatusBarFill1Color);
				lg.AddColorStop (1, Styles.StatusBarFill4Color);

				context.Pattern = lg;
				context.FillPreserve ();
			}

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

			using (RadialGradient rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) {
				rg.AddColorStop (0, Styles.StatusBarFill1Color);
				rg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarFill1Color, 0));

				context.Scale (region.Width / (double)region.Height, 1.0);
				context.Pattern = rg;
				context.Fill ();
			}
			context.Restore ();

			using (LinearGradient lg = new LinearGradient (0, region.Y, 0, region.Y + region.Height)) {
				lg.AddColorStop (0, Styles.StatusBarShadowColor1);
				lg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarShadowColor1, Styles.StatusBarShadowColor1.A * 0.2));

				LayoutRoundedRectangle (context, region, 0, -1);
				context.LineWidth = 1;
				context.Pattern = lg;
				context.Stroke ();
			}

			using (LinearGradient lg = new LinearGradient (0, region.Y, 0, region.Y + region.Height)) {
				lg.AddColorStop (0, Styles.StatusBarShadowColor2);
				lg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarShadowColor2, Styles.StatusBarShadowColor2.A * 0.2));

				LayoutRoundedRectangle (context, region, 0, -2);
				context.LineWidth = 1;
				context.Pattern = lg;
				context.Stroke ();
			}

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


示例8: DrawBackground

        void DrawBackground(Cairo.Context context, Gdk.Rectangle region, int radius, StateType state)
        {
            double rad = radius - 0.5;
            int centerX = region.X + region.Width / 2;
            int centerY = region.Y + region.Height / 2;

            context.MoveTo (centerX + rad, centerY);
            context.Arc (centerX, centerY, rad, 0, Math.PI * 2);

            double high;
            double low;
            switch (state) {
            case StateType.Selected:
                high = 0.85;
                low = 1.0;
                break;
            case StateType.Prelight:
                high = 1.0;
                low = 0.9;
                break;
            case StateType.Insensitive:
                high = 0.95;
                low = 0.83;
                break;
            default:
                high = 1.0;
                low = 0.85;
                break;
            }
            using (var lg = new LinearGradient (0, centerY - rad, 0, centerY +rad)) {
                lg.AddColorStop (0, new Cairo.Color (high, high, high));
                lg.AddColorStop (1, new Cairo.Color (low, low, low));
                context.SetSource (lg);
                context.FillPreserve ();
            }

            context.SetSourceRGBA (0, 0, 0, 0.4);
            context.LineWidth = 1;
            context.Stroke ();
        }
开发者ID:Kalnor,项目名称:monodevelop,代码行数:40,代码来源:RoundButton.cs


示例9: DrawRowSelection

        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
            bool filled, bool stroked, Cairo.Color color, CairoCorners corners, bool flat_fill)
        {
            Cairo.Color selection_color = color;
            Cairo.Color selection_highlight = CairoExtensions.ColorShade (selection_color, 1.24);
            Cairo.Color selection_stroke = CairoExtensions.ColorShade (selection_color, 0.85);
            selection_highlight.A = 0.5;
            selection_stroke.A = color.A;
            LinearGradient grad = null;

            if (filled) {
                if (flat_fill) {
                    cr.Color = selection_color;
                } else {
                    Cairo.Color selection_fill_light = CairoExtensions.ColorShade (selection_color, 1.12);
                    Cairo.Color selection_fill_dark = selection_color;

                    selection_fill_light.A = color.A;
                    selection_fill_dark.A = color.A;

                    grad = new LinearGradient (x, y, x, y + height);
                    grad.AddColorStop (0, selection_fill_light);
                    grad.AddColorStop (0.4, selection_fill_dark);
                    grad.AddColorStop (1, selection_fill_light);

                    cr.Pattern = grad;
                }

                CairoExtensions.RoundedRectangle (cr, x, y, width, height, Context.Radius, corners, true);
                cr.Fill ();

                if (grad != null) {
                    grad.Destroy ();
                }
            }

            if (filled && stroked) {
                cr.LineWidth = 1.0;
                cr.Color = selection_highlight;
                CairoExtensions.RoundedRectangle (cr, x + 1.5, y + 1.5, width - 3, height - 3,
                    Context.Radius - 1, corners, true);
                cr.Stroke ();
            }

            if (stroked) {
                cr.LineWidth = 1.0;
                cr.Color = selection_stroke;
                CairoExtensions.RoundedRectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1,
                    Context.Radius, corners, true);
                cr.Stroke ();
            }
        }
开发者ID:knocte,项目名称:hyena,代码行数:52,代码来源:GtkTheme.cs


示例10: PaintSurface

		protected sealed override void PaintSurface (DockySurface surface)
		{
			surface.Clear ();
			
			lock (buffers) {
				if (slideCounter > 0 && slideCounter < slideSteps) {
					double offset = Allocation.Width * Math.Log (slideCounter) / Math.Log (slideSteps);
					
					if (MovedLeft) {
						ShowBuffer (surface, Page, offset - Allocation.Width);
						ShowBuffer (surface, LastPage, offset);
					} else {
						ShowBuffer (surface, Page, Allocation.Width - offset);
						ShowBuffer (surface, LastPage, -offset);
					}
					
					// fade out the edges during a slide
					Gradient linpat = new LinearGradient (0, surface.Height / 2, surface.Width, surface.Height / 2);
					linpat.AddColorStop (0, new Color(1, 1, 1, 1));
					linpat.AddColorStop (2 * (double) BUTTON_SIZE / surface.Width, new Color(1, 1, 1, 0));
					linpat.AddColorStop (1 - 2 * (double) BUTTON_SIZE / surface.Width, new Color(1, 1, 1, 0));
					linpat.AddColorStop (1, new Color(1, 1, 1, 1));
						
					surface.Context.Save ();
					surface.Context.Operator = Operator.Source;
					surface.Context.Color = new Cairo.Color (0, 0, 0, 0);
					surface.Context.Mask (linpat);
					surface.Context.PaintWithAlpha (0);
					surface.Context.Restore ();
					linpat.Destroy ();
				} else {
					ShowBuffer (surface, Page, 0);
				}
			}
			
			// overlay the prev/next arrow buttons
			if (buttonBuffer != null && (buttonBuffer.Width != surface.Width || buttonBuffer.Height != surface.Height))
				ResetButtons ();
			
			if (buttonBuffer == null) {
				buttonBuffer = new DockySurface (surface.Width, surface.Height, surface);
				DrawButtonsBuffer ();
			}
			
			buttonBuffer.Internal.Show (surface.Context, 0, 0);
		}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:46,代码来源:PagingDockPainter.cs


示例11: RenderOuterShadow

		// VERY SLOW, only use on cached renders
		public static void RenderOuterShadow (this Cairo.Context self, Gdk.Rectangle area, int size, int rounding, double strength)
		{
			area.Inflate (-1, -1);
			size++;

			int doubleRounding = rounding * 2;
			// left side
			self.Rectangle (area.X - size, area.Y + rounding, size, area.Height - doubleRounding - 1);
			using (var lg = new LinearGradient (area.X, 0, area.X - size, 0)) {
				ShadowGradient (lg, strength);
				self.Pattern = lg;
				self.Fill ();
			}

			// right side
			self.Rectangle (area.Right, area.Y + rounding, size, area.Height - doubleRounding - 1);
			using (var lg = new LinearGradient (area.Right, 0, area.Right + size, 0)) {
				ShadowGradient (lg, strength);
				self.Pattern = lg;
				self.Fill ();
			}

			// top side
			self.Rectangle (area.X + rounding, area.Y - size, area.Width - doubleRounding - 1, size);
			using (var lg = new LinearGradient (0, area.Y, 0, area.Y - size)) {
				ShadowGradient (lg, strength);
				self.Pattern = lg;
				self.Fill ();
			}

			// bottom side
			self.Rectangle (area.X + rounding, area.Bottom, area.Width - doubleRounding - 1, size);
			using (var lg = new LinearGradient (0, area.Bottom, 0, area.Bottom + size)) {
				ShadowGradient (lg, strength);
				self.Pattern = lg;
				self.Fill ();
			}

			// top left corner
			self.Rectangle (area.X - size, area.Y - size, size + rounding, size + rounding);
			using (var rg = new RadialGradient (area.X + rounding, area.Y + rounding, rounding, area.X + rounding, area.Y + rounding, size + rounding)) {
				ShadowGradient (rg, strength);
				self.Pattern = rg;
				self.Fill ();
			}

			// top right corner
			self.Rectangle (area.Right - rounding, area.Y - size, size + rounding, size + rounding);
			using (var rg = new RadialGradient (area.Right - rounding, area.Y + rounding, rounding, area.Right - rounding, area.Y + rounding, size + rounding)) {
				ShadowGradient (rg, strength);
				self.Pattern = rg;
				self.Fill ();
			}

			// bottom left corner
			self.Rectangle (area.X - size, area.Bottom - rounding, size + rounding, size + rounding);
			using (var rg = new RadialGradient (area.X + rounding, area.Bottom - rounding, rounding, area.X + rounding, area.Bottom - rounding, size + rounding)) {
				ShadowGradient (rg, strength);
				self.Pattern = rg;
				self.Fill ();
			}

			// bottom right corner
			self.Rectangle (area.Right - rounding, area.Bottom - rounding, size + rounding, size + rounding);
			using (var rg = new RadialGradient (area.Right - rounding, area.Bottom - rounding, rounding, area.Right - rounding, area.Bottom - rounding, size + rounding)) {
				ShadowGradient (rg, strength);
				self.Pattern = rg;
				self.Fill ();
			}
		}
开发者ID:wickedshimmy,项目名称:monodevelop,代码行数:71,代码来源:CairoExtensions.cs


示例12: DrawFrameBorder

        public override void DrawFrameBorder(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            cr.LineWidth = BorderWidth;
            border_color.A = 0.3;
            cr.SetSourceColor (border_color);

            double offset = (double)BorderWidth / 2.0;
            double w = Math.Max (0, alloc.Width * 0.75);
            double x = alloc.X + (alloc.Width - w) * 0.5 + offset;
            double y = alloc.Y + alloc.Height + offset;

            LinearGradient g = new LinearGradient (x, y, x + w, y);

            Color transparent = border_color;
            transparent.A = 0.0;

            g.AddColorStop (0, transparent);
            g.AddColorStop (0.4, border_color);
            g.AddColorStop (0.6, border_color);
            g.AddColorStop (1, transparent);

            cr.SetSource (g);

            cr.MoveTo (x, y);
            cr.LineTo (x + w, y);
            cr.Stroke ();

            g.Dispose ();
        }
开发者ID:stsundermann,项目名称:cubano,代码行数:29,代码来源:CubanoTheme.cs


示例13: DrawRowSelection

        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
            bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
        {
            color.A *= 0.85;
            Cairo.Color selection_color = color;
            Cairo.Color selection_stroke = CairoExtensions.ColorShade (selection_color, 0.85);
            selection_stroke.A = color.A;

            if (filled) {
                Cairo.Color selection_fill_light = CairoExtensions.ColorShade (selection_color, 1.05);
                Cairo.Color selection_fill_dark = selection_color;

                selection_fill_light.A = color.A;
                selection_fill_dark.A = color.A;

                LinearGradient grad = new LinearGradient (x, y, x, y + height);
                grad.AddColorStop (0, selection_fill_dark);
                grad.AddColorStop (1, selection_fill_light);

                cr.SetSource (grad);
                cr.Rectangle (x, y, width, height);
                cr.Fill ();
                grad.Dispose ();
            }

            if (stroked && !filled) {
                cr.LineWidth = 1.0;
                cr.SetSourceColor (selection_stroke);
                cr.Rectangle (x + 0.5, y + 0.5, width - 1, height - 1);
                cr.Stroke ();
            }
        }
开发者ID:stsundermann,项目名称:cubano,代码行数:32,代码来源:CubanoTheme.cs


示例14: Draw

        void Draw(Cairo.Context ctx, List<TableRow> rowList, int dividerX, int x, ref int y)
        {
            if (!heightMeasured)
                return;

            Pango.Layout layout = new Pango.Layout (PangoContext);
            TableRow lastCategory = null;

            foreach (var r in rowList) {
                int w,h;
                layout.SetText (r.Label);
                layout.GetPixelSize (out w, out h);
                int indent = 0;

                if (r.IsCategory) {
                    var rh = h + CategoryTopBottomPadding*2;
                    ctx.Rectangle (0, y, Allocation.Width, rh);
                    using (var gr = new LinearGradient (0, y, 0, rh)) {
                        gr.AddColorStop (0, new Cairo.Color (248d/255d, 248d/255d, 248d/255d));
                        gr.AddColorStop (1, new Cairo.Color (240d/255d, 240d/255d, 240d/255d));
                        ctx.SetSource (gr);
                        ctx.Fill ();
                    }

                    if (lastCategory == null || lastCategory.Expanded || lastCategory.AnimatingExpand) {
                        ctx.MoveTo (0, y + 0.5);
                        ctx.LineTo (Allocation.Width, y + 0.5);
                    }
                    ctx.MoveTo (0, y + rh - 0.5);
                    ctx.LineTo (Allocation.Width, y + rh - 0.5);
                    ctx.SetSourceColor (DividerColor);
                    ctx.Stroke ();

                    ctx.MoveTo (x, y + CategoryTopBottomPadding);
                    ctx.SetSourceColor (CategoryLabelColor);
                    Pango.CairoHelper.ShowLayout (ctx, layout);

                    var img = r.Expanded ? discloseUp : discloseDown;
                    ctx.DrawImage (this, img, Allocation.Width - img.Width - CategoryTopBottomPadding, y + Math.Round ((rh - img.Height) / 2));

                    y += rh;
                    lastCategory = r;
                }
                else {
                    var cell = GetCell (r);
                    r.Enabled = !r.Property.IsReadOnly || cell.EditsReadOnlyObject;
                    var state = r.Enabled ? State : Gtk.StateType.Insensitive;
                    ctx.Save ();
                    ctx.Rectangle (0, y, dividerX, h + PropertyTopBottomPadding*2);
                    ctx.Clip ();
                    ctx.MoveTo (x, y + PropertyTopBottomPadding);
                    ctx.SetSourceColor (Style.Text (state).ToCairoColor ());
                    Pango.CairoHelper.ShowLayout (ctx, layout);
                    ctx.Restore ();

                    if (r != currentEditorRow)
                        cell.Render (GdkWindow, ctx, r.EditorBounds, state);

                    y += r.EditorBounds.Height;
                    indent = PropertyIndent;
                }

                if (r.ChildRows != null && r.ChildRows.Count > 0 && (r.Expanded || r.AnimatingExpand)) {
                    int py = y;

                    ctx.Save ();
                    if (r.AnimatingExpand)
                        ctx.Rectangle (0, y, Allocation.Width, r.AnimationHeight);
                    else
                        ctx.Rectangle (0, 0, Allocation.Width, Allocation.Height);

                    ctx.Clip ();
                    Draw (ctx, r.ChildRows, dividerX, x + indent, ref y);
                    ctx.Restore ();

                    if (r.AnimatingExpand) {
                        y = py + r.AnimationHeight;
                        // Repaing the background because the cairo clip doesn't work for gdk primitives
                        int dx = (int)((double)Allocation.Width * dividerPosition);
                        ctx.Rectangle (0, y, dx, Allocation.Height - y);
                        ctx.SetSourceColor (LabelBackgroundColor);
                        ctx.Fill ();
                        ctx.Rectangle (dx + 1, y, Allocation.Width - dx - 1, Allocation.Height - y);
                        ctx.SetSourceRGB (1, 1, 1);
                        ctx.Fill ();
                    }
                }
            }
        }
开发者ID:Kalnor,项目名称:monodevelop,代码行数:89,代码来源:PropertyGridTable.cs


示例15: CreateScene

        private Surface CreateScene (Cairo.Context window_cr, ImageSurface image, int reflect)
        {
            Surface surface = window_cr.Target.CreateSimilar (window_cr.Target.Content,
                image.Width, image.Height + reflect);
            Cairo.Context cr = new Context (surface);

            cr.Save ();

            cr.SetSource (image);
            cr.Paint ();

            cr.Rectangle (0, image.Height, image.Width, reflect);
            cr.Clip ();

            Matrix matrix = new Matrix ();
            matrix.InitScale (1, -1);
            matrix.Translate (0, -(2 * image.Height) + 1);
            cr.Transform (matrix);

            cr.SetSource (image);
            cr.Paint ();

            cr.Restore ();

            Color bg_transparent = BackgroundColor;
            bg_transparent.A = 0.65;

            LinearGradient mask = new LinearGradient (0, image.Height, 0, image.Height + reflect);
            mask.AddColorStop (0, bg_transparent);
            mask.AddColorStop (1, BackgroundColor);

            cr.Rectangle (0, image.Height, image.Width, reflect);
            cr.Pattern = mask;
            cr.Fill ();

            ((IDisposable)cr).Dispose ();
            return surface;
        }
开发者ID:gclark916,项目名称:banshee,代码行数:38,代码来源:LargeTrackInfoDisplay.cs


示例16: DrawCloseButton

		static void DrawCloseButton (Context context, Gdk.Point center, bool hovered, double opacity, double animationProgress)
		{
			if (hovered) {
				const double radius = 6;
				context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
				context.SetSourceRGBA (.6, .6, .6, opacity);
				context.Fill ();

				context.SetSourceRGBA (0.95, 0.95, 0.95, opacity);
				context.LineWidth = 2;

				context.MoveTo (center.X - 3, center.Y - 3);
				context.LineTo (center.X + 3, center.Y + 3);
				context.MoveTo (center.X - 3, center.Y + 3);
				context.LineTo (center.X + 3, center.Y - 3);
				context.Stroke ();
			} else {
				double lineColor = .63 - .1 * animationProgress;
				const double fillColor = .74;

				double heightMod = Math.Max (0, 1.0 - animationProgress * 2);
				context.MoveTo (center.X - 3, center.Y - 3 * heightMod);
				context.LineTo (center.X + 3, center.Y + 3 * heightMod);
				context.MoveTo (center.X - 3, center.Y + 3 * heightMod);
				context.LineTo (center.X + 3, center.Y - 3 * heightMod);

				context.LineWidth = 2;
				context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
				context.Stroke ();

				if (animationProgress > 0.5) {
					double partialProg = (animationProgress - 0.5) * 2;
					context.MoveTo (center.X - 3, center.Y);
					context.LineTo (center.X + 3, center.Y);

					context.LineWidth = 2 - partialProg;
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();

					double radius = partialProg * 3.5;

					// Background
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (fillColor, fillColor, fillColor, opacity);
					context.Fill ();

					// Inset shadow
					using (var lg = new LinearGradient (0, center.Y - 5, 0, center.Y)) {
						context.Arc (center.X, center.Y + 1, radius, 0, Math.PI * 2);
						lg.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.2 * opacity));
						lg.AddColorStop (1, new Cairo.Color (0, 0, 0, 0));
						context.SetSource (lg);
						context.Stroke ();
					}

					// Outline
					context.Arc (center.X, center.Y, radius, 0, Math.PI * 2);
					context.SetSourceRGBA (lineColor, lineColor, lineColor, opacity);
					context.Stroke ();

				}
			}
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:63,代码来源:TabStrip.cs


示例17: DrawTab

		void DrawTab (Context ctx, DockNotebookTab tab, Gdk.Rectangle allocation, Gdk.Rectangle tabBounds, bool highlight, bool active, bool dragging, Pango.Layout la)
		{
			// This logic is stupid to have here, should be in the caller!
			if (dragging) {
				tabBounds.X = (int)(tabBounds.X + (dragX - tabBounds.X) * dragXProgress);
				tabBounds.X = Clamp (tabBounds.X, tabStartX, tabEndX - tabBounds.Width);
			}
			int padding = LeftRightPadding;
			padding = (int)(padding * Math.Min (1.0, Math.Max (0.5, (tabBounds.Width - 30) / 70.0)));

			ctx.LineWidth = 1;
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.ClosePath ();
			using (var gr = new LinearGradient (tabBounds.X, TopBarPadding, tabBounds.X, allocation.Bottom)) {
				if (active) {
					gr.AddColorStop (0, Styles.BreadcrumbGradientStartColor.MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, Styles.BreadcrumbBackgroundColor.MultiplyAlpha (tab.Opacity));
				} else {
					gr.AddColorStop (0, CairoExtensions.ParseColor ("f4f4f4").MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, CairoExtensions.ParseColor ("cecece").MultiplyAlpha (tab.Opacity));
				}
				ctx.SetSource (gr);
			}
			ctx.Fill ();

			ctx.SetSourceColor (new Cairo.Color (1, 1, 1, .5).MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 1, active);
			ctx.Stroke ();

			ctx.SetSourceColor (Styles.BreadcrumbBorderColor.MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.StrokePreserve ();

			if (tab.GlowStrength > 0) {
				Gdk.Point mouse = tracker.MousePosition;
				using (var rg = new RadialGradient (mouse.X, tabBounds.Bottom, 0, mouse.X, tabBounds.Bottom, 100)) {
					rg.AddColorStop (0, new Cairo.Color (1, 1, 1, 0.4 * tab.Opacity * tab.GlowStrength));
					rg.AddColorStop (1, new Cairo.Color (1, 1, 1, 0));

					ctx.SetSource (rg);
					ctx.Fill ();
				}
			} else {
				ctx.NewPath ();
			}

			// Render Close Button (do this first so we can tell how much text to render)

			var ch = allocation.Height - TopBarPadding - BottomBarPadding + CloseImageTopOffset;
			var crect = new Gdk.Rectangle (tabBounds.Right - padding - CloseButtonSize + 3,
				            tabBounds.Y + TopBarPadding + (ch - CloseButtonSize) / 2,
				            CloseButtonSize, CloseButtonSize);
			tab.CloseButtonAllocation = crect;
			tab.CloseButtonAllocation.Inflate (2, 2);

			bool closeButtonHovered = tracker.Hovered && tab.CloseButtonAllocation.Contains (tracker.MousePosition) && tab.WidthModifier >= 1.0f;
			bool drawCloseButton = tabBounds.Width > 60 || highlight || closeButtonHovered;
			if (drawCloseButton) {
				DrawCloseButton (ctx, new Gdk.Point (crect.X + crect.Width / 2, crect.Y + crect.Height / 2), closeButtonHovered, tab.Opacity, tab.DirtyStrength);
			}

			// Render Text
			int w = tabBounds.Width - (padding * 2 + CloseButtonSize);
			if (!drawCloseButton)
				w += CloseButtonSize;

			int textStart = tabBounds.X + padding;

			ctx.MoveTo (textStart, tabBounds.Y + TopPadding + TextOffset + VerticalTextSize);
			if (!MonoDevelop.Core.Platform.IsMac && !MonoDevelop.Core.Platform.IsWindows) {
				// This is a work around for a linux specific problem.
				// A bug in the proprietary ATI driver caused TAB text not to draw.
				// If that bug get's fixed remove this HACK asap.
				la.Ellipsize = Pango.EllipsizeMode.End;
				la.Width = (int)(w * Pango.Scale.PangoScale);
				ctx.SetSourceColor (tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor);
				Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
			} else {
				// ellipses are for space wasting ..., we cant afford that
				using (var lg = new LinearGradient (textStart + w - 5, 0, textStart + w + 3, 0)) {
					var color = tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor;
					color = color.MultiplyAlpha (tab.Opacity);
					lg.AddColorStop (0, color);
					color.A = 0;
					lg.AddColorStop (1, color);
					ctx.SetSource (lg);
					Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
				}
			}
			la.Dispose ();
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:91,代码来源:TabStrip.cs


示例18: DrawTimeBar

        public void DrawTimeBar(CairoContextEx gr, double x, double y, double percentage)
        {
            double width = 0.04, height = 0.6;
            const double w = 0.003, h = 0.003;

            gr.DrawTextCentered (x + (width / 2), y + height + 0.05, Translations.GetString ("Time left"));
            gr.Stroke ();

            gr.Save ();
            gr.Color = new Color (0, 0, 0);
            gr.MoveTo (x, y);
            gr.LineTo (x, y + height);
            gr.LineTo (x + width, y + height);
            gr.LineTo (x + width, y);
            gr.LineTo (x, y);
            gr.Stroke ();

            x+= w;
            y+= h;
            width -= w * 2;
            height -= h * 2;
            y += height * (100 - percentage) / 100;
            height *= percentage / 100;

            if (gradient == null) {
                gradient = new LinearGradient (x, y, x + width, y + height);
                gradient.AddColorStop (0, new Color (1, 0, 0, 1));
                gradient.AddColorStop (1, new Color (0.2, 0, 0, 1));
            }

            gr.Source = gradient;
            gr.MoveTo (x, y);
            gr.LineTo (x, y + height);
            gr.LineTo (x + width, y + height);
            gr.LineTo (x + width, y);
            gr.LineTo (x, y);
            gr.FillPreserve ();
            gr.Stroke ();
            gr.Restore ();
        }
开发者ID:GNOME,项目名称:gbrainy,代码行数:40,代码来源:Memory.cs


示例19: DrawHeaderBackground

        public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            Cairo.Color gtk_background_color =
                CairoExtensions.GdkRGBAToCairoColor (Widget.StyleContext.GetBackgroundColor (StateFlags.Normal));
            Cairo.Color light_color = CairoExtensions.ColorShade (gtk_background_color, 1.1);
            Cairo.Color dark_color = CairoExtensions.ColorShade (gtk_background_color, 0.95);

            CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight;

            LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom);
            grad.AddColorStop (0, light_color);
            grad.AddColorStop (0.75, dark_color);
            grad.AddColorStop (0, light_color);

            cr.Pattern = grad;
            CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
            cr.Fill ();

            cr.Color = border_color;
            cr.Rectangle (alloc.X, alloc.Bottom, alloc.Width, BorderWidth);
            cr.Fill ();
            grad.Destroy ();
        }
开发者ID:knocte,项目名称:hyena,代码行数:23,代码来源:GtkTheme.cs


示例20: DrawGradient

        private void DrawGradient(Context g)
        {
            Rectangle rect = GradientRectangle;

            Gradient pat = new LinearGradient(rect.X, rect.Y, rect.X,
                                              rect.Y + rect.Height);
            pat.AddColorStop (0, MaxColor);
            pat.AddColorStop (1, new Cairo.Color (0, 0, 0));

            g.Rectangle (rect);
            g.Pattern = pat;
            g.Fill();
        }
开发者ID:RudoCris,项目名称:Pinta,代码行数:13,代码来源:ColorGradientWidget.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Cairo.PointD类代码示例发布时间:2022-05-24
下一篇:
C# Cairo.ImageSurface类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap