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


C# Context.Rectangle方法代码示例

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


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

示例1: CreateImageBrush

        public static SurfacePattern CreateImageBrush(ImageBrush brush, Size targetSize)
        {
            if (brush.Source == null)
            {
                return null;
            }

            // TODO: This is directly ported from Direct2D and could probably be made more
            // efficient on cairo by taking advantage of the fact that cairo has Extend.None.
            var image = ((BitmapImpl)brush.Source.PlatformImpl).Surface;
            var imageSize = new Size(brush.Source.PixelWidth, brush.Source.PixelHeight);
            var tileMode = brush.TileMode;
            var sourceRect = brush.SourceRect.ToPixels(imageSize);
            var destinationRect = brush.DestinationRect.ToPixels(targetSize);
            var scale = brush.Stretch.CalculateScaling(destinationRect.Size, sourceRect.Size);
            var translate = CalculateTranslate(brush, sourceRect, destinationRect, scale);
            var intermediateSize = CalculateIntermediateSize(tileMode, targetSize, destinationRect.Size);

			var intermediate = new ImageSurface (Format.ARGB32, (int)intermediateSize.Width, (int)intermediateSize.Height);
            using (var context = new Context(intermediate))
            {
                Rect drawRect;
                var transform = CalculateIntermediateTransform(
                    tileMode,
                    sourceRect,
                    destinationRect,
                    scale,
                    translate,
                    out drawRect);
                context.Rectangle(drawRect.ToCairo());
                context.Clip();
                context.Transform(transform.ToCairo());
                Gdk.CairoHelper.SetSourcePixbuf(context, image, 0, 0);
                context.Rectangle(0, 0, imageSize.Width, imageSize.Height);
                context.Fill();

                var result = new SurfacePattern(intermediate);

                if ((brush.TileMode & TileMode.FlipXY) != 0)
                {
                    // TODO: Currently always FlipXY as that's all cairo supports natively. 
                    // Support separate FlipX and FlipY by drawing flipped images to intermediate
                    // surface.
                    result.Extend = Extend.Reflect;
                }
                else
                {
                    result.Extend = Extend.Repeat;
                }

                if (brush.TileMode != TileMode.None)
                {
                    var matrix = result.Matrix;
                    matrix.InitTranslate(-destinationRect.X, -destinationRect.Y);
                    result.Matrix = matrix;
                }

                return result;
            }
        }
开发者ID:shahid-pk,项目名称:Perspex,代码行数:60,代码来源:TileBrushes.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, 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:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:26,代码来源:DissolveTransition.cs

示例3: DrawObject

        public void DrawObject(Context ctx, DrawingObject body)
        {
            if (body == null)
                return;
            ctx.Save ();
            ctx.Color = new Cairo.Color (0, 0, 0);

            ctx.LineWidth = 1;
            foreach (Tuple<PointDouble, PointDouble> line in body.lines) {
                ctx.MoveTo (line.Item1.toPointD());
                ctx.LineTo (line.Item2.toPointD());
            }

            if (body.points.Count > 1)
                ctx.Rectangle(body._centerOfMass.X - 5, body._centerOfMass.Y - 5, 10, 10);
            ctx.Stroke ();

            foreach (PointDouble point in body.points) {
                ctx.Rectangle (point.X - 5, point.Y - 5, 10, 10);
                ctx.Fill ();
            }
            foreach (Tuple<PointDouble, double, double> force in body._forces) {
                DrawForce (ctx, force);
            }

            foreach (Tuple<PointDouble, double> moment in body._moments) {
                DrawMoment (ctx, moment);
            }

            ctx.Restore ();
        }
开发者ID:jqt3of5,项目名称:StaticsSimulator,代码行数:31,代码来源:DrawingWidgetView.cs

示例4: FillChecks

	void FillChecks (Context cr, int x, int y, int width, int height)
	{
		int CHECK_SIZE = 32;
		
		cr.Save ();
		Surface check = cr.Target.CreateSimilar (Content.Color, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
		
		// draw the check
		using (Context cr2 = new Context (check)) {
			cr2.Operator = Operator.Source;
			cr2.Color = new Color (0.4, 0.4, 0.4);
			cr2.Rectangle (0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
			cr2.Fill ();

			cr2.Color = new Color (0.7, 0.7, 0.7);
			cr2.Rectangle (x, y, CHECK_SIZE, CHECK_SIZE);
			cr2.Fill ();

			cr2.Rectangle (x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE);
			cr2.Fill ();
		}

		// Fill the whole surface with the check
		SurfacePattern check_pattern = new SurfacePattern (check);
		check_pattern.Extend = Extend.Repeat;
		cr.Source = check_pattern;
		cr.Rectangle (0, 0, width, height);
		cr.Fill ();

		check_pattern.Destroy ();
		check.Destroy ();
		cr.Restore ();
	}
开发者ID:ystk,项目名称:debian-gtk-sharp2,代码行数:33,代码来源:CairoSample.cs

示例5: Draw

 /// <summary>
 /// Draws black in the areas outside the view.
 /// Assumes that controlBounds is starting at (0, 0) in upper left corner.
 /// </summary>
 /// <param name="context">A context to perform drawing.</param>
 /// <param name="controlBounds">Bounds of the control.</param>
 /// <param name="view">The bounds of the view.</param>
 public static void Draw(Context context, Rectangle controlBounds, Rectangle view)
 {
     context.Color = new Cairo.Color (0.0, 0.0, 0.0);
     context.NewPath ();
     context.Rectangle (0.0, 0.0, view.X, controlBounds.Height);
     var wRight = controlBounds.Width - view.X - view.Width;
     context.Rectangle (view.X + view.Width, 0.0, wRight, controlBounds.Height);
     context.Rectangle (view.X, 0.0, view.Width, view.Y);
     var hBottom = controlBounds.Height - view.Y - view.Height;
     context.Rectangle (view.X, view.Y + view.Height, view.Width, hBottom);
     context.Fill ();
 }
开发者ID:bvssvni,项目名称:csharp-sketch,代码行数:19,代码来源:CairoCanvasViewModule.cs

示例6: Draw

        protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress)
        {
            cr.SetSourceColor (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:Yetangitu,项目名称:f-spot,代码行数:50,代码来源:Push.cs

示例7: Render

        public void Render(DrawingArea area, SettingsModel settings)
        {
            var width = area.Allocation.Width;
            var height = area.Allocation.Height;

            var kaleidoscope = _factory.Get (settings.Type);
            var rootNode = kaleidoscope.Generate (
                settings.GeometyWidth,
                settings.ImageUri,
                width, height);

            ImageSurface surface = new ImageSurface(Format.Argb32, width, height);

            using (var context = new Context (surface)) {
                context.Translate(width / 2, height / 2);
                rootNode.Render (context);
            }
            rootNode.Geometry.Dispose ();

            using (Context context = Gdk.CairoHelper.Create (area.GdkWindow)) {
                context.Rectangle(0, 0, width, height);
                context.SetSource(surface);
                context.Fill();
                context.GetTarget ().Dispose ();
            }
            surface.Dispose ();
        }
开发者ID:imagineblueeyes,项目名称:KaleidoscopeGenerator,代码行数:27,代码来源:CairoRenderer.cs

示例8: Draw

 public virtual void Draw(Context cr, Gdk.Rectangle clip)
 {
     cr.Rectangle(clip.X, clip.Y, clip.Width, clip.Height);
     cr.Color = BackgroundColor;
     cr.Fill();
     cr.Stroke();
 }
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:7,代码来源:Paper.cs

示例9: clip

        public void clip(Context ctx)
        {
            foreach (Rectangle r in list)
                ctx.Rectangle(r);

            ctx.Clip();
        }
开发者ID:jpbruyere,项目名称:Crow,代码行数:7,代码来源:Rectangles.cs

示例10: Run

 public override void Run()
 {
     ICollection<double> chapters = this.Theory.Chapters;
     StripCanvasSize scs = this.Manager.GenerateStripCanvasSize (chapters.Count);
     double dw = scs.CanvasSize.Width;
     double dh = scs.CanvasSize.Height;
     using (PdfSurface surface = new PdfSurface (this.Manager.OutputFile, scs.TotalWidth, scs.TotalHeight)) {
         using (Context ctx = new Context (surface)) {
             int index = 0x00;
             IPoint3 p;
             foreach (double chapter in chapters) {
                 p = scs.GetCanvasOffset (index);
                 ctx.Save ();
                 ctx.Translate (p.X, p.Y);
                 ctx.Rectangle (0.0d, 0.0d, dw, dh);
                 ctx.Stroke ();
                 this.Theory.Time = chapter;
                 CairoEngine engine = new CairoEngine (this.Theory);
                 engine.Context = ctx;
                 engine.Process ();
                 ctx.Restore ();
                 index++;
             }
         }
     }
 }
开发者ID:KULeuven-KRR,项目名称:IdpGie,代码行数:26,代码来源:OutputPdfStripDevice.cs

示例11: Apply

        public override void Apply (CanvasItem item, Context cr)
        {
            int steps = ShadowSize;
            double opacity_step = ShadowOpacity / ShadowSize;
            Color color = new Color (0, 0, 0);

            double width = Math.Round (item.Allocation.Width);
            double height = Math.Round (item.Allocation.Height);

            if (Fill != null) {
                cr.Rectangle (shadow_size, shadow_size, width - ShadowSize * 2, height - ShadowSize * 2);
                Fill.Apply (cr);
                cr.Fill ();
            }

            cr.LineWidth = 1.0;

            for (int i = 0; i < steps; i++) {
                CairoExtensions.RoundedRectangle (cr,
                    i + 0.5,
                    i + 0.5,
                    (width - 2 * i) - 1,
                    (height - 2 * i) - 1,
                    steps - i);

                color.A = opacity_step * (i + 1);
                cr.Color = color;
                cr.Stroke ();
            }
        }
开发者ID:fatman2021,项目名称:gnome-apps,代码行数:30,代码来源:ShadowMarginStyle.cs

示例12: DrawHist

        public void DrawHist(TimeList<Complex[]> list, double t)
        {
            using (Context context = new Context(Surface)) {

                context.Rectangle(0, 0, Width, Height);
                context.Color = Background;
                context.Fill();

                int index = list.Index (t);
                int times = 30;

                double xl = (double)(Width - 60) / N;
                double yl = (double)Height / times;

                Complex[] points;
                Color c;
                int ii;
                for (int i = index; i >= Math.Max(0, index - times); i--) {
                    points = list.Get (i);
                    N = points.Length;
                    ii = index - i;
                    for (int j = 0; j < points.Length; j++) {
                        DrawHistArea (context, xl, yl, ii, j, _valueExtractor(points [j]));
                    }
                }
            }

            DrawExpose (null, null);
        }
开发者ID:codingcave,项目名称:CoupledOdeViewer,代码行数:29,代码来源:ValueSurfaceItem.cs

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

示例14: clear

 public void clear(Context ctx)
 {
     foreach (Rectangle r in list)
         ctx.Rectangle(r);
     ctx.Operator = Operator.Clear;
     ctx.Fill();
     ctx.Operator = Operator.Over;
 }
开发者ID:jpbruyere,项目名称:Crow,代码行数:8,代码来源:Rectangles.cs

示例15: OnRender

 protected void OnRender(Context cr, int width, int height)
 {
     cr.Save();
     cr.SetSourceRGBA(1, 0, 0, mTick*0.1);
     cr.Rectangle(0, 0, width, height);
     cr.Fill();
     cr.Restore();
 }
开发者ID:icebreaker,项目名称:csdemo,代码行数:8,代码来源:main.cs


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