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


C# Cairo.SetSourceRGB方法代码示例

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


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

示例1: Draw

        /// <summary>
        /// Draw the robot taking into account the center x and y position of the map which
        /// will be different from the true center x and y positions on the drawing context.
        /// This method will result in a red wheeled robot with black tyres being drawn at
        /// the robots location on the map.
        /// 
        /// The scale value is currently unused but it could be useful if the map was scaled
        /// in some way for example a mini-map may be 10 times smaller than the original 
        /// results in 1:10 scale robot.
        /// </summary>
        /// <param name="cairoContext">Cairo context to draw to (assuming a map).</param>
        /// <param name="centerX">Center x position of map to draw onto.</param>
        /// <param name="centerY">Center y position of map to draw onto.</param>
        /// <param name="scale">Scale currently unused.</param>
        public void Draw(Cairo.Context cairoContext, int centerX, int centerY, double scale)
        {
            // Scale up to centimeters.
            int width = (int)(robot.Width * 100);
            int height = (int)(robot.Height * 100);
            int x = (int)(robot.X * 100);
            int y = (int)(robot.Y * 100);

            // Set a red colour.
            cairoContext.SetSourceRGB(255, 0, 0);

            cairoContext.LineWidth = 1.0;
            cairoContext.LineCap = LineCap.Butt;

            cairoContext.Translate (centerX + x, centerY - y);
            cairoContext.Rotate (relativeRotation); // Rotate the robot based on its orientation in radians.

            // Draw the robot as a triangle.
            cairoContext.MoveTo (0, -height / 2);
            cairoContext.LineTo (-width / 2, height / 2);
            cairoContext.LineTo (width / 2, height / 2);
            cairoContext.LineTo (0, -height / 2);
            cairoContext.Stroke ();

            // Reset the drawing context.
            cairoContext.Rotate (-relativeRotation);
            cairoContext.Translate (-(centerX + x), -(centerY - y));
        }
开发者ID:abdulrahman-alhemmy,项目名称:slambot,代码行数:42,代码来源:RobotView.cs

示例2: draw

 public void draw(Cairo.Context cr)
 {
     cr.MoveTo (position);
     cr.SetSourceRGB (0, 1.0, 0);
     cr.Arc (position.X, position.Y, 5, 0, 2 * Math.PI);
     cr.Fill ();
 }
开发者ID:latestversion,项目名称:projects,代码行数:7,代码来源:Player.cs

示例3: Draw

        /// <summary>
        /// Draw the specified cairoContext, centerX, centerY and scale.
        /// </summary>
        /// <param name="cairoContext">Cairo context.</param>
        /// <param name="centerX">Center x.</param>
        /// <param name="centerY">Center y.</param>
        /// <param name="scale">Scale.</param>
        public void Draw(Cairo.Context cairoContext, int centerX, int centerY, double scale)
        {
            cairoContext.SetSourceRGB (0, 0, 200);
            cairoContext.LineWidth = 1.0;
            cairoContext.LineCap = LineCap.Butt;

            //cairoContext.MoveTo (OriginalX, -OriginalY);
            //int x = centerX;

            //Console.WriteLine ("point: " + (robot.PathPointList [robot.PathPointList.Count-1] [1]*100));

            //if (30 <= (robot.PathPointList [robot.PathPointList.Count - 1] [1] * 100))
            //{
            //robot.Halt ();
            //Console.WriteLine ("\n\n Has Gone 30cm \n\n");
            //}

            for (int i = 1; i < robot.PathPointList.Count; i++)
            {
                cairoContext.MoveTo (centerX + (robot.PathPointList [i - 1] [0] * 100), centerY - (robot.PathPointList [i - 1] [1] * 100));
                cairoContext.LineTo (centerX + (robot.PathPointList [i] [0] * 100), centerY - (robot.PathPointList [i] [1] * 100));
                //	Console.WriteLine (path[0]*100+" , "+ path[1]*100);
                cairoContext.Stroke ();
            }

            foreach (double[] path in robot.PathPointList)
            {
                //cairoContext.MoveTo (centerX - (path[0] * 100), centerY - (path[1] * 100));
            }
        }
开发者ID:abdulrahman-alhemmy,项目名称:slambot,代码行数:37,代码来源:PathView.cs

示例4: Draw

        private void Draw(Cairo.Context cr, int width, int heigth)
        {
            foreach (var path in pathPosition.Keys)
            {
                var pPosition = pathPosition[path];
                var begin = pPosition.Item1;
                var end = pPosition.Item2;

                cr.SetSourceRGB(1, 1, 1);
                cr.MoveTo(begin.X, begin.Y);
                cr.LineTo(end.X, end.Y);
                cr.Stroke();
                cr.SetSourceRGB(0, 0, 0);
            }

            foreach (var path in pathPosition.Keys)
            {
                var pPosition = pathPosition[path];
                var begin = pPosition.Item1;
                var end = pPosition.Item2;

                if (path is BlockingPath)
                {
                    var blockingPath = path as BlockingPath;

                    if (blockingPath.IsBlocked)
                    {
                        cr.SetSourceRGB(1, 0, 0);
                    }
                    else
                    {
                        cr.SetSourceRGB(0, 1, 0);
                    }

                    cr.Rectangle(new Cairo.Rectangle(end.X - 6, end.Y - 6, 12, 12));
                    cr.Fill();
                    cr.SetSourceRGB(0, 0, 0);
                }
                else if (path is SourcePath)
                {
                    var sourcePath = path as SourcePath;
                    cr.MoveTo(begin.X, begin.Y);
                    cr.TextPath(sourcePath.Queue.ToString());
                    cr.Fill();
                }

                foreach (var vehicle in path.VehiclePosition.Keys)
                {
                    var position = path.VehiclePosition[vehicle];
                    var r = position / path.Length;
                    var x = begin.X + (end.X - begin.X) * r;
                    var y = begin.Y + (end.Y - begin.Y) * r;

                    cr.Arc(x, y, 5, 0, 2 * Math.PI);
                    cr.Fill();
                }
            }

            cr.Stroke();
        }
开发者ID:gumik,项目名称:VSTS,代码行数:60,代码来源:TrafficControl.cs

示例5: draw

 public void draw(Cairo.Context cr)
 {
     if (!canSeePlayer) {
         return;
     }
     cr.MoveTo (position);
     cr.SetSourceRGB (1.0, 0.0, 0);
     cr.Arc (position.X, position.Y, 5, 0, 2 * Math.PI);
     cr.Fill ();
 }
开发者ID:latestversion,项目名称:projects,代码行数:10,代码来源:Ghost.cs

示例6: draw

        public void draw(Cairo.Context cr)
        {
            cr.LineWidth = 3;
            cr.SetSourceRGB(0, 0.9, 0.0);

            //cr.Translate (l1.P1.X, l1.P1.Y);
            cr.MoveTo(position);

            cr.LineTo (position.X + width, position.Y);
            cr.LineTo (position.X + width, position.Y + height);
            cr.LineTo (position.X, position.Y + height);
            cr.LineTo (position.X, position.Y);

            cr.Stroke ();
        }
开发者ID:latestversion,项目名称:projects,代码行数:15,代码来源:Application.cs

示例7: DrawBackground

		public override void DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
		{
			int markerStart = Offset;
			int markerEnd = EndOffset;

			double @from;
			double to;
			var startXPos = metrics.TextRenderStartPosition;
			var endXPos = metrics.TextRenderEndPosition;
			var y = metrics.LineYRenderStartPosition;
			if (markerStart < startOffset && endOffset < markerEnd) {
				@from = startXPos;
				to = endXPos;
			} else {
				int start = startOffset < markerStart ? markerStart : startOffset;
				int end = endOffset < markerEnd ? endOffset : markerEnd;

				uint curIndex = 0, byteIndex = 0;
				TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);

				int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;

				@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

				TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
				x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;

				to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
			}

			@from = Math.Max (@from, editor.TextViewMargin.XOffset);
			to = Math.Max (to, editor.TextViewMargin.XOffset);
			if (@from <= to) {
				if (metrics.TextEndOffset < markerEnd)
					to = metrics.WholeLineWidth + metrics.TextRenderStartPosition;
				var c1 = editor.Options.GetColorStyle ().PlainText.Background;
				var c2 = editor.Options.GetColorStyle ().SelectedText.Background;
				cr.SetSourceRGB ((c1.R + c2.R) / 2, (c1.G + c2.G) / 2, (c1.B + c2.B) / 2);
				cr.Rectangle (@from, y, to - @from, metrics.LineHeight);
				cr.Fill ();
			}
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:42,代码来源:SearchInSelectionMarker.cs

示例8: Draw

        /// <summary>
        /// Draw every landmark contained within this class.
        /// </summary>
        /// <param name="cairoContext">Cairo context.</param>
        /// <param name="centerX">Center x.</param>
        /// <param name="centerY">Center y.</param>
        /// <param name="scale">Scale currently unused.</param>
        public void Draw(Cairo.Context cairoContext, int centerX, int centerY, double scale/*, Landmark[] a*/)
        {
            cairoContext.SetSourceRGB (0, 255, 0);

            cairoContext.LineWidth = 1.0;
            cairoContext.LineCap = LineCap.Butt;

            /*for (int i = 0; i < a.Length; i++) {
                // Draw the slope.
                cairoContext.MoveTo (centerX + ((a[i].a / -a[i].b) * 100), centerY);
                cairoContext.LineTo (centerX, centerY - (a[i].b * 100));

                // Draw the line.
                //cairoContext.MoveTo (centerX - (landmark.x1y1[0] * 100), centerY - (landmark.x1y1[1] * 100));
                //cairoContext.LineTo (centerX - (landmark.x2y2[0] * 100), centerY - (landmark.x2y2[1] * 100));

                cairoContext.Stroke ();

            }*/

            foreach (Landmark landmark in landmarks)
            {

                // Draw the slope.
                //cairoContext.MoveTo (centerX + (slope * 100), centerY);
                //cairoContext.LineTo (centerX, centerY - (landmark.b * 100));

                // Draw the real line.
                double x1 = (((-centerY) / 100) - landmark.b) / landmark.a;
                double x2 = (((centerY) / 100) - landmark.b) / landmark.a;

                cairoContext.MoveTo (centerX + (-x1 * 100), centerY * 2);
                cairoContext.LineTo (centerX - (x2 * 100), 0);

                // Draw the length of the line.
                //cairoContext.MoveTo (centerX - (landmark.x1y1[0] * 100), centerY - (landmark.x1y1[1] * 100));
                //cairoContext.LineTo (centerX - (landmark.x2y2[0] * 100), centerY - (landmark.x2y2[1] * 100));

                cairoContext.Stroke ();
            }
        }
开发者ID:abdulrahman-alhemmy,项目名称:slambot,代码行数:48,代码来源:LandmarkView.cs

示例9: DrawRoundedRectangle

		void DrawRoundedRectangle (Cairo.Context c, Cairo.Rectangle rect)
		{
			double x = rect.X;
			double y = rect.Y;
			double width = rect.Width;
			double height = rect.Height;
			double radius = 5;
			
			c.MoveTo (x, y + radius);
			c.Arc (x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
			c.LineTo (x + width - radius, y);
			c.Arc (x + width - radius, y + radius, radius, -Math.PI / 2, 0);
			c.LineTo (x + width, y + height - radius);
			c.Arc (x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
			c.LineTo (x + radius, y + height);
			c.Arc (x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
			c.ClosePath ();
			
			c.SetSourceRGB (161 / 255.0, 40 / 255.0, 48 / 255.0);
			c.Fill ();
		}
开发者ID:Chertolom,项目名称:monodevelop,代码行数:21,代码来源:SplashScreen.cs

示例10: DrawVersionNumber

		void DrawVersionNumber (Cairo.Context c, ref Cairo.PointD bottomRight, string text)
		{
			c.SelectFontFace (SplashFontFamily, Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
			c.SetFontSize (SplashFontSize);

			var extents = c.TextExtents (text);
			c.MoveTo (bottomRight.X - extents.Width - 1, bottomRight.Y - extents.Height);

			c.SetSourceRGB (1, 1, 1);
			c.ShowText (text);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:11,代码来源:SplashScreen.cs

示例11: DrawRectangle

		void DrawRectangle (Cairo.Context c, Cairo.Rectangle rect)
		{
			double x = rect.X;
			double y = rect.Y;
			double width = rect.Width;
			double height = rect.Height;

			c.Rectangle (x, y, width, height);
			c.SetSourceRGB (0, 0, 0);
			c.Fill ();
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:11,代码来源:SplashScreen.cs

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

示例13: OnDrawn

 protected override bool OnDrawn(Cairo.Context cr)
 {
     cr.Save ();
     cr.SetSourceRGB (0.0, 0.0, 0.0);
     cr.Rectangle (0, 0, Allocation.Width, Allocation.Height);
     cr.Fill ();
     cr.Restore ();
     return base.OnDrawn (cr);
 }
开发者ID:knocte,项目名称:banshee,代码行数:9,代码来源:FullscreenWindow.cs

示例14: DrawLabel

        /// <summary>
        /// Draws the label.
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="bordertype">Bordertype.</param>
        /// <param name="pin">Pin.</param>
        /// <param name="xpos">Xpos.</param>
        /// <param name="ypos">Ypos.</param>
        private static void DrawLabel(Cairo.Context context, BorderType bordertype, IPin pin, int xpos = 0, int ypos = 0)
        {
            const int widht = 100;
            const int height = BoldHeight;
            const int fontsize = 12;
            //Rect
            context.Rectangle (xpos, ypos, widht, 26);
            context.SetSourceRGBA (BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A);
            context.Fill ();

            string displaytext = pin.Name;

            if (displaytext.Length > 12) {
                displaytext = displaytext.Substring (0, 12);
                displaytext += "...";
            }

            if (bordertype == BorderType.Line) {
                //Border
                context.SetSourceRGB (0, 0, 0);
                context.LineWidth = .5;
                context.Rectangle (xpos, ypos, widht, height);
                context.Stroke ();
            }

            //ColorFlag
            context.Rectangle (xpos, ypos, 5, height);
            context.SetSourceRGB (pin.PlotColor.Red, pin.PlotColor.Green, pin.PlotColor.Blue);
            context.Fill ();

            //Number
            context.SetSourceRGB (0, 0, 0);
            context.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold);
            context.SetFontSize (fontsize);
            context.MoveTo (xpos + 5, ypos + fontsize);
            context.ShowText (pin.DisplayNumberShort);

            context.MoveTo (xpos + 5, ypos + fontsize * 2);
            context.ShowText (displaytext);
        }
开发者ID:Onkeliroh,项目名称:DSA,代码行数:48,代码来源:MCUDisplayHelper.cs

示例15: RenderBackground

		void RenderBackground (Cairo.Context context, Gdk.Rectangle region)
		{
			region.Inflate (-Padding, -Padding);
			context.RenderOuterShadow (new Gdk.Rectangle (region.X + 10, region.Y + 15, region.Width - 20, region.Height - 15), Padding, 3, .25);

			context.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 5);
			using (var lg = new LinearGradient (0, region.Y, 0, region.Bottom)) {
				lg.AddColorStop (0, new Cairo.Color (.36, .53, .73));
				lg.AddColorStop (1, new Cairo.Color (.21, .37, .54));

				context.SetSource (lg);
				context.FillPreserve ();
			}

			context.LineWidth = 1;
			context.SetSourceRGB (.29, .47, .67);
			context.Stroke ();
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:18,代码来源:WelcomePageFirstRun.cs


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