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


C# Context.Scale方法代码示例

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


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

示例1: OnTransformIp

  protected override FlowReturn OnTransformIp (Gst.Buffer buf) {
    if (!buf.IsWritable)
      return FlowReturn.Error;

    Cairo.ImageSurface img = new Cairo.ImageSurface (buf.Data, Cairo.Format.Rgb24, width, height, width*4);

    using (Cairo.Context context = new Cairo.Context (img)) {
      double dx = (double) ( (buf.Timestamp / Clock.MSecond) % 2180) / 5;
      context.Save ();
      context.Scale (width / 640.0, height / 480.0);
      context.MoveTo (300, 10 + dx);
      context.LineTo (500 - dx, 400);
      context.LineWidth = 4.0;
      context.Color = new Color (0, 0, 1.0);
      context.Stroke();
      context.Restore ();

      if (lastX != -1 && lastY != -1) {
        context.Color = new Color (1.0, 0, 0);
        context.Translate (lastX, lastY);
        context.Scale (Math.Min (width / 640.0, height / 480.0), Math.Min (width / 640.0, height / 480.0));
        context.Arc (0, 0, 10.0, 0.0, 2 * Math.PI);
        context.Fill();
      }
    }

    img.Destroy ();
    return base.OnTransformIp (buf);
  }
开发者ID:jwzl,项目名称:ossbuild,代码行数:29,代码来源:TransformSample.cs

示例2: Draw

        protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress)
        {
            cr.Color = new Color (0, 0, 0);
            if (prev != null) {
                double scale = Math.Min ((double)width/(double)prev.Width, (double)height/(double)prev.Height);
                cr.Save ();
                cr.Translate (-progress * width, 0);

                cr.Rectangle (0, 0, width, .5 * (height - scale*prev.Height));
                cr.Fill ();

                cr.Rectangle (0, height - .5 * (height - scale*prev.Height), width, .5 * (height - scale*prev.Height));
                cr.Fill ();

                cr.Rectangle (0, 0, .5 * (width - scale*prev.Width), height);
                cr.Fill ();

                cr.Rectangle (width - .5 * (width - scale*prev.Width), 0, .5 * (width - scale*prev.Width), height);
                cr.Fill ();

                cr.Rectangle (0, 0, width, height);
                cr.Scale (scale, scale);
                CairoHelper.SetSourcePixbuf (cr, prev, .5 * ((double)width/scale - prev.Width), .5 * ((double)height/scale - prev.Height));
                cr.Fill ();
                cr.Restore ();
            }
            if (next != null) {
                double scale = Math.Min ((double)width/(double)next.Width, (double)height/(double)next.Height);
                cr.Save ();
                cr.Translate (width * (1.0 - progress), 0);

                cr.Rectangle (0, 0, width, .5 * (height - scale*next.Height));
                cr.Fill ();

                cr.Rectangle (0, height - .5 * (height - scale*next.Height), width, .5 * (height - scale*next.Height));
                cr.Fill ();

                cr.Rectangle (0, 0, .5 * (width - scale*next.Width), height);
                cr.Fill ();

                cr.Rectangle (width - .5 * (width - scale*next.Width), 0, .5 * (width - scale*next.Width), height);
                cr.Fill ();

                cr.Rectangle (0, 0, width, height);
                cr.Scale (scale, scale);
                CairoHelper.SetSourcePixbuf (cr, next, .5 * ((double)width/scale - next.Width), .5 * ((double)height/scale - next.Height));
                cr.Fill ();
                cr.Restore ();
            }
        }
开发者ID:iainlane,项目名称:f-spot,代码行数:50,代码来源:PushTransition.cs

示例3: Draw

        protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress)
        {
            cr.SetSourceColor (new Color (0, 0, 0, progress));
            if (next != null) {
                double scale = Math.Min ((double)width/(double)next.Width, (double)height/(double)next.Height);
                cr.Save ();

                cr.Rectangle (0, 0, width, .5 * (height - scale*next.Height));
                cr.Fill ();

                cr.Rectangle (0, height - .5 * (height - scale*next.Height), width, .5 * (height - scale*next.Height));
                cr.Fill ();

                cr.Rectangle (0, 0, .5 * (width - scale*next.Width), height);
                cr.Fill ();

                cr.Rectangle (width - .5 * (width - scale*next.Width), 0, .5 * (width - scale*next.Width), height);
                cr.Fill ();

                cr.Rectangle (0, 0, width, height);
                cr.Scale (scale, scale);
                CairoHelper.SetSourcePixbuf (cr, next, .5 * ((double)width/scale - next.Width), .5 * ((double)height/scale - next.Height));
                cr.PaintWithAlpha (progress);
                cr.Restore ();
            }
        }
开发者ID:Yetangitu,项目名称:f-spot,代码行数:26,代码来源:Dissolve.cs

示例4: draw

	static void draw (Context cr, int width, int height)
	{
		double xc = 0.5;
		double yc = 0.5;
		double radius = 0.4;
		double angle1 = 45.0  * (Math.PI / 180.0);  // angles are specified
		double angle2 = 180.0 * (Math.PI / 180.0);  // in radians
		
		cr.Scale (width, height);
		cr.LineWidth = 0.04;

		cr.Arc (xc, yc, radius, angle1, angle2);
		cr.Stroke ();
		
		// draw helping lines
		cr.Color = new Color(1, 0.2, 0.2, 0.6);
		cr.Arc (xc, yc, 0.05, 0, 2 * Math.PI);
		cr.Fill ();
		cr.LineWidth = 0.03;
		cr.Arc (xc, yc, radius, angle1, angle1);
		cr.LineTo (new PointD (xc, yc));
		cr.Arc (xc, yc, radius, angle2, angle2);
		cr.LineTo (new PointD (xc, yc));
		cr.Stroke ();
	}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:25,代码来源:arc.cs

示例5: Draw

    void Draw(Context cr, int width, int height)
    {
        cr.LineWidth = 1.0;
        cr.Color = new Color(1.0, 1.0, 1.0);
        cr.Rectangle(0, 0, width, height);
        cr.Fill();

        cr.Save();
        cr.Scale(scale_factor, scale_factor);
        try
        {
            if(diagram != null)
            {
                DiagramRenderer dr = new DiagramRenderer(cr, width, height, diagram);
                cr.Color = new Color(0.0, 0.0, 0.0);
                dr.Render();
                dr.Draw();
            }
        }
        catch
        {
            error_counter++;
        }
        cr.Restore();
    }
开发者ID:jonasoster,项目名称:smul,代码行数:25,代码来源:Gui.cs

示例6: OvalPath

	void OvalPath (Context cr, double xc, double yc, double xr, double yr)
	{
		Matrix m = cr.Matrix;

		cr.Translate (xc, yc);
		cr.Scale (1.0, yr / xr);
		cr.MoveTo (xr, 0.0);
		cr.Arc (0, 0, xr, 0, 2 * Math.PI);
		cr.ClosePath ();

		cr.Matrix = m;
	}
开发者ID:ystk,项目名称:debian-gtk-sharp2,代码行数:12,代码来源:CairoSample.cs

示例7: Render

        public static void Render (Context cr, Rectangle box,
            double xalign, double yalign, Color innerColor, Color outerColor)
        {
            // virtual size of the figure we will draw below on the 1:1 scale
            double original_width = 8;
            double original_height = 12;

            // figure out the scale dimensions of the bounding box and the glyph
            double box_size = Math.Min (box.Width, box.Height);
            double original_size = Math.Max (original_width, original_height);

            // create a scale for the box (ratio between virtual glyph size and the box),
            // then re-scale to account for the extra size that will be added via stroke.
            // glyph_scale is the stroke width and the actual transformation size
            double box_scale = box_size / original_size;
            double glyph_scale = Math.Floor ((box_size - box_scale) / original_size);

            // compute the alignment to the pixel grid for the stroke/scale
            double pixel_align = Math.Floor (glyph_scale + 0.5) / 2.0;

            // figure out the actual size in pixels of the glyph
            double actual_width = glyph_scale * original_width + 2 * Math.Floor (pixel_align);
            double actual_height = glyph_scale * original_height + 2 * Math.Floor (pixel_align);

            // compute the offset accounting for box, grid alignment, and figure alignment
            double tx = box.X + pixel_align + Math.Round ((box.Width - actual_width) * xalign);
            double ty = box.Y + pixel_align + Math.Round ((box.Height - actual_height) * yalign);

            // save the context, and transform the current/new context
            cr.Save ();
            cr.Translate (tx, ty);
            cr.Scale (glyph_scale, glyph_scale);

            // define how the strokes look
            cr.LineWidth = 1;
            cr.LineCap = LineCap.Round;
            cr.LineJoin = LineJoin.Round;

            // inner 'b' note
            cr.Color = innerColor;
            cr.MoveTo (0, 2);
            cr.LineTo (2, 0);
            cr.Arc (4, 8, 2, Math.PI, Math.PI * 3);
            cr.Stroke ();

            // outer 'cut' circle
            cr.Color = outerColor;
            cr.Arc (4, 8, 4, Math.PI * 1.5, Math.PI * 1.12);
            cr.Stroke ();

            cr.Restore ();
        }
开发者ID:haugjan,项目名称:banshee-hacks,代码行数:52,代码来源:BansheeLineLogo.cs

示例8: DrawBasis

        public void DrawBasis(Context cr, int CubePxSize)
        {
            if (OriginalFile == null)
                return;
            if (DrawingSvg == null)
                ModifyDrawingImage();

            FrameScale = DrawingSvg.Dimensions.Width / SvgWidht;

            double ratio = CubePxSize / (BaseWidht * FrameScale);
            cr.Scale(ratio, ratio);
            cr.Translate(0.0 - ((BaseX - AddX) * FrameScale), 0.0 - ((BaseY - AddY) * FrameScale));
            DrawingSvg.RenderCairo(cr);
        }
开发者ID:QualitySolution,项目名称:CupboardDesigner,代码行数:14,代码来源:SVGHelper.cs

示例9: DrawBackground

		protected override void DrawBackground (Context context, Gdk.Rectangle region)
		{
			LayoutRoundedRectangle (context, region);
			context.Clip ();

			context.SetSourceColor (CairoExtensions.ParseColor ("D3E6FF"));
			context.Paint ();

			context.Save ();
			context.Translate (region.X + region.Width / 2.0, region.Y + region.Height);

			using (var rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) {
				var color = CairoExtensions.ParseColor ("E5F0FF");
				rg.AddColorStop (0, color);
				color.A = 0;
				rg.AddColorStop (1, color);

				context.Scale (region.Width / (double)region.Height, 1.0);
				context.SetSource (rg);
				context.Paint ();
			}

			context.Restore ();

			LayoutRoundedRectangle (context, region, -3, -3, 2);
			context.SetSourceRGBA (1, 1, 1, 0.4);
			context.LineWidth = 1;
			context.StrokePreserve ();

			context.Clip ();

			int boxSize = 11;
			int x = region.Left + (region.Width % boxSize) / 2;
			for (; x < region.Right; x += boxSize) {
				context.MoveTo (x + 0.5, region.Top);
				context.LineTo (x + 0.5, region.Bottom);
			}

			int y = region.Top + (region.Height % boxSize) / 2;
			y += boxSize / 2;
			for (; y < region.Bottom; y += boxSize) {
				context.MoveTo (region.Left, y + 0.5);
				context.LineTo (region.Right, y + 0.5);
			}

			context.SetSourceRGBA (1, 1, 1, 0.2);
			context.Stroke ();

			context.ResetClip ();
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:50,代码来源:StatusAreaBuildTheme.cs

示例10: BasicDraw

		public override void BasicDraw (Context context) {
			double midwidth  = DisplayBox.Width / 2.0;
			double midheight = DisplayBox.Height / 2.0;

			context.LineWidth = LineWidth;
			context.Save ();
			context.Translate (DisplayBox.X + midwidth, DisplayBox.Y + midheight);
			context.Scale (midwidth - 1.0, midheight - 1.0);
			context.Arc (0.0, 0.0, 1.0, 0.0, 2.0 * Math.PI);
			context.Restore ();
			context.Color = FillColor;
			context.FillPreserve ();
			context.Color = LineColor;
			context.Stroke ();
		}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:15,代码来源:EllipseFigure.cs

示例11: Draw

        //FIXME: Figure produces invalid results
        public override PointD Draw(Context context, PointD a, PointD b)
        {
            // Save context
            context.Save ();

            if (_scaleX != _scaleY)
                context.Scale(_scaleX, _scaleY);

            var midpoint = new PointD (a.X + 2 * _radius, a.Y + 2 * _radius);

            context.Arc (midpoint.X, midpoint.Y, _radius, 0, (2 * Math.PI));
            context.Restore ();
            context.Stroke ();

            return Geometry.EdgePointOfCircle (midpoint, _radius, b);
        }
开发者ID:erbriones,项目名称:monodevelop-classdesigner,代码行数:17,代码来源:CircularLineTerminal.cs

示例12: Draw

        void Draw(Context cr, int width, int height)
        {
            Surface overlay = cr.Target.CreateSimilar(Content.ColorAlpha, width, height);
            Surface addSurface = cr.Target.CreateSimilar(Content.ColorAlpha, width, height);

            //	FillChecks (cr, 0, 0,width, height);//w, h);
            //	cr.Save ();

            using (Context cr_overlay = new Context(overlay))
                if (listPoint != null && listPoint.Count > 0) {

                    using (Context cr_addSurface = new Context(addSurface)) {

                        BarierPoint actualPoint;
                        BarierPoint nearstBP;

                        for (int i = 0; i < listPoint.Count; i++) {

                            actualPoint = listPoint[i];
                            if (i == listPoint.Count-1) {
                                nearstBP = listPoint[0];
                            } else
                                nearstBP = listPoint[i + 1];
                            Cairo.Color clrPoint;

                            if (actualPoint.Equals(movingPoint))
                                clrPoint =colorSelectPoint;
                            else
                                clrPoint = colorPoint;

                            cr_addSurface.Color = clrPoint;
                            OvalPath(cr_addSurface, actualPoint.X * scaling, actualPoint.Y * scaling, pointWidth, pointWidth);
                            cr_addSurface.Fill();

                            cr_addSurface.Color = colorLine;
                            LinePath(cr_addSurface, actualPoint.X * scaling, actualPoint.Y * scaling, nearstBP.X * scaling, nearstBP.Y * scaling);
                            cr_addSurface.Fill();
                        }

                    cr_overlay.Operator = Operator.Add;
                    cr_overlay.SetSourceSurface(addSurface, 0, 0);
                    cr_overlay.Paint();
                }

            cr.Scale(1 / scaling, 1 / scaling);

            cr.SetSourceSurface(overlay, (int)(drawOffsetX), (int)(drawOffsetY));

            cr.Paint();

            }

            addSurface.Destroy();
            overlay.Destroy();
        }
开发者ID:moscrif,项目名称:ide,代码行数:55,代码来源:ImageCanvas.cs

示例13: Draw

    /**
    The Draw method draws the clock on the given Cairo.Context in a width by
    height -area.

    Draw clears the canvas, sets up the clock transform and calls the clock
    drawing methods. In the clock transform, the clock area coords go from
    -1.0 to 1.0, rotation 0 is at 12:00 and rotation increases clockwise.
    The clock drawing functions are DrawClockFace, DrawHourHand, DrawMinuteHand,
    DrawSecondHand and DrawPin. The transform origin is at the middle of the
    window and the transform preserves the aspect ratio.

    All operations on the context take place inside a Save-Restore -pair.

    @param cr Cairo.Context to draw on.
    @param width The width of the drawable area.
    @param height The height of the drawable area.
      */
    void Draw(Context cr, uint width, uint height)
    {
        uint boxSize = Math.Min (width, height);

        DateTime date = DateTime.Now;

        cr.Save ();
          // Clear the canvas
          cr.Color = new Color (1, 1, 1);
          cr.Rectangle (0, 0, width, height);
          cr.Fill ();

        // Set canvas transform so that the coords go from -1.0 to 1.0,
        // rotation 0.0 is 12:00 and rotation increases clockwise.
        //
        // First, center the clock box to the window.
          cr.Translate ((width - boxSize) / 2.0, (height - boxSize) / 2.0);
        // Then scale the box so that -1.0 .. 1.0 spans the whole box.
          cr.Scale (boxSize / 2.0, boxSize / 2.0);
        // And move the origin to the center of the box.
          cr.Translate (1.0, 1.0);
        // Finally, rotate CCW by 90 degrees to make rotation 0 point up.
        // We don't need to flip the rotation direction, because angle grows
        // clockwise in the "Y grows down" default transform.
          cr.Rotate (-Math.PI / 2.0);

          // Draw the clock
          DrawClockFace (cr);
          DrawHourHand (cr, (uint)date.Hour);
          DrawMinuteHand (cr, (uint)date.Minute);
          DrawSecondHand (cr, (uint)date.Second);
          DrawPin (cr);
        cr.Restore ();
    }
开发者ID:kig,项目名称:simpleclock,代码行数:51,代码来源:simpleclock.cs

示例14: SetAsSource

        public override void SetAsSource(Context ctx, Rectangle bounds = default(Rectangle))
        {
            float widthRatio = 1f;
            float heightRatio = 1f;

            if (Scaled){
                widthRatio = (float)bounds.Width / Dimensions.Width;
                heightRatio = (float)bounds.Height / Dimensions.Height;
            }

            if (KeepProportions) {
                if (widthRatio < heightRatio)
                    heightRatio = widthRatio;
                else
                    widthRatio = heightRatio;
            }

            using (ImageSurface tmp = new ImageSurface (Format.Argb32, bounds.Width, bounds.Height)) {
                using (Cairo.Context gr = new Context (tmp)) {
                    gr.Translate (bounds.Left, bounds.Top);
                    gr.Scale (widthRatio, heightRatio);
                    gr.Translate ((bounds.Width/widthRatio - Dimensions.Width)/2, (bounds.Height/heightRatio - Dimensions.Height)/2);

                    hSVG.RenderCairo (gr);
                }
                ctx.SetSource (tmp);
            }
        }
开发者ID:jpbruyere,项目名称:Crow,代码行数:28,代码来源:SvgPicture.cs

示例15: DrawSelected

        public override void DrawSelected(Context context)
        {
            context.Save ();
            context.Translate (DisplayBox.X, DisplayBox.Y);
            context.Scale (DisplayBox.Width, DisplayBox.Height);
            context.Rectangle (0.0, 0.0, 1, 1);
            context.Restore ();
            context.Save ();
            context.LineWidth = 3;
            context.Color = new Cairo.Color (1, 0.0784314, 0.576471, 1);
            context.Stroke ();
            context.Restore ();

            context.Save ();
            BasicDrawSelected (context);
            foreach (IFigure fig in FiguresEnumerator) {
                fig.Draw (context);
            }
            context.Restore ();
        }
开发者ID:xiul,项目名称:Monodevelop-Database-Modeler-Addin,代码行数:20,代码来源:TableFigure.cs


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