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


C# Cairo.Rotate方法代码示例

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


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

	static void draw (Cairo.Context gr, int width, int height)
	{
		int w, h;
		ImageSurface image;
		
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
				
		image = new ImageSurface ("data/e.png");
		w = image.Width;
		h = image.Height;
		
		gr.Translate (0.5, 0.5);
		gr.Rotate (45* M_PI/180);
		gr.Scale  (1.0/w, 1.0/h);
		gr.Translate (-0.5*w, -0.5*h);
		
		image.Show (gr, 0, 0);
		image.Destroy ();
	}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:20,代码来源:image.cs

示例3: draw

	static void draw (Cairo.Context gr, int width, int height)
	{
		int w, h;
		ImageSurface image;
		Matrix matrix;
		SurfacePattern pattern;
		
		gr.Scale (width, height);
		gr.LineWidth = 0.04;

		image = new ImageSurface ("data/e.png");
		w = image.Width;
		h = image.Height;
		
		pattern = new SurfacePattern (image);
		pattern.Extend = Cairo.Extend.Repeat;
		
		gr.Translate (0.5, 0.5);
		gr.Rotate (M_PI / 4);
		gr.Scale (1 / Math.Sqrt (2), 1 / Math.Sqrt (2));
		gr.Translate (- 0.5, - 0.5);
		
		matrix = new Matrix ();
		matrix.InitScale (w * 5.0, h * 5.0);
		
		pattern.Matrix = matrix;
		
		gr.Pattern = pattern;
		
		gr.Rectangle ( new PointD (0, 0),
			       1.0, 1.0);
		gr.Fill ();
		
		pattern.Destroy ();
		image.Destroy();
	}
开发者ID:nlhepler,项目名称:mono,代码行数:36,代码来源:image_pattern.cs

示例4: DrawBuildEffect

		void DrawBuildEffect (Cairo.Context context, Gdk.Rectangle area, double progress, double opacity)
		{
			context.Save ();
			LayoutRoundedRectangle (context, area);
			context.Clip ();

			Gdk.Point center = new Gdk.Point (area.Left + 19, (area.Top + area.Bottom) / 2);
			context.Translate (center.X, center.Y);
			var circles = new [] {
				new { Radius = 200, Thickness = 12, Speed = 1, ArcLength = Math.PI * 1.50 },
				new { Radius = 195, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.50 },
				new { Radius = 160, Thickness = 17, Speed = 3, ArcLength = Math.PI * 0.75 },
				new { Radius = 200, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.25 },
				new { Radius = 240, Thickness = 12, Speed = 3, ArcLength = Math.PI * 1.50 },
				new { Radius = 160, Thickness = 17, Speed = 3, ArcLength = Math.PI * 0.75 },
				new { Radius = 200, Thickness = 15, Speed = 2, ArcLength = Math.PI * 0.25 },
				new { Radius = 215, Thickness = 20, Speed = 2, ArcLength = Math.PI * 1.25 }
			};

			double zmod = 1.0d;
			double zporg = progress;
			foreach (var arc in circles) {
				double zoom = 1.0d;
				zoom = (double) Math.Sin (zporg * Math.PI * 2 + zmod);
				zoom = ((zoom + 1) / 6.0d) + .05d;

				context.Rotate (Math.PI * 2 * progress * arc.Speed);
				context.MoveTo (arc.Radius * zoom, 0);
				context.Arc (0, 0, arc.Radius * zoom, 0, arc.ArcLength);
				context.LineWidth = arc.Thickness * zoom;
				context.Color = CairoExtensions.ParseColor ("B1DDED", 0.35 * opacity);
				context.Stroke ();
				context.Rotate (Math.PI * 2 * -progress * arc.Speed);

				progress = -progress;

				context.Rotate (Math.PI * 2 * progress * arc.Speed);
				context.MoveTo (arc.Radius * zoom, 0);
				context.Arc (0, 0, arc.Radius * zoom, 0, arc.ArcLength);
				context.LineWidth = arc.Thickness * zoom;
				context.Stroke ();
				context.Rotate (Math.PI * 2 * -progress * arc.Speed);

				progress = -progress;

				zmod += (float)Math.PI / circles.Length;
			}

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

示例5: DrawShape

		private void DrawShape (Cairo.Context g, int width, int height)
		{
			int inner_x = radius + border + inner;
			int cx = Center.X;
			int cy = Center.Y;
			
			g.Operator = Operator.Source;
			g.Source = new SolidPattern (new Cairo.Color (0,0,0,0));
			g.Rectangle (0, 0, width, height);
			g.Paint ();

			g.NewPath ();
			g.Translate (cx, cy);
			g.Rotate (angle);
			
			g.Source = new SolidPattern (new Cairo.Color (0.2, 0.2, 0.2, .6));
			g.Operator = Operator.Over;
			g.Rectangle (0, - (border + inner), inner_x, 2 * (border + inner));
			g.Arc (inner_x, 0, inner + border, 0, 2 * Math.PI);
			g.Arc (0, 0, radius + border, 0, 2 * Math.PI);
			g.Fill ();

			g.Source = new SolidPattern (new Cairo.Color (0, 0, 0, 1.0));
			g.Operator = Operator.DestOut;
			g.Arc (inner_x, 0, inner, 0, 2 * Math.PI);
#if true
			g.Fill ();
#else
			g.FillPreserve ();

			g.Operator = Operator.Over;
			RadialGradient rg = new RadialGradient (inner_x - (inner * 0.3), inner * 0.3 , inner * 0.1, inner_x, 0, inner);
			rg.AddColorStop (0, new Cairo.Color (0.0, 0.2, .8, 0.5)); 
			rg.AddColorStop (0.7, new Cairo.Color (0.0, 0.2, .8, 0.1)); 
			rg.AddColorStop (1.0, new Cairo.Color (0.0, 0.0, 0.0, 0.0));
			g.Source = rg;
			g.Fill ();
			rg.Destroy ();
#endif
			g.Operator = Operator.Over;
			g.Matrix = new Matrix ();
			g.Translate (cx, cy);
			if (source != null)
				SetSourcePixbuf (g, source, -source.Width / 2, -source.Height / 2);

			g.Arc (0, 0, radius, 0, 2 * Math.PI);
			g.Fill ();

			if (overlay != null) {
				SetSourcePixbuf (g, overlay, -overlay.Width / 2, -overlay.Height / 2);
				g.Arc (0, 0, radius, angle, angle + Math.PI);
				g.ClosePath ();
				g.FillPreserve ();
				g.Source = new SolidPattern (new Cairo.Color (1.0, 1.0, 1.0, 1.0));
				g.Stroke ();
			}
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:57,代码来源:Loupe.cs

示例6: rotateContext

 protected void rotateContext(Cairo.Context context, Direction direction)
 {
     switch (direction) {
     case Direction.Down:
         context.Rotate (Math.PI);
         context.Translate (- fieldSize, - fieldSize);
         break;
     case Direction.Right:
         context.Rotate (Math.PI / 2);
         context.Translate (0, - fieldSize);
         break;
     case Direction.Left:
         context.Rotate (3 * Math.PI / 2);
         context.Translate (- fieldSize, 0);
         break;
     }
 }
开发者ID:Teyras,项目名称:Bounce,代码行数:17,代码来源:BoardRenderer.cs

示例7: Draw

        /// <summary>
        /// Draws this shape using the specified Cairo.Context
        /// </summary>
        /// <param name="cx">
        /// The context to use for drawing
        /// A <see cref="Cairo.Context"/>
        /// </param>
        public virtual void Draw(Cairo.Context cx)
        {
            // start by drawing the unrotated selection-rectangle
            if(this.Selected)
            {
                cx.Save();

                cx.Translate(this.Position.X, this.Position.Y);

                /*cx.Scale(this.Size.Width / this.svgHandle.Dimensions.Width,
                     this.Size.Height / this.svgHandle.Dimensions.Height);*/

                /*cx.Translate(-this.svgHandle.Dimensions.Width / 2,
                         -this.svgHandle.Dimensions.Height / 2);*/

                // leave a small offset of 3 on every side of the rectangle
                // simply looks neater
                DrawRoundedRectangle(cx,
                                     this.Boundaries.X - 3,
                                     this.Boundaries.Y - 3,
                                     this.Boundaries.Width + 6,
                                     this.Boundaries.Height + 6,
                                     7);

                // #b5b7b4 - light grey (meego palette)
                //cx.Color = new Color(0.7, 0.71, 0.7, 0.3);
                //cx.Color = new Color(0.7, 0.71, 0.7, 0.5);
                cx.Color = Shape.SelectionColor;
                cx.Fill();

                cx.Restore();
            }

            cx.Save();

            cx.Translate(this.Position.X, this.Position.Y);

            // not well thought, but it works, needs refinements.
            switch(this.flipMode)
            {
                case FlipMode.Horizontal:
                    cx.Scale(-this.Size.Width / this.svgHandle.Dimensions.Width,
                         	 this.Size.Height / this.svgHandle.Dimensions.Height);
                    break;
                case FlipMode.Vertical:
                    cx.Scale(this.Size.Width / this.svgHandle.Dimensions.Width,
                         	 -this.Size.Height / this.svgHandle.Dimensions.Height);
                    break;
                case FlipMode.None:
                    cx.Scale(this.Size.Width / this.svgHandle.Dimensions.Width,
                         	 this.Size.Height / this.svgHandle.Dimensions.Height);
                    break;
                default:
                    cx.Scale(-this.Size.Width / this.svgHandle.Dimensions.Width,
                             -this.Size.Height / this.svgHandle.Dimensions.Height);
                    break;
            }

            //TODO: MAYBE make the rotation depend on the FlipMode
            cx.Rotate(this.Rotation);
            cx.Translate(-this.svgHandle.Dimensions.Width / 2,
                         -this.svgHandle.Dimensions.Height / 2);

            // for debugging purposes
            /*cx.Rectangle(0, 0, this.svgHandle.Dimensions.Width, this.svgHandle.Dimensions.Height);
            cx.Color = new Color(200, 100, 100, 100);
            cx.Fill();*/

            this.svgHandle.RenderCairo(cx);

            cx.Restore();
        }
开发者ID:physalis,项目名称:MeeGen,代码行数:79,代码来源:Shape.cs


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