2

これが私がやろうとしていることです。基本的に各グリフのビットマップ長方形であるフォントがあります。私はこのような弧を描いたテキスト効果を得ようとしています:

ここに画像の説明を入力

私の計画は、中心と半径を指定して、各グリフの位置と角度を解決することです。

位置を見つけることができる関数があります:

Vec2 Math::positionFromCenterToLineAt( Vec2 center, float dist,
        float totalAngular, float angularDistance, float angularOffset )
    {
        float startAngle = -((totalAngular) / 2.0f);
        float curAngle = startAngle + angularDistance;
        curAngle -= angularOffset;
        curAngle += angularDistance / 2.0f;
        curAngle += CGE_PI;

        Vec2 retVec = center;
        Vec2 angVec = Vec2(sin(curAngle),cos(curAngle));
        angVec *= dist;
        retVec += angVec;

        return retVec;
    }

ラジアンでどのくらいの円が占有されるかを知る必要があり、現在のグリフを描画する開始角度からの角度が必要です。

私が理解できないのは、グリフの半径、中心、および幅と高さを考慮して、特定のグリフが占める角度を見つける関数です。各グリフは異なる次元を持つことができます。

これを参照してください: ここに画像の説明を入力

ご覧のとおり、円のセクターをラジアンで探しています。

どうすれば計算できますか?

ありがとう

4

1 に答える 1

2
2*pi*radius equals the circumference
You know radius as a pixel base(lets say it is 40 pixels)
You can find circumference(lets say it is 251 pixels)
Then, if you get width of a char(lets say it is 8)
You know the angle of arc: angle=2*pi*(8/251)=2*pi*0.03=0.2 radians
0.2 radians * 57.3 = 11.5 degrees

現在のフォントに従って文字の幅を見つける方法は?

LOGFONT lf;
int width=lf.lfWidth; //beware! this is average

正確なオプションが必要ですか?

GetTextExtentPoint32() // search usage of this!

Its structure type is:

 BOOL GetTextExtentPoint32(
  __in   HDC hdc,
  __in   LPCTSTR lpString,
  __in   int c,
  __out  LPSIZE lpSize
);
于 2012-09-01T21:55:54.677 に答える