本文整理汇总了C#中MonoMac.CoreGraphics.CGContext.AddCurveToPoint方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.AddCurveToPoint方法的具体用法?C# CGContext.AddCurveToPoint怎么用?C# CGContext.AddCurveToPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoMac.CoreGraphics.CGContext
的用法示例。
在下文中一共展示了CGContext.AddCurveToPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}