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


C# Context.Rotate方法代码示例

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


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

示例1: onDraw

        protected override void onDraw(Context gr)
        {
            base.onDraw (gr);

            Rectangle r = ClientRectangle;
            Point m = r.Center;

            gr.Save ();

            double aUnit = Math.PI*2.0 / (Maximum - Minimum);
            gr.Translate (m.X, r.Height *1.1);
            gr.Rotate (Value/4.0 * aUnit - Math.PI/4.0);
            gr.Translate (-m.X, -m.Y);

            gr.LineWidth = 2;
            Foreground.SetAsSource (gr);
            gr.MoveTo (m.X,0.0);
            gr.LineTo (m.X, -m.Y*0.5);
            gr.Stroke ();

            gr.Restore ();
        }
开发者ID:jpbruyere,项目名称:Crow,代码行数:22,代码来源:AnalogMeter.cs

示例2: image

		public void image(Context cr, int width, int height)
		{
			Normalize (cr, width, height);
			ImageSurface image = new ImageSurface ("data/romedalen.png");
			int w = image.Width;
			int h = image.Height;

			cr.Translate (0.5, 0.5);
			cr.Rotate (45* Math.PI/180);
			cr.Scale  (1.0/w, 1.0/h);
			cr.Translate (-0.5*w, -0.5*h);

			cr.SetSourceSurface (image, 0, 0);
			cr.Paint ();
			image.Destroy ();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:16,代码来源:Snippets.cs

示例3: PaintEdges

 private void PaintEdges(Context ctx, int w, int h, IEnumerable<NotatedEdge> edges)
 {
     PointD pc, pd;
     foreach(NotatedEdge edge in edges) {
         PointD pa = new PointD(w*edge.Item1.X, h*edge.Item1.Y);
         PointD pb = new PointD(w*edge.Item2.X, h*edge.Item2.Y);
         Utils.CutTowardsCenter(pa, pb, AlgorithmRadius, out pc, out pd);
         double dxr = pc.X-pd.X;
         double dyr = pc.Y-pd.Y;
         double r = Math.Sqrt(dxr*dxr+dyr*dyr);
         ctx.MoveTo(pc);
         ctx.LineTo(pd);
         ctx.Stroke();
         ctx.Save();
         ctx.Translate(pc.X, pc.Y);
         ctx.Rotate(Math.Atan2(pb.Y-pa.Y, pb.X-pa.X));
         double v = 0.0d;//double v = tm/e.Delay;
         foreach(EdgeNotation msg in edge.Item3) {
             TextExtents te = ctx.TextExtents(msg.Item2);
             ctx.MoveTo((msg.Item1+v)*(r-te.XAdvance), te.Height+2.0d);
             ctx.ShowText(msg.Item2);
         }
         ctx.Restore();
         ctx.Save();
         ctx.Translate(pd.X, pd.Y);
         ctx.Rotate(Math.Atan2(pa.Y-pb.Y, pa.X-pb.X));
         foreach(EdgeNotation msg in edge.Item4) {
             TextExtents te = ctx.TextExtents(msg.Item2);
             ctx.MoveTo((msg.Item1+v)*(r-te.XAdvance), te.Height+2.0d);
             ctx.ShowText(msg.Item2);
         }
         ctx.Restore();
     }
 }
开发者ID:KommuSoft,项目名称:ParVis,代码行数:34,代码来源:BlueprintParallelStatePainter.cs

示例4: MakeAnalogIcon

		void MakeAnalogIcon (Context cr, int size)
		{
			int center = size / 2;
			int radius = center;
			
			RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-drop-shadow.svg"), radius * 2);
			RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-face-shadow.svg"), radius * 2);
			RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-face.svg"), radius * 2);
			RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-marks.svg"), radius * 2);
			
			cr.Translate (center, center);
			cr.Color = new Cairo.Color (.15, .15, .15);
			
			cr.LineWidth = Math.Max (1, size / 48);
			cr.LineCap = LineCap.Round;
			double minuteRotation = 2 * Math.PI * (DateTime.Now.Minute / 60.0) + Math.PI;
			cr.Rotate (minuteRotation);
			cr.MoveTo (0, radius - radius * .35);
			cr.LineTo (0, -radius * .15);
			cr.Stroke ();
			cr.Rotate (-minuteRotation);
			
			cr.Color = new Cairo.Color (0, 0, 0);
			double hourRotation = 2 * Math.PI * (DateTime.Now.Hour / (ShowMilitary ? 24.0 : 12.0)) + 
					Math.PI + (Math.PI / (ShowMilitary ? 12.0 : 6.0)) * DateTime.Now.Minute / 60.0;
			cr.Rotate (hourRotation);
			cr.MoveTo (0, radius - radius * .5);
			cr.LineTo (0, -radius * .15);
			cr.Stroke ();
			cr.Rotate (-hourRotation);
			
			cr.Translate (-center, -center);
			
			RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-glass.svg"), radius * 2);
			RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-frame.svg"), radius * 2);
		}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:36,代码来源:ClockDockItem.cs

示例5: draw

        public void draw(Context cr)
        {
            PointD p = model.position;

            cr.Save();
            cr.Translate (p.X-image.Width/2, p.Y-image.Height/2);
            cr.Rotate (model.ang);
            cr.SetSource(image);
            cr.Paint();

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

示例6: DrawOnHandPieces

        private void DrawOnHandPieces(Context cr, Position pos, bool BlackPlayer)
        {
            cr.Save();
            cr.Rectangle(0, 0, ON_HAND_AREA_WIDTH, 9 * FIELD_SIZE + 2 * FIELD_NAMING_SIZE);
            cr.Color = BorderColor;
            cr.FillPreserve();
            cr.Color = new Color(0.6, 0.5, 0.55);
            cr.LineWidth = 3;
            cr.Stroke();

            if (BlackPlayer)
            {
                cr.Translate(0, 8 * FIELD_SIZE + 2 * FIELD_NAMING_SIZE);
            }

            for (int i = 0; i < (int)PieceType.PIECE_TYPES_COUNT; i++)
            {
                int player_nr = BlackPlayer ? 0 : 1;
                if (pos.OnHandPieces[player_nr, i] != 0)
                {
                    //highlight selected piece
                    if (gi != null && gi.localPlayerMoveState != LocalPlayerMoveState.Wait
                        && gi.localPlayerMoveState != LocalPlayerMoveState.PickSource
                        && gi.GetLocalPlayerMove().OnHandPiece != PieceType.NONE
                        && gi.GetLocalPlayerMove().OnHandPiece == (PieceType)i
                        && !((gi.CurPlayer == gi.BlackPlayer) ^ BlackPlayer))
                    {
                        cr.Rectangle(0, 0, FIELD_SIZE, FIELD_SIZE);
                        cr.Color = new Color(0.8, 0.835, 0.4);
                        cr.Fill();
                    }

                    //draw piece
                    cr.Save();
                    if (!BlackPlayer)
                    {
                        cr.Rotate(180 * Math.PI / 180);
                        cr.Translate(-FIELD_SIZE, -FIELD_SIZE);
                    }
                    cr.Scale(FIELD_SIZE / PieceGraphics[i].Dimensions.Width, FIELD_SIZE / PieceGraphics[i].Dimensions.Width);
                    PieceGraphics[i].RenderCairo(cr);
                    cr.Restore();

                    //draw amount
                    cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Normal);
                    cr.SetFontSize(FIELD_SIZE / 3 * 0.9);
                    cr.Color = new Color(0, 0, 0);

                    String amount_str = "x " + pos.OnHandPieces[player_nr, i].ToString();
                    TextExtents extents = cr.TextExtents(amount_str);
                    double x = (FIELD_SIZE);
                    // - (extents.Width/2 + extents.XBearing);
                    double y = (FIELD_SIZE / 2) - (extents.Height / 2 + extents.YBearing);

                    cr.MoveTo(x, y);
                    cr.ShowText(amount_str);

                    double offset = BlackPlayer ? -FIELD_SIZE - PADDING : FIELD_SIZE + PADDING;
                    cr.Translate(0, offset);
                }
            }
            cr.Restore();
        }
开发者ID:Rootie,项目名称:KoushuShogi,代码行数:63,代码来源:ShogibanSVG.cs

示例7: RotatePng

        public static void RotatePng(ParsedPath pngPath, ImageRotation rotation)
        {
            if (rotation == ImageRotation.None)
                return;

            using (ImageSurface originalImage = new ImageSurface(pngPath))
            {
                int w;
                int h;

                if (rotation == ImageRotation.Left || rotation == ImageRotation.Right)
                {
                    w = originalImage.Height;
                    h = originalImage.Width;
                }
                else
                {
                    w = originalImage.Width;
                    h = originalImage.Height;
                }

                double[] rotationRadians = {0, -Math.PI / 2, Math.PI / 2, Math.PI };

                using (ImageSurface rotatedImage = new ImageSurface(Format.Argb32, w, h))
                {
                    using (Cairo.Context g = new Cairo.Context(rotatedImage))
                    {
                        g.Translate(rotatedImage.Width / 2.0, rotatedImage.Height / 2.0);
                        g.Rotate(rotationRadians[(int)rotation]);
                        g.Translate(-originalImage.Width / 2.0, -originalImage.Height / 2.0);

                        g.SetSourceSurface(originalImage, 0, 0);
                        g.Paint();
                    }

                    rotatedImage.WriteToPng(pngPath);
                }
            }
        }
开发者ID:dellis1972,项目名称:XnaBuildContent,代码行数:39,代码来源:ImageTools.cs

示例8: DrawShape

        void DrawShape(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.SetSource (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.SetSource (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.SetSource (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)
            CairoHelper.SetSourcePixbuf (g, source, -source.Width / 2, -source.Height / 2);

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

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

示例9: DrawMinuteHand

    /**
    Draws the minute hand of the clock.

    @param cr The context to draw on.
    @param minute The minute as an uint between 0 and 59.
      */
    void DrawMinuteHand(Context cr, uint minute)
    {
        double rot = (double)minute / 60.0;
        cr.Save ();
          cr.Rotate (rot * Math.PI * 2.0);
          cr.Rectangle (0.0, -0.05, 0.8, 0.1);
          cr.Color = new Color (0, 0, 0);
          cr.Fill ();
        cr.Restore ();
    }
开发者ID:kig,项目名称:simpleclock,代码行数:16,代码来源:simpleclock.cs

示例10: DrawHourHand

    /**
    Draws the hour hand of the clock.

    @param cr The context to draw on.
    @param hour The hour as an uint between 0 and 23.
      */
    void DrawHourHand(Context cr, uint hour)
    {
        double rot = (double)(hour % 12) / 12.0;
        cr.Save ();
          cr.Rotate (rot * Math.PI * 2.0);
          cr.Rectangle (0.0, -0.1, 0.6, 0.2);
          cr.Color = new Color (0, 0, 0);
          cr.Fill ();
        cr.Restore ();
    }
开发者ID:kig,项目名称:simpleclock,代码行数:16,代码来源:simpleclock.cs

示例11: DrawBackground

 /** FAST */
 void DrawBackground(Context cr, uint width, uint height)
 {
     cr.Save ();
       DrawClear (cr, width, height);
       double t = DateTime.Now.ToFileTime() / 1e7;
       cr.Save ();
     Color ca = Renderer.DirectoryFGColor;
     ca.A = 0.3;
     cr.Color = ca;
     cr.LineWidth = 0.5;
     cr.Translate (270, -50);
     cr.Rotate (0.15);
     for (double y=0; y<6; y++) {
     for (double i=0; i<6-y; i++) {
       cr.Save ();
         double hr = 45;
         double iscale = Math.Sin(-i/20 * Math.PI*2 + CylinderRotation);
         double xscale = Math.Cos(-i/20 * Math.PI*2 + 0.1 + CylinderRotation);
         cr.Translate (iscale * hr * 3, -100 + y*hr*(2*1.732) + hr*(i%2)*1.732);
         hr = 45;
         cr.Scale (xscale, 1);
         cr.NewPath ();
         cr.MoveTo (0, -hr);
         cr.LineTo (0.866*hr, -0.5*hr);
         cr.LineTo (0.866*hr, 0.5*hr);
         cr.LineTo (0, hr);
         cr.LineTo (-0.866*hr, 0.5*hr);
         cr.LineTo (-0.866*hr, -0.5*hr);
         cr.ClosePath ();
         cr.Color = ca;
         cr.Stroke ();
         cr.Color = Renderer.SocketColor;
         cr.Translate (0.75 * -0.866*hr, 0.75 * -0.5*hr);
         double x2 = cr.Matrix.X0, y2 = cr.Matrix.Y0;
         cr.IdentityMatrix ();
         cr.Arc (x2,y2, 1, 0, Math.PI*2);
         cr.Fill ();
       cr.Restore ();
     }
     }
     CylinderRotation += 0.02;
       cr.Restore ();
       if (CurrentDirEntry.InProgress || (t - LastProgress < 3)) {
     if (FirstProgress == 0) { FirstProgress = LastProgress = t; }
     if (CurrentDirEntry.InProgress) LastProgress = t;
     double opacity = Math.Min(3, t-FirstProgress) - Math.Max(0, t-LastProgress);
     t = (t * 0.1) % Math.PI*2;
     Color c = Renderer.RegularFileColor;
     c.A = 0.1*opacity;
     cr.Color = c;
     cr.LineWidth = 1;
     double n = 6;
     double af = Math.PI*2/n;
     double r = 400*(4.4+0.3*cosScale(opacity/3));
     for (double i=0; i<n; i++) {
       cr.Arc (-400*4, 1000/4, r, t+i*af, t+(i+0.7)*af);
       cr.Stroke ();
     }
     for (double i=0; i<n; i++) {
       cr.Arc (-400*4, 1000/4, r+5, -t+i*af, -t+(i+0.7)*af);
       cr.Stroke ();
     }
     if (CurrentDirEntry.InProgress) {
       cr.NewPath ();
         // find FSCache.LastTraversed [or ancestor] y position from model
         // draw line there
       cr.NewPath ();
     }
     LimitedRedraw = true;
       } else {
     FirstProgress = 0;
     LastProgress = 0;
       }
     cr.Restore ();
 }
开发者ID:kig,项目名称:filezoo,代码行数:76,代码来源:filezoo.cs

示例12: RenderMonthName

		void RenderMonthName (Context cr)
		{
			string month = StartDate.ToString ("MMMM").ToUpper ();
			
			using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) {
				layout.FontDescription = new Gtk.Style().FontDescription;
				layout.FontDescription.Weight = Pango.Weight.Bold;
				layout.Ellipsize = Pango.EllipsizeMode.None;
				layout.Width = Pango.Units.FromPixels (Allocation.Height);
				layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (Allocation.Height / 6);
				
				cr.Save ();
				cr.Color = new Cairo.Color (1, 1, 1, .5);
				layout.SetText (month);
				
				Pango.Rectangle inkRect, logicalRect;
				layout.GetPixelExtents (out inkRect, out logicalRect);
				double scale = Math.Min (1, Math.Min (Allocation.Height / (double) inkRect.Width, (Allocation.Width / 9.0) / (double) logicalRect.Height));
				
				cr.Rotate (Math.PI / -2.0);
				cr.MoveTo ((Allocation.Height - scale * inkRect.Width) / 2 - Allocation.Height, Allocation.Width / 9 - scale * logicalRect.Height);
				if (scale < 1)
					cr.Scale (scale, scale);
				
				Pango.CairoHelper.LayoutPath (cr, layout);
				cr.Fill ();
				cr.Restore ();
				
				layout.FontDescription.Dispose ();
				layout.Context.Dispose ();
			}
		}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:32,代码来源:CalendarPainter.cs

示例13: DrawGroup


//.........这里部分代码省略.........
                        double bandY = y1 + roundSize - 2*lineWidth - bandHeight;
                        cr.LineTo (x0 - roundSize + lineWidth05, bandY);
                        cr.LineTo (x1 + roundSize - lineWidth15, bandY);
                        linGrad = new LinearGradient (0, bandY, 0, bandY + bandHeight);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelY = bandY;
                    }

                    double frameSize = 2*lineWidth + space;
                    double availableHorizontalSpace = r.Width - 2 * frameSize;
                    if(expandButton.Visible) availableHorizontalSpace -= expandButton.WidthRequest + space;

                    cr.Save ();
                    cr.Rectangle (r.X + frameSize, labelY, availableHorizontalSpace, bandHeight);
                    cr.Clip ();

                    cr.Color = new Color(1, 1, 1);
                    Pango.CairoHelper.UpdateLayout (cr, l);
                    cr.MoveTo (r.X + frameSize + Math.Max(0, (availableHorizontalSpace - lblWidth) / 2), labelY + space);
                    Pango.CairoHelper.ShowLayout (cr, l);

                    cr.Restore();
                }
                else	// label at right or left
                {
                    double labelX;
                    double bandWidth = lblHeight + 2*space;

                    if(w.LabelPosition == Position.Left)
                    {
                        cr.Arc (x0, y1, roundSize - lineWidth05, Math.PI/2, Math.PI);
                        cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
                        double bandX = x0 - roundSize + 2*lineWidth + bandWidth;
                        cr.LineTo (bandX, y0 - roundSize + lineWidth05);
                        cr.LineTo (bandX, y1 + roundSize - lineWidth15);
                        linGrad = new LinearGradient (bandX - bandWidth, 0, bandX, 0);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelX = bandX - bandWidth - space;
                    }
                    else
                    {
                        cr.Arc (x1, y0 - lineWidth05, roundSize - lineWidth15, 3*Math.PI/2, 0);
                        cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
                        double bandX = x1 + roundSize - 2*lineWidth - bandWidth;
                        cr.LineTo (bandX, y1 + roundSize - lineWidth15);
                        cr.LineTo (bandX, y0 - roundSize + lineWidth05);
                        linGrad = new LinearGradient (bandX, 0, bandX + bandWidth, 0);
                        linGrad.AddColorStop (0.0, colorScheme.Dark);
                        linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                        cr.Pattern = linGrad;
                        cr.Fill ();
                        linGrad.Destroy ();

                        labelX = bandX + space;
                    }

                    double frameSize = 2*lineWidth + space;
                    double availableVerticalSpace = r.Height - 2 * frameSize;
                    if(expandButton.Visible) availableVerticalSpace -= expandButton.HeightRequest + space;

                    cr.Save ();
                    cr.Rectangle (labelX, r.Y + frameSize, bandWidth, availableVerticalSpace);
                    cr.Clip ();
                    cr.Rotate (-Math.PI / 2);

                    cr.Color = new Color(1, 1, 1);
                    Pango.CairoHelper.UpdateLayout (cr, l);
                    double shift = Math.Max(0, (availableVerticalSpace - lblWidth) / 2);
                    if(expandButton.Visible) shift += expandButton.HeightRequest + space;
                    cr.MoveTo (-(r.Y + r.Height - 2 * space - shift), labelX + space);
                    Pango.CairoHelper.ShowLayout (cr, l);

                    cr.Restore();
                }
            }

            cr.MoveTo (x1 + roundSize - lineWidth15, y1);
            cr.Arc (x1, y1, roundSize - lineWidth15, 0, Math.PI/2);
            cr.Arc (x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI/2, Math.PI);
            cr.Arc (x0, y0, roundSize - lineWidth05, Math.PI, 3*Math.PI/2);
            cr.Arc (x1 - lineWidth, y0, roundSize - lineWidth05, 3*Math.PI/2, 0);
            cr.LineTo (x1 + roundSize - lineWidth15, y1);
            cr.LineWidth = lineWidth;
            linGrad = new LinearGradient (0, r.Y, 0, r.Y + r.Height - lineWidth);
            linGrad.AddColorStop (0.0, ColorScheme.GetColorRelative (colorScheme.PrettyDark, 0.1));
            linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
            cr.Pattern = linGrad;
            cr.Stroke ();
            linGrad.Destroy ();
        }
开发者ID:MASGAU,项目名称:gtk-sharp-ribbon,代码行数:101,代码来源:Theme.cs

示例14: DrawPiece

        private void DrawPiece(Context cr, PieceType Piece, PieceDirection Direction, double x, double y)
        {
            int idx = (int)Piece;
            if (idx < (int)PieceType.FUHYOU || idx > (int)PieceType.OUSHOU)
                return;

            cr.Save();
            cr.Translate(x, y);
            if (Direction == PieceDirection.DOWN)
            {
                cr.Rotate(180 * Math.PI / 180);
                cr.Translate(-FIELD_SIZE,-FIELD_SIZE);
            }
            cr.Scale(FIELD_SIZE/PieceGraphics[idx].Dimensions.Width, FIELD_SIZE/PieceGraphics[idx].Dimensions.Width);
            if (idx == (int)PieceType.OUSHOU && Direction == PieceDirection.DOWN)
            {
                GyokushouGraphic.RenderCairo(cr);
            }
            else
            {
                PieceGraphics[idx].RenderCairo(cr);
            }

            cr.Restore();
        }
开发者ID:Rootie,项目名称:KoushuShogi,代码行数:25,代码来源:ShogibanSVG.cs

示例15: imagepattern

		public void imagepattern(Context cr, int width, int height)
		{
			Normalize (cr, width, height);
			
			ImageSurface image = new ImageSurface ("data/romedalen.png");
			int w = image.Width;
			int h = image.Height;

			SurfacePattern pattern = new SurfacePattern (image);
			pattern.Extend = Extend.Repeat;

			cr.Translate (0.5, 0.5);
			cr.Rotate (Math.PI / 4);
			cr.Scale (1 / Math.Sqrt (2), 1 / Math.Sqrt (2));
			cr.Translate (- 0.5, - 0.5);

			Matrix matrix = new Matrix ();
			matrix.InitScale (w * 5.0, h * 5.0);
			pattern.Matrix = matrix;

			cr.Source = pattern;

			cr.Rectangle (0, 0, 1.0, 1.0);
			cr.Fill ();

			pattern.Destroy ();
			image.Destroy ();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:28,代码来源:Snippets.cs


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