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


C# CGContext.AddCurveToPoint方法代码示例

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


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

示例1: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		// Drawing with a white stroke color
		context.SetStrokeColor (1, 1, 1, 1);
		// Draw them with a 2 stroke width so they are a bit more visible.
		context.SetLineWidth (2);

		// Draw a bezier curve with end points s,e and control points cp1,cp2
		var s = new CGPoint (30, 120);
		var e = new CGPoint (300, 120);
		var cp1 = new CGPoint (120, 30);
		var cp2 = new CGPoint (210, 210);
		context.MoveTo (s.X, s.Y);
		context.AddCurveToPoint (cp1.X, cp1.Y, cp2.X, cp2.Y, e.X, e.Y);
		context.StrokePath ();

		// Show the control points.
		context.SetStrokeColor (1, 0, 0, 1);
		context.MoveTo (s.X, s.Y);
		context.AddLineToPoint (cp1.X, cp1.Y);
		context.MoveTo (e.X, e.Y);
		context.AddLineToPoint (cp2.X, cp2.Y);
		context.StrokePath ();

		// Draw a quad curve with end points s,e and control point cp1
		context.SetStrokeColor (1, 1, 1, 1);
		s = new CGPoint (30, 300);
		e = new CGPoint (270, 300);
		cp1 = new CGPoint (150, 180);
		context.MoveTo (s.X, s.Y);
		context.AddQuadCurveToPoint (cp1.X, cp1.Y, e.X, e.Y);
		context.StrokePath ();

		// Show the control point.
		context.SetStrokeColor (1, 0, 0, 1);
		context.MoveTo (s.X, s.Y);
		context.AddLineToPoint (cp1.X, cp1.Y);
		context.StrokePath ();
	}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:39,代码来源:CurveDrawing.cs

示例2: make_arc

        /*
         * Based on the algorithm described in
         *      http://www.stillhq.com/ctpfaq/2002/03/c1088.html#AEN1212
         */
        static void make_arc(CGContext graphics, bool start, float x, float y, float width,
			         float height, float startAngle, float endAngle, bool antialiasing, bool isPieSlice)
        {
            float delta, bcp;
            double sin_alpha, sin_beta, cos_alpha, cos_beta;
            float PI = (float)Math.PI;

            float rx = width / 2;
            float ry = height / 2;

            /* center */
            float cx = x + rx;
            float cy = y + ry;

            /* angles in radians */
            float alpha = startAngle * PI / 180;
            float beta = endAngle * PI / 180;

            /* adjust angles for ellipses */
            alpha = (float)Math.Atan2(rx * Math.Sin(alpha), ry * Math.Cos(alpha));
            beta = (float)Math.Atan2(rx * Math.Sin(beta), ry * Math.Cos(beta));

            if (Math.Abs(beta - alpha) > PI)
            {
                if (beta > alpha)
                    beta -= 2 * PI;
                else
                    alpha -= 2 * PI;
            }

            delta = beta - alpha;
            bcp = (float)(4.0 / 3.0 * (1 - Math.Cos(delta / 2)) / Math.Sin(delta / 2));

            sin_alpha = Math.Sin(alpha);
            sin_beta = Math.Sin(beta);
            cos_alpha = Math.Cos(alpha);
            cos_beta = Math.Cos(beta);

            /* don't move to starting point if we're continuing an existing curve */
            if (start)
            {
                /* starting point */
                double sx = cx + rx * cos_alpha;
                double sy = cy + ry * sin_alpha;
                if (isPieSlice)
                    graphics.AddLineToPoint((float)sx,(float)sy);
                else
                    graphics.MoveTo((float)sx,(float)sy);
            }

            graphics.AddCurveToPoint(cx + rx * (float)(cos_alpha - bcp * sin_alpha),
                                    cy + ry * (float)(sin_alpha + bcp * cos_alpha),
                                    cx + rx * (float)(cos_beta + bcp * sin_beta),
                                    cy + ry * (float)(sin_beta - bcp * cos_beta),
                                    cx + rx * (float)cos_beta, cy + ry * (float)sin_beta);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:60,代码来源:Graphics-DrawEllipticalArc.cs


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