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


C# Context.CurveTo方法代码示例

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


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

示例1: Curves1

        public virtual void Curves1(Context ctx, double x, double y)
        {
            ctx.Save ();
            ctx.Translate (x, y);

            ctx.SetLineWidth (1);
            Action curve1 = () => {
                ctx.MoveTo (0, 30);
                ctx.CurveTo (20, 0, 50, 0, 60, 25);
            };
            // curve2 with lineTo; curve1 is closed
            Action curve2 = () => {
                ctx.LineTo (0, 0);
                ctx.CurveTo (20, 30, 50, 30, 60, 5);
            };
            Action paint = () => {
                curve1 ();
                curve2 ();
                ctx.ClosePath ();
                ctx.SetColor (new Color (0, 0, 0, .5));
                ctx.StrokePreserve ();
                ctx.SetColor (new Color (1, 0, 1, .5));
                ctx.Fill ();
            };
            paint ();

            ctx.Translate (0, 40);
            // curve2 with moveTo; curve1 is open
            curve2 = () => {
                ctx.MoveTo (0, 0);
                ctx.CurveTo (20, 30, 50, 30, 60, 5);
            };
            paint ();
            ctx.Restore ();

            //Todo: same stuff with arc
        }
开发者ID:RevolutionSmythe,项目名称:xwt,代码行数:37,代码来源:DrawingFigures.cs

示例2: Curves2

		public virtual void Curves2 (Context ctx, double sx, double sy)
		{
			ctx.Save ();
			ctx.Translate (sx, sy);
			ctx.SetColor (Colors.Black);
			
			double x = 0, y = 40;
			double x1 = y - x, y1 = x1 + y, x2 = x + y, y2 = x, x3 = y1, y3 = y;

			ctx.MoveTo (x, y);
			ctx.CurveTo (x1, y1, x2, y2, x3, y3);

			ctx.SetLineWidth (2.0);
			ctx.Stroke ();

			ctx.SetColor (new Color (1, 0.2, 0.2, 0.6));
			ctx.SetLineWidth (1.0);
			ctx.MoveTo (x, y);
			ctx.LineTo (x1, y1);
			ctx.MoveTo (x2, y2);
			ctx.LineTo (x3, y3);
			ctx.Stroke ();
			
			ctx.Restore ();
		}
开发者ID:m13253,项目名称:xwt,代码行数:25,代码来源:DrawingFigures.cs

示例3: DrawBorder

        void DrawBorder(Context ctx, double x, double y, double w, double h, double radius, double thickness)
        {
            // test limits (without using multiplication)
            if (radius > w - radius)
                radius = w / 2;
            if (radius > h - radius)
                radius = h / 2;

            // approximate (quite close) the arc using a bezier curve
            double arc = ArcToBezier * radius;

            ctx.SetLineWidth (thickness);

            // top-left corner
            ctx.NewPath ();
            ctx.MoveTo (x, y + radius);
            ctx.CurveTo (x, y + radius - arc, x + radius - arc, y, x + radius, y);
            ctx.Pattern = GetCornerGradient (x + radius, y + radius, radius, thickness / 2);
            ctx.Stroke ();

            // top edge
            ctx.NewPath ();
            ctx.MoveTo (x + radius - 0.5, y);
            ctx.LineTo (x + w - radius + 0.5, y);
            ctx.Pattern = GetTopEdgeGradient (y, thickness / 2);
            ctx.Stroke ();

            // top-right corner
            ctx.NewPath ();
            ctx.MoveTo (x + w - radius, y);
            ctx.CurveTo (x + w - radius + arc, y, x + w, y + arc, x + w, y + radius);
            ctx.Pattern = GetCornerGradient (x + w - radius, y + radius, radius, thickness / 2);
            ctx.Stroke ();

            // right edge
            ctx.NewPath ();
            ctx.MoveTo (x + w, y + radius - 0.5);
            ctx.LineTo (x + w, y + h - radius + 0.5);
            ctx.Pattern = GetRightEdgeGradient (x + w, thickness / 2);
            ctx.Stroke ();

            // bottom-right corner
            ctx.NewPath ();
            ctx.MoveTo (x + w, y + h - radius);
            ctx.CurveTo (x + w, y + h - radius + arc, x + w + arc - radius, y + h, x + w - radius, y + h);
            ctx.Pattern = GetCornerGradient (x + w - radius, y + h - radius, radius, thickness / 2);
            ctx.Stroke ();

            // bottom edge
            ctx.NewPath ();
            ctx.MoveTo (x + w - radius + 0.5, y + h);
            ctx.LineTo (x + radius - 0.5, y + h);
            ctx.Pattern = GetBottomEdgeGradient (y + h, thickness / 2);
            ctx.Stroke ();

            // bottom-left corner
            ctx.NewPath ();
            ctx.MoveTo (x + radius, y + h);
            ctx.CurveTo (x + radius - arc, y + h, x, y + h - arc, x, y + h - radius);
            ctx.Pattern = GetCornerGradient (x + radius, y + h - radius, radius, thickness / 2);
            ctx.Stroke ();

            // left edge
            ctx.NewPath ();
            ctx.MoveTo (x, y + h - radius + 0.5);
            ctx.LineTo (x, y + radius - 0.5);
            ctx.Pattern = GetLeftEdgeGradient (x, thickness / 2);
            ctx.Stroke ();
        }
开发者ID:pabloescribano,项目名称:xwt,代码行数:69,代码来源:ReliefFrame.cs

示例4: OnDraw

        /// <summary>
        /// Raises the draw event.
        /// </summary>
        /// <param name="ctx">Context.</param>
        /// <param name="dirtyRect">Dirty rect.</param>
        protected override void OnDraw(Context ctx, Rectangle dirtyRect)
        {
            base.OnDraw(ctx, dirtyRect);

            ctx.SetLineWidth(1.0);

            if (previous != null && !previous.Active) {
                ctx.SetColor(deactiveColor);
                if (Multiple) {
                    ctx.Rectangle(0, 0, Lean.Dx * 2, Size.Height);
                    ctx.Fill();

                    ctx.SetColor(borderColor);
                    ctx.MoveTo(0, 0);
                    ctx.LineTo(Lean.Dx * 2, 0);
                    ctx.Stroke();
                } else {
                    ctx.MoveTo(0, 0);
                    ctx.CurveTo(
                        0, 0,
                        Lean.Dx, 0,
                        Lean.Dx, Lean.Dy);
                    ctx.LineTo(Lean.Dx, Size.Height - Lean.Dy);
                    ctx.CurveTo(
                        Lean.Dx, Size.Height - Lean.Dy,
                        Lean.Dx, Size.Height + 0.5,
                        Lean.Dx * 2, Size.Height + 0.5);
                    ctx.LineTo(0, Size.Height);

                    ctx.FillPreserve();

                    ctx.SetColor(borderColor);
                    ctx.Stroke();
                }
            }

            if (previous == null || Multiple || !previous.Active) {
                ctx.MoveTo(0, Size.Height + 0.5);
                ctx.CurveTo(
                    0, Size.Height + 0.5,
                    Lean.Dx, Size.Height + 0.5,
                    Lean.Dx, Size.Height - Lean.Dy);
            } else {
                ctx.MoveTo(Lean.Dx, Size.Height);
            }
            ctx.LineTo(Lean.Dx, Lean.Dy);
            ctx.CurveTo(
                Lean.Dx, Lean.Dy,
                Lean.Dx, 0,
                Lean.Dx * 2, 0);

            if (next == null) {
                ctx.LineTo(Size.Width - (Lean.Dx * 2), 0);
                ctx.CurveTo(
                    Size.Width - (Lean.Dx * 2), 0,
                    Size.Width - Lean.Dx, 0,
                    Size.Width - Lean.Dx, Lean.Dy);
                ctx.LineTo(Size.Width - Lean.Dx, Size.Height - Lean.Dy);
                ctx.CurveTo(
                    Size.Width - Lean.Dx, Size.Height - Lean.Dy,
                    Size.Width - Lean.Dx, Size.Height,
                    Size.Width, Size.Height);
            } else {
                ctx.LineTo(Size.Width, 0);
                ctx.LineTo(Size.Width, Size.Height);
            }

            ctx.SetColor(Active ? activeColor : deactiveColor);
            ctx.Fill();

            // border
            if (previous == null || Multiple || !previous.Active) {
                ctx.MoveTo(0, Size.Height + 0.5);
                ctx.CurveTo(
                    0, Size.Height + 0.5,
                    Lean.Dx, Size.Height + 0.5,
                    Lean.Dx, Size.Height - Lean.Dy);
            } else {
                ctx.MoveTo(Lean.Dx, Size.Height + 0.5 - Lean.Dy);
            }

            ctx.LineTo(Lean.Dx, Lean.Dy);
            ctx.CurveTo(
                Lean.Dx, Lean.Dy,
                Lean.Dx, 0,
                Lean.Dx * 2, 0);

            if (next == null) {
                ctx.LineTo(Size.Width - (Lean.Dx * 2), 0);
                ctx.CurveTo(
                    Size.Width - (Lean.Dx * 2), 0,
                    Size.Width - Lean.Dx, 0,
                    Size.Width - Lean.Dx, Lean.Dy);
                ctx.LineTo(Size.Width - Lean.Dx, Size.Height - Lean.Dy);
                ctx.CurveTo(
//.........这里部分代码省略.........
开发者ID:jfreax,项目名称:BAIMP,代码行数:101,代码来源:TabButton.cs


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