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


C# Context.SetSourceRGB方法代码示例

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


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

示例1: CreatePng

	public void CreatePng ()
	{
		const int Width = 480;
		const int Height = 160;
		const int CheckSize = 10;
		const int Spacing = 2;

		// Create an Image-based surface with data stored in ARGB32 format and a context,
		// "using" is used here to ensure that they are Disposed once we are done
		using (ImageSurface surface = new ImageSurface (Format.ARGB32, Width, Height))
		using (Context cr = new Cairo.Context (surface))
		{
			// Start drawing a checkerboard
			int i, j, xcount, ycount;
			xcount = 0;
			i = Spacing;
			while (i < Width) {
				j = Spacing;
				ycount = xcount % 2; // start with even/odd depending on row
				while (j < Height) {
					if (ycount % 2 != 0)
						cr.SetSourceRGB (1, 0, 0);
					else
						cr.SetSourceRGB (1, 1, 1);
					// If we're outside the clip, this will do nothing.
					cr.Rectangle (i, j, CheckSize, CheckSize);
					cr.Fill ();

					j += CheckSize + Spacing;
					++ycount;
				}
				i += CheckSize + Spacing;
				++xcount;
			}

			// Select a font to draw with
			cr.SelectFontFace ("serif", FontSlant.Normal, FontWeight.Bold);
			cr.SetFontSize (64.0);

			// Select a color (blue)
			cr.SetSourceRGB (0, 0, 1);

			// Draw
			cr.MoveTo (20, 100);
			cr.ShowText ("Hello, World");

			surface.WriteToPng ("test.png");
		}
	}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:49,代码来源:CairoPng.cs

示例2: DrawPoints

 public static void DrawPoints(List<PointD> points,Context cr)
 {
     foreach (PointD p in points){
         cr.MoveTo(p);
         cr.SetSourceRGB (0.3, 0.3, 0.3);
         cr.Arc (p.X, p.Y, 2, 0, 2 * Math.PI);
         cr.Fill ();
     }
 }
开发者ID:latestversion,项目名称:projects,代码行数:9,代码来源:Drawer.cs

示例3: Draw

		public static void Draw(Context grw, Line line)
		{
			var color = AppController.Instance.Config.LineColor;
			grw.SetSourceRGB (
				color.Red, 
				color.Green, 
				color.Blue);

			var segments = AppController.Instance.Surface.Segments;

			var s1 = segments.FirstOrDefault (s => s.Position.X == line.Input.X 
				&& s.Position.Y == line.Input.Y);

			var s2 = segments.FirstOrDefault (s => s.Position.X == line.Output.X 
				&& s.Position.Y == line.Output.Y);
			
			if (s1 == null || s2 == null)
			{
				return;
			}

			//todo : use one func.
			var start = s1.Connectors
				.FirstOrDefault (p => p.Marker == line.InputMarker);

			//todo : use one func.
			var stop = s2.Connectors
				.FirstOrDefault (p => p.Marker == line.OutputMarker);
			if (start == null || stop == null)
			{
				return;
			}

			grw.MoveTo (
				start.Center.GeometryX, 
				start.Center.GeometryY);

			if (line.Input.X == line.Output.X ||
			   line.Input.Y == line.Output.Y) {
				grw.LineTo (
					stop.Center.GeometryX, 
					stop.Center.GeometryY);    
			} else {
				grw.LineTo (
					stop.Center.GeometryX, 
					start.Center.GeometryY);    

				grw.LineTo (
					stop.Center.GeometryX, 
					stop.Center.GeometryY);    
			}

			grw.Stroke();
		}
开发者ID:jdpillon,项目名称:ArduinoLadder,代码行数:54,代码来源:SurfaceLineBrush.cs

示例4: draw

        public void draw(Context cr)
        {
            Triangle t = model.tri;
            switch (model.alignment) {
            case ActiveTriangle.TriangleAlignment.ChaoticEvil:
                cr.SetSourceRGB (0.5, 0, 0);
                break;
            case ActiveTriangle.TriangleAlignment.TrueNeutral:
                cr.SetSourceRGB (0, 0.8, 0);
                break;
            default:
                cr.SetSourceRGB (1.0, 1.0, 0);
                break;

            }
            cr.LineWidth = 1.1;
            cr.MoveTo (t.a);
            cr.LineTo (t.b);
            cr.MoveTo (t.b);
            cr.LineTo (t.c);
            cr.MoveTo (t.c);
            cr.LineTo (t.a);
            cr.Stroke ();

            cr.Fill();

            Tuple<PointD,PointD,PointD,PointD> points;

            points = model.getSharpestPointAndAssociatedMidpointAndDullestPoints ();
            PointD sharpest = points.Item1;
            PointD midPoint = points.Item2;

            cr.SetSourceRGB (1.0, 0.3, 0.3);
            cr.Arc (sharpest.X, sharpest.Y, 2, 0, 2 * Math.PI);
            cr.Fill ();

            cr.Arc (midPoint.X, midPoint.Y, 2, 0, 2 * Math.PI);
            cr.Fill ();
        }
开发者ID:latestversion,项目名称:projects,代码行数:39,代码来源:ActiveTriangleView.cs

示例5: FillChecks

	void FillChecks (Context cr, int x, int y, int width, int height)
	{
		int CHECK_SIZE = 32;
		
		cr.Save ();
		Surface check;
		using (var target = cr.GetTarget ()) {
			check = target.CreateSimilar (Content.Color, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
		}
		
		// draw the check
		using (Context cr2 = new Context (check)) {
			cr2.Operator = Operator.Source;
			cr2.SetSourceRGB (0.4, 0.4, 0.4);
			cr2.Rectangle (0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
			cr2.Fill ();

			cr2.SetSourceRGB (0.7, 0.7, 0.7);
			cr2.Rectangle (x, y, CHECK_SIZE, CHECK_SIZE);
			cr2.Fill ();

			cr2.Rectangle (x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE);
			cr2.Fill ();
		}

		// Fill the whole surface with the check
		SurfacePattern check_pattern = new SurfacePattern (check);
		check_pattern.Extend = Extend.Repeat;
		cr.SetSource (check_pattern);
		cr.Rectangle (0, 0, width, height);
		cr.Fill ();

		check_pattern.Dispose ();
		check.Dispose ();
		cr.Restore ();
	}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:36,代码来源:CairoSample.cs

示例6: DrawVertexStructure

 public static void DrawVertexStructure(VertexStructure vs, Context cr)
 {
     VertexStructure head = vs;
     int i = 0;
     do {
         cr.MoveTo (vs.v);
         cr.SetSourceRGB (0, 0, 0.8);
         cr.Arc (vs.v.X, vs.v.Y, 2, 0, 2 * Math.PI);
         cr.Fill ();
         cr.LineWidth = 1;
         cr.MoveTo (vs.v);
         cr.LineTo(vs.next.v);
         cr.Stroke();
         vs = vs.next;
         //Logger.Log("Meh..." + i);
         i++;
     } while(!ReferenceEquals(vs,head));
 }
开发者ID:latestversion,项目名称:projects,代码行数:18,代码来源:Drawer.cs

示例7: Draw

		public static void Draw(Context grw, LineElement line)
		{
			if (line.Foregraund != null) {
				grw.SetSourceRGB (
					line.Foregraund.Red, 
					line.Foregraund.Green, 
					line.Foregraund.Blue);
			}

			grw.MoveTo(
				line.Start.GeometryX, 
				line.Start.GeometryY);
			grw.LineTo(
				line.End.GeometryX, 
				line.End.GeometryY);    

			grw.Stroke();
		}
开发者ID:jdpillon,项目名称:ArduinoLadder,代码行数:18,代码来源:LineBrush.cs

示例8: Draw

		public static void Draw (Context grw, ArcElement arc)
		{
			if (arc.Foregraund != null) {
				grw.SetSourceRGB (
					arc.Foregraund.Red, 
					arc.Foregraund.Green, 
					arc.Foregraund.Blue);
			}

			grw.Arc (
				arc.Center.GeometryX, 
				arc.Center.GeometryY, 
				arc.GeometryRadius, 
				arc.ArcStart, 
				arc.ArcStop);

			grw.Stroke ();
		}
开发者ID:jdpillon,项目名称:ArduinoLadder,代码行数:18,代码来源:ArcBrush.cs

示例9: CellRendererSurface

        public CellRendererSurface(int width, int height)
        {
            // TODO: Respect cell padding (Xpad and Ypad).
            SetFixedSize (width, height);

            transparent = new Cairo.ImageSurface (Cairo.Format.ARGB32, width, height);
            Cairo.Color gray = new Cairo.Color (.75, .75, .75);

            // Create checkerboard background
            int grid_width = 4;

            using (Cairo.Context g = new Cairo.Context (transparent)) {
                g.SetSourceRGB (1, 1, 1);
                g.Paint ();

                for (int y = 0; y < height; y += grid_width)
                    for (int x = 0; x < width; x += grid_width)
                        if ((x / grid_width % 2) + (y / grid_width % 2) == 1)
                            g.FillRectangle (new Cairo.Rectangle (x, y, grid_width, grid_width), gray);
            }
        }
开发者ID:CiprianKhlud,项目名称:Pinta,代码行数:21,代码来源:CellRendererSurface.cs

示例10: Draw

		public static void Draw(Context grw, Connector con)
		{
			var c = con.Selected ? AppController.Instance.Config.SelectedConnectorColor : 
				!con.ConnectedTo.Any() ? 
				con.Foregraund : 
				AppController.Instance.Config.ConnectedColor;

			if ( c != null) {
				grw.SetSourceRGB (
					c.Red, 
					c.Green, 
					c.Blue);
			}

			grw.Arc (
				con.Center.GeometryX, 
				con.Center.GeometryY, 
				con.GeometryRadius, 
				0, 2 * Math.PI);

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

示例11: NewDocument

        public Document NewDocument(Gdk.Size imageSize, bool transparent)
        {
            Document doc = CreateAndActivateDocument (null, imageSize);
            doc.Workspace.CanvasSize = imageSize;

            // Start with an empty white layer
            Layer background = doc.AddNewLayer (Catalog.GetString ("Background"));

            if (!transparent) {
                using (Cairo.Context g = new Cairo.Context (background.Surface)) {
                    g.SetSourceRGB (1, 1, 1);
                    g.Paint ();
                }
            }

            doc.Workspace.History.PushNewItem (new BaseHistoryItem (Stock.New, Catalog.GetString ("New Image")));
            doc.IsDirty = false;

            PintaCore.Actions.View.ZoomToWindow.Activate ();

            return doc;
        }
开发者ID:RudoCris,项目名称:Pinta,代码行数:22,代码来源:WorkspaceManager.cs

示例12: removeDotsFromScreen

        protected void removeDotsFromScreen()
        {
            //Redraw all of the grid
            if (clear) {
                using (Context ctx = new Context (surface)) {

                    //Set Background Color
                    ctx.SetSourceRGB (0, 0, 0);
                    ctx.Rectangle (0, 0, 500, 500);
                    ctx.Fill ();

                    //Draw Axis Lines
                    for (int i = 0; i < (int)(divisions); i++) {
                        float curX = Math.Abs (param_Min_x) + Math.Abs (param_Max_x);

                        float divCount = (500) / divisions;
                        divCount *= i;

                        curX = divCount;

                        //If Middle Color Green
                        if (i == ((int)divisions / 2)) {
                            R = 0;
                            G = 1;
                            B = 0;
                        } else {
                            R = 0.5F;
                            G = 0.5F;
                            B = 0.5F;
                        }
                        //Draw Vertical Lines
                        DrawLine (ctx, new PointD ((int)(curX), 0), new PointD ((int)(curX), 500));

                        //Draw Horizontal Lines
                        DrawLine (ctx, new PointD (0, (int)(curX)), new PointD (500, (int)(curX)));
                    }
                }
                clear = false;
                dArea.QueueDraw ();
            }
        }
开发者ID:justingruber,项目名称:Protractor,代码行数:41,代码来源:Launcher.cs

示例13: DrawSingle

        public void DrawSingle(Complex[] points)
        {
            N = points.Length;
            using (Context context = new Context(Surface)) {
                double min = double.PositiveInfinity, max = double.NegativeInfinity, val;
                for (int i = 0; i < points.Length; i++) {
                    val = _valueExtractor (points [i]) * 1.2;
                    if(val < min) {
                        min = val;
                    }
                    if(val > max) {
                        max = val;
                    }
                }
                DrawAxes (context, min, max);
                context.SetSourceRGB (0.0, 0.0, 1.0);

                for (int i = 0; i < points.Length; i++) {
                    DrawPoint (context, i, _valueExtractor(points [i]));
                }
            }

            DrawExpose (null, null);
        }
开发者ID:codingcave,项目名称:CoupledOdeViewer,代码行数:24,代码来源:ValueSurfaceItem.cs

示例14: DrawHistArea

 private void DrawHistArea(Context context, double xl, double yl, int i, int j, double value)
 {
     Color c = HistColor (value);
     context.SetSourceRGB (c.R, c.G, c.B);
     context.MoveTo ((int)(j * xl + 50), (int)(i * yl));
     context.LineTo ((int)((j + 1) * xl + 50), (int)(i * yl));
     context.LineTo ((int)((j + 1) * xl + 50), (int)((i + 1) * yl));
     context.LineTo ((int)(j * xl + 50), (int)((i + 1) * yl));
     context.LineTo ((int)(j * xl + 50), (int)(i * yl));
     context.StrokePreserve ();
     context.MoveTo ((int)((j + .5) * xl + 50), (int)((i + .5) * yl));
     context.Fill ();
 }
开发者ID:codingcave,项目名称:CoupledOdeViewer,代码行数:13,代码来源:ValueSurfaceItem.cs

示例15: DrawAxes

        private void DrawAxes(Context context, double min, double max)
        {
            context.Rectangle(0, 0, Width, Height);
            context.SetSourceRGB(Background.R, Background.G, Background.B);
            context.Fill();

            int y = ValueToY (0);
            context.LineWidth = 1;
            context.SetSourceRGB(0.0, 0.0, 0.0);

            context.MoveTo (44, y);
            context.LineTo (Width, y);
            context.StrokePreserve();

            context.MoveTo (50, 0);
            context.LineTo (50, Height);
            context.StrokePreserve();

            KeyValuePair<double, string>[] ax = _axis.AxisSteps (min, max);

            foreach (var a in ax) {
                y = ValueToY (a.Key);
                context.MoveTo (44, y);
                context.LineTo (56, y);
                context.StrokePreserve();
                context.MoveTo (40, y - 1);
                _axis.Text (context, a.Value, HorizontalTextAlignment.Right);
            }
        }
开发者ID:codingcave,项目名称:CoupledOdeViewer,代码行数:29,代码来源:ValueSurfaceItem.cs


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