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


C# Context.SetSourceRGBA方法代码示例

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


在下文中一共展示了Context.SetSourceRGBA方法的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: Draw3Circles

	void Draw3Circles (Context cr, int xc, int yc, double radius, double alpha)
	{
		double subradius = radius * (2 / 3.0 - 0.1);

		cr.SetSourceRGBA (1.0, 0.0, 0.0, alpha);
		OvalPath (cr, xc + radius / 3.0 * Math.Cos (Math.PI * 0.5), yc - radius / 3.0 * Math.Sin (Math.PI * 0.5), subradius, subradius);
		cr.Fill ();

		cr.SetSourceRGBA (0.0, 1.0, 0.0, alpha);
		OvalPath (cr, xc + radius / 3.0 * Math.Cos (Math.PI * (0.5 + 2 / 0.3)), yc - radius / 3.0 * Math.Sin (Math.PI * (0.5 + 2 / 0.3)), subradius, subradius);
		cr.Fill ();

		cr.SetSourceRGBA (0.0, 0.0, 1.0, alpha);
		OvalPath (cr, xc + radius / 3.0 * Math.Cos (Math.PI * (0.5 + 4 / 0.3)), yc - radius / 3.0 * Math.Sin (Math.PI * (0.5 + 4 / 0.3)), subradius, subradius);
		cr.Fill ();
	}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:16,代码来源:CairoSample.cs

示例3: OnRender

 protected void OnRender(Context cr, int width, int height)
 {
     cr.Save();
     cr.SetSourceRGBA(1, 0, 0, mTick*0.1);
     cr.Rectangle(0, 0, width, height);
     cr.Fill();
     cr.Restore();
 }
开发者ID:icebreaker,项目名称:csdemo,代码行数:8,代码来源:main.cs

示例4: Draw

		public static void Draw(Context grw, RectangleElement rect)
		{
			if (rect.Foregraund != null) {
				grw.SetSourceRGBA (
					rect.Foregraund.Red, 
					rect.Foregraund.Green, 
					rect.Foregraund.Blue, 
					rect.Alpha);
			}

			grw.Rectangle (
				new Rectangle (
					rect.LeftBottom.GeometryX, 
					rect.LeftBottom.GeometryY, 
					rect.GeometryWidth, 
					rect.GeometryHeight));

			grw.StrokePreserve();
			grw.Fill();
		}
开发者ID:jdpillon,项目名称:ArduinoLadder,代码行数:20,代码来源:RectangleBrush.cs

示例5: Moodbar

        private Moodbar(string mood_file_path)
        {
            this.mood_file_path = mood_file_path;
            //            mood_file_path = GetMoodFilePath(audio_file_path);
            var file = new FileStream (mood_file_path, FileMode.Open);
            moodbar_data = new byte[file.Length / 3, 3];

            for (int i = 0; i < file.Length; i += 3) {
                moodbar_data[i / 3, 0] = (byte)file.ReadByte ();
                moodbar_data[i / 3, 1] = (byte)file.ReadByte ();
                moodbar_data[i / 3, 2] = (byte)file.ReadByte ();
            }
            file.Close ();

            mood_surface = new Cairo.ImageSurface (Cairo.Format.RGB24, 1000, 1);
            using (Cairo.Context cr = new Cairo.Context (mood_surface)) {
                for (int i = 0; i < moodbar_data.GetLength (0); i++) {
                    cr.SetSourceRGBA (moodbar_data[i, 0] / 255.0, moodbar_data[i, 1] / 255.0, moodbar_data[i, 2] / 255.0, 1);
                    cr.Rectangle (i, 0, 1, 1);
                    cr.Fill ();
                }
            }
        }
开发者ID:X4lldux,项目名称:banshee-moodbar-extension,代码行数:23,代码来源:Moodbar.cs

示例6: 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

示例7: DrawTitle

 protected void DrawTitle(Context g, String name)
 {
     g.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold); //Draw the title and line names/colors.
     g.SetFontSize (14);
     g.SetSourceRGBA (0, 0, 0, 0.5f);
     g.MoveTo (NumberSpacingXLeft+15, NumberSpacingYUp+7);
     g.ShowText (name);
 }
开发者ID:haved,项目名称:MyPrograms,代码行数:8,代码来源:HChart.cs

示例8: Draw

        private void Draw(DrawingArea drawingarea1, Color tool_color, Cairo.PointD point, bool first_pixel)
        {
            int x = (int)point.X;
            int y = (int) point.Y;

            if (last_point.Equals (point_empty)) {
                last_point = new Point (x, y);

                if (!first_pixel)
                    return;
            }

            Document doc = PintaCore.Workspace.ActiveDocument;

            if (doc.Workspace.PointInCanvas (point))
                surface_modified = true;

            ImageSurface surf = doc.CurrentUserLayer.Surface;

            if (first_pixel) {
                // Does Cairo really not support a single-pixel-long single-pixel-wide line?
                surf.Flush ();
                int shiftedX = (int)point.X;
                int shiftedY = (int)point.Y;
                ColorBgra source = surf.GetColorBgra (shiftedX, shiftedY);
                source = UserBlendOps.NormalBlendOp.ApplyStatic (source, tool_color.ToColorBgra ());
                surf.SetColorBgra (source, shiftedX, shiftedY);
                surf.MarkDirty ();
            } else {
                using (Context g = new Context (surf)) {
                    g.AppendPath (doc.Selection.SelectionPath);
                    g.FillRule = FillRule.EvenOdd;
                    g.Clip ();

                    g.Antialias = Antialias.None;

                    // Adding 0.5 forces cairo into the correct square:
                    // See https://bugs.launchpad.net/bugs/672232
                    g.MoveTo (last_point.X + 0.5, last_point.Y + 0.5);
                    g.LineTo (x + 0.5, y + 0.5);

                    g.SetSourceRGBA (tool_color);
                    g.LineWidth = 1;
                    g.LineCap = LineCap.Square;

                    g.Stroke ();
                }
            }

            Gdk.Rectangle r = GetRectangleFromPoints (last_point, new Point (x, y));

            if (doc.Workspace.IsPartiallyOffscreen (r)) {
                doc.Workspace.Invalidate ();
            } else {
                doc.Workspace.Invalidate (doc.ClampToImageSize (r));
            }

            last_point = new Point (x, y);
        }
开发者ID:CiprianKhlud,项目名称:Pinta,代码行数:59,代码来源:PencilTool.cs

示例9: paintDisabled

 void paintDisabled(Context gr, Rectangle rb)
 {
     gr.Operator = Operator.Xor;
     gr.SetSourceRGBA (0.6, 0.6, 0.6, 0.3);
     gr.Rectangle (rb);
     gr.Fill ();
     gr.Operator = Operator.Over;
 }
开发者ID:jpbruyere,项目名称:Crow,代码行数:8,代码来源:GraphicObject.cs

示例10: DrawText

        private void DrawText(Context cr, string text, int x, int y)
        {
            cr.SetSourceRGBA(0.0, 0.0, 0.0, 0.1);
            int dx = 3, dy = 4;
            cr.MoveTo(x-1+dx, y-1+dy);
            cr.ShowText(text);
            cr.MoveTo(x+1+dx, y+1+dy);
            cr.ShowText(text);
            cr.MoveTo(x-1+dx, y+1+dy);
            cr.ShowText(text);
            cr.MoveTo(x+1+dx, y-1+dy);
            cr.ShowText(text);

            Gdk.Color c = textcolor;
            double b = (double)c.Blue / ushort.MaxValue;
            double g = (double)c.Green / ushort.MaxValue;
            double r = (double)c.Red / ushort.MaxValue;
            if(b>1) b = 1;
            if(g>1) g = 1;
            if(r>1) r = 1;
            cr.SetSourceRGBA(b,g,r, 1);
            cr.MoveTo(x, y);
            cr.Antialias = Antialias.Default;
            cr.ShowText(text);
        }
开发者ID:niwakazoider,项目名称:unicast,代码行数:25,代码来源:TextWindow.cs

示例11: DrawLineInfo

 protected void DrawLineInfo(Context g, HChartLine line, int index)
 {
     g.MoveTo (NumberSpacingXLeft+15, NumberSpacingYUp+15 + index * 15);
     g.LineTo (NumberSpacingXLeft+25, NumberSpacingYUp+15 + index * 15);
     line.UseColor (g);
     g.LineWidth = 11;
     g.Stroke ();
     g.MoveTo (NumberSpacingXLeft+26, NumberSpacingYUp+20 + index * 15);
     g.SetSourceRGBA (0, 0, 0, 0.5f);
     g.ShowText (line.GetName ());
 }
开发者ID:haved,项目名称:MyPrograms,代码行数:11,代码来源:HChart.cs

示例12: DrawCircle

 static void DrawCircle(Context cr, double xc, double yc, double radius, Color color)
 {
     cr.SetSourceRGBA (color.R, color.G, color.B, color.A);
     OvalPath (cr, xc, yc, radius, radius);
     cr.Fill ();
 }
开发者ID:ugureren,项目名称:agariosharp,代码行数:6,代码来源:Program.cs

示例13: OnMouseMove

        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            if ((args.Event.State & Gdk.ModifierType.Button1Mask) == Gdk.ModifierType.Button1Mask) {
                outline_color = PintaCore.Palette.PrimaryColor;
                fill_color = PintaCore.Palette.SecondaryColor;
            } else if ((args.Event.State & Gdk.ModifierType.Button3Mask) == Gdk.ModifierType.Button3Mask) {
                outline_color = PintaCore.Palette.SecondaryColor;
                fill_color = PintaCore.Palette.PrimaryColor;
            } else {
                last_point = point_empty;
                return;
            }

            int x = (int)point.X;
            int y = (int)point.Y;

            if (last_point.Equals (point_empty)) {
                last_point = new Point (x, y);
                return;
            }

            if (doc.Workspace.PointInCanvas (point))
                surface_modified = true;

            doc.ToolLayer.Clear ();
            ImageSurface surf = doc.ToolLayer.Surface;

            using (Context g = new Context (surf)) {
                doc.Selection.Clip(g);

                g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

                if (path != null) {
                    g.AppendPath (path);
                    (path as IDisposable).Dispose ();
                }

                g.LineTo (x, y);

                path = g.CopyPath ();

                g.ClosePath ();
                g.LineWidth = BrushWidth;
                g.LineJoin = LineJoin.Round;
                g.LineCap = LineCap.Round;
                g.FillRule = FillRule.EvenOdd;

                if (FillShape && StrokeShape) {
                    g.SetSourceRGBA (fill_color);
                    g.FillPreserve ();
                    g.SetSourceRGBA (outline_color);
                    g.Stroke ();
                } else if (FillShape) {
                    g.SetSourceRGBA (outline_color);
                    g.Fill ();
                } else {
                    g.SetSourceRGBA (outline_color);
                    g.Stroke ();
                }
            }

            doc.Workspace.Invalidate ();

            last_point = new Point (x, y);
        }
开发者ID:CiprianKhlud,项目名称:Pinta,代码行数:67,代码来源:FreeformShapeTool.cs

示例14: OnMouseUp

        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            doc.ToolLayer.Hidden = true;

            if (surface_modified)
                PintaCore.History.PushNewItem (new SimpleHistoryItem (Icon, Name, undo_surface, doc.CurrentUserLayerIndex));
            else if (undo_surface != null)
                (undo_surface as IDisposable).Dispose ();

            surface_modified = false;
            ImageSurface surf = doc.CurrentUserLayer.Surface;

            using (Context g = new Context (surf)) {
                g.AppendPath (doc.Selection.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

                if (path != null) {
                    g.AppendPath (path);
                    (path as IDisposable).Dispose ();
                    path = null;
                }

                g.ClosePath ();
                g.LineWidth = BrushWidth;
                g.LineJoin = LineJoin.Round;
                g.LineCap = LineCap.Round;
                g.FillRule = FillRule.EvenOdd;

                if (FillShape && StrokeShape) {
                    g.SetSourceRGBA (fill_color);
                    g.FillPreserve ();
                    g.SetSourceRGBA (outline_color);
                    g.Stroke ();
                } else if (FillShape) {
                    g.SetSourceRGBA (outline_color);
                    g.Fill ();
                } else {
                    g.SetSourceRGBA (outline_color);
                    g.Stroke ();
                }
            }

            doc.Workspace.Invalidate ();
        }
开发者ID:CiprianKhlud,项目名称:Pinta,代码行数:49,代码来源:FreeformShapeTool.cs

示例15: OnMouseMove

        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            if (mouse_button == 1) {
                StrokeColor = PintaCore.Palette.PrimaryColor;
                FillColor = PintaCore.Palette.SecondaryColor;
            } else if (mouse_button == 3) {
                StrokeColor = PintaCore.Palette.SecondaryColor;
                FillColor = PintaCore.Palette.PrimaryColor;
            } else {
                LastPoint = point_empty;
                return;
            }

            // TODO: also multiply by pressure
            StrokeColor = new Color (StrokeColor.R, StrokeColor.G, StrokeColor.B,
                StrokeColor.A * active_brush.StrokeAlphaMultiplier);

            int x = (int)point.X;
            int y = (int)point.Y;

            if (LastPoint.Equals (point_empty))
                LastPoint = new Point (x, y);

            if (doc.Workspace.PointInCanvas (point))
                surface_modified = true;

            var surf = doc.CurrentUserLayer.Surface;
            var invalidate_rect = Gdk.Rectangle.Zero;
            var brush_width = BrushWidth;

            Surface = surf;

            using (Drawable = new Context (surf)) {
                Drawable.AppendPath (doc.Selection.SelectionPath);
                Drawable.FillRule = FillRule.EvenOdd;
                Drawable.Clip ();

                Drawable.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;
                Drawable.LineWidth = brush_width;
                Drawable.LineJoin = LineJoin.Round;
                Drawable.LineCap = BrushWidth == 1 ? LineCap.Butt : LineCap.Round;
                Drawable.SetSourceRGBA (StrokeColor);

                active_brush.Tool = this;
                invalidate_rect = active_brush.DoMouseMove (x, y, LastPoint.X, LastPoint.Y);
                active_brush.Tool = null;
            }

            Surface = null;
            Drawable = null;

            // If we draw partially offscreen, Cairo gives us a bogus
            // dirty rectangle, so redraw everything.
            if (doc.Workspace.IsPartiallyOffscreen (invalidate_rect)) {
                doc.Workspace.Invalidate ();
            } else {
                doc.Workspace.Invalidate (doc.ClampToImageSize (invalidate_rect));
            }

            LastPoint = new Point (x, y);
        }
开发者ID:CiprianKhlud,项目名称:Pinta,代码行数:63,代码来源:PaintBrushTool.cs


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