【问题标题】:middlePoint in CGContextAddArc?CGContextAddArc 中的中间点?
【发布时间】:2011-01-17 05:17:59
【问题描述】:

我正在通过CGContext绘制Arc。我想在Arc的中心点绘制一个字符串。我如何喜欢通过CGContext绘制的Arc中的中心点。

              CGContextSetAlpha(ctx, 0.5);
CGContextSetRGBFillColor(ctx, color.red, color.green, color.blue, color.alpha );
CGContextMoveToPoint(ctx, cX, cY);
CGContextAddArc(ctx, cX, cY, radious+10, (startDeg-90)*M_PI/180.0, (endDeg-90)*M_PI/180.0, 0);
CGContextClosePath(ctx);
CGContextFillPath(ctx); 

【问题讨论】:

    标签: iphone ipad math cgcontext


    【解决方案1】:

    CGContextAddArc 的第二个和第三个参数是圆弧中心的 x 和 y 坐标。因此,在这段代码中,中心在点 (cX,cY)。

    编辑

    此代码将直接在弧的起点和终点之间给出点的坐标为 x 和 y。

    CGFloat x = cX + (radious+10) * (cos((startDeg-90)*M_PI/180.0) + cos((endDeg-90)*M_PI/180.0)) / 2;
    CGFloat y = cY + (radious+10) * (sin((startDeg-90)*M_PI/180.0) + sin((endDeg-90)*M_PI/180.0)) / 2;
    

    【讨论】:

    • 嗨..我没有问这段代码中的圆心....两个radius之间的弧形部分的中点...
    • 哦,我明白你想要什么了。您应该编辑帖子以询问中间点,而不是中心点,以避免将来混淆。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多