Cairo.Context.Rotate C# (CSharp) Метод

Rotate() публичный Метод

public Rotate ( double angle ) : void
angle double
Результат void
        public void Rotate(double angle)
        {
            CheckDisposed ();
            NativeMethods.cairo_rotate (handle, angle);
        }

Usage Example

Пример #1
0
        /// <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));
        }
All Usage Examples Of Cairo.Context::Rotate