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


C# Context.Scale方法代码示例

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


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

示例1: OnDraw

		protected override void OnDraw (Context ctx, Rectangle bounds)
		{
			ctx.Save ();
			ctx.Translate (bounds.Location);
			ctx.Scale (bounds.Width / Size.Width, bounds.Height / Size.Height);
			ToolkitEngine.VectorImageRecorderContextHandler.Draw (ctx.Handler, Toolkit.GetBackend (ctx), data);
			ctx.Restore ();
		}
开发者ID:TheBrainTech,项目名称:xwt,代码行数:8,代码来源:VectorImage.cs

示例2: OnDraw

        protected override sealed void OnDraw(Context ctx, Rectangle bounds)
        {
            var frame = GetFrame (ctx.ScaleFactor);
            var fixedWidth = frame.Bitmap.Width - 2 - frame.StretchableWidth;
            var fixedHeight = frame.Bitmap.Height - 2 - frame.StretchableHeight;
            double totalVariableWidth = bounds.Width - fixedWidth / frame.ScaleFactor;
            double totalVariableHeight = bounds.Height - fixedHeight / frame.ScaleFactor;
            double remainingVariableHeight = totalVariableHeight;

            double y = bounds.Y, yb = 1;
            int tileIndex = 0;

            ctx.Save ();
            if (totalVariableWidth < 0) {
                if (fixedWidth > 0)
                    ctx.Scale (bounds.Width / fixedWidth, 1);
                totalVariableWidth = 0;
            }
            if (totalVariableHeight < 0) {
                if (fixedHeight > 0)
                    ctx.Scale (1, bounds.Height / fixedHeight);
                totalVariableHeight = 0;
            }

            foreach (var vs in frame.VerticalSections) {

                double sh = CalcSectionSize (frame, vs, totalVariableHeight, frame.StretchableHeight, ref remainingVariableHeight);

                double x = bounds.X, xb = 1;
                double remainingVariableWidth = totalVariableWidth;

                foreach (var hs in frame.HorizontalSections) {
                    var sourceRegion = new Rectangle (xb, yb, hs.Size, vs.Size);
                    double sw = CalcSectionSize (frame, hs, totalVariableWidth, frame.StretchableWidth, ref remainingVariableWidth);
                    var targetRegion = new Rectangle (x, y, sw, sh);

                    if (vs.Mode != RenderMode.Tile && hs.Mode != RenderMode.Tile) {
                        var t = GetTile (frame, tileIndex, sourceRegion);
                        ctx.DrawImage (t, targetRegion);
                    } else {
                        double pw = hs.Size / frame.ScaleFactor;
                        double ph = vs.Size / frame.ScaleFactor;
                        if (hs.Mode == RenderMode.Stretch) {
                            pw = targetRegion.Width;
                        }
                        if (vs.Mode == RenderMode.Stretch) {
                            ph = targetRegion.Height;
                        }

                        ctx.Save ();
                        ctx.Translate (targetRegion.Location);
                        targetRegion.Location = Point.Zero;
                        ctx.Pattern = new ImagePattern (GetTile (frame, tileIndex, sourceRegion).WithSize (pw, ph));
                        ctx.NewPath ();
                        ctx.Rectangle (targetRegion);
                        ctx.Fill ();
                        ctx.Restore ();
                    }
                    x += sw;
                    xb += hs.Size;
                    tileIndex++;
                }
                yb += vs.Size;
                y += sh;
            }
            ctx.Restore ();
        }
开发者ID:jijamw,项目名称:xwt,代码行数:67,代码来源:NinePatchImage.cs

示例3: Scale

        public virtual void Scale(Context ctx, double ax, double ay)
        {
            ctx.Save ();
            ctx.Translate (ax, ay);
            ctx.SetColor (Colors.Black);
            ctx.SetLineWidth (1);

            var x = 0d;
            var y = 0d;
            var w = 10d;
            var inc = .1d;
            for (var i = inc; i < 3.5d; i +=inc) {
                ctx.Save ();
                ctx.Scale (i, i);
                ctx.Rectangle (x, y, w, w);
                ctx.SetColor (Colors.Yellow.WithAlpha (1 / i));
                ctx.FillPreserve ();
                ctx.SetColor (Colors.Red.WithAlpha (1 / i));
                ctx.Stroke ();
                ctx.MoveTo (x += w * inc, y += w * inc / 3);
                ctx.Restore ();

            }

            ctx.Restore ();
        }
开发者ID:RevolutionSmythe,项目名称:xwt,代码行数:26,代码来源:DrawingTransforms.cs

示例4: Draw

        bool Draw(Context ctx, Rectangle dirtyRect, double scale)
        {
            bool redraw = false;
            ctx.Save();
            ctx.Scale(scale, scale);

            // draw all edges
            foreach (PipelineNode pNode in nodes) {
                foreach (MarkerNode mNode in pNode.mNodes) {
                    if (!mNode.IsInput) {
                        mNode.DrawEdges(ctx);
                    }
                }
            }

            // draw all nodes
            foreach (PipelineNode node in nodes) {
                if (!mouseAction.HasFlag(MouseAction.MoveNode) || node != lastSelectedNode) {
                    if (node.bound.IntersectsWith(dirtyRect) || !initialScrollPosition.IsEmpty) {
                        if (node.Draw(ctx)) {
                            redraw = true;
                            QueueDraw(node.bound);
                        }
                    }
                }
            }

            // draw all markers
            foreach (PipelineNode pNode in nodes) {
                foreach (MarkerNode mNode in pNode.mNodes) {
                    mNode.Draw(ctx);
                }
            }

            // draw selected node last
            if (mouseAction.HasFlag(MouseAction.MoveNode)) {
                if (lastSelectedNode.Draw(ctx)) {
                    redraw = true;
                    QueueDraw(lastSelectedNode.bound);
                }
                foreach (MarkerNode mNode in lastSelectedNode.mNodes) {
                    mNode.Draw(ctx);
                }
            }

            ctx.Restore();
            return redraw;
        }
开发者ID:jfreax,项目名称:BAIMP,代码行数:48,代码来源:PipelineView.cs


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