-2

小さなマルチメイジグラフィックコントロールを実装する必要があります。これは、基本的に9つの画像の配列であり、1つずつ表示されます。最終的な目標は、ミニスライダーとして機能することです。

これで、このグラフィックコントロールは、5から25、0から7、または-9から9のさまざまな整数範囲を受け取ります。

プロポーション(「三つのルール」)を使用する場合、エラーの原因となる可能性があるため、技術的に持続可能ではないのではないかと思います。私の推測では、いくつかのルックアップテーブルを使用することですが、アプローチについて誰か良いアドバイスがありますか?

Thnx

4

2 に答える 2

1

ルックアップテーブルが必要かどうかはわかりません。入力値から0〜9の画像インデックスに比例して取得できます。

int ConvertToImageArrayIndex(int inputValue)
{
    int maxInputFromOtherModule = 25;
    int minInputFromOtherModule = 5;


    // +1 required so include both min and max input values in possible range.
    // + 0.5 required so that round to the nearest image instead of always rounding down.
    // 8.0 required to get to an output range of 9 possible indexes [0..8]

    int imageIndex = ( (float)((inputValue-minInputFromOtherModule) * 8.0) / (float)(maxInputFromOtherModule - minInputFromOtherModule + 1) ) + 0.5;

    return imageIndex;
}
于 2010-08-04T08:43:50.483 に答える
0

はい、ルックアップテーブルは良い解決策です

int lookup[9] = {5, 25, ... the other values };
int id1 = floor(slider);
int id2 = id1+1;
int texId1 = lookup[id1];
int texId2 = lookup[id2];
interpolate(texId1, texId2, slider - float(id1));
于 2010-08-04T08:11:59.503 に答える