0

次のコードがブロック状のグラデーションになるのはなぜですか? つまり、グラデーションは滑らかではなく、それを構成するいくつかの長方形を見ることができます。

これを修正する方法はありますか?
ところで、私はこれを Vista で実行していますが、Mac でもこれを経験しました。

var stage:Stage = Stage {
title: "Louis' Photo Wall"
width: 900
height: 600

scene: Scene {
    content : Rectangle {
        width:  bind stage.scene.width
        height: bind stage.scene.height
        fill:LinearGradient {
            startX : 0.0
            startY : 0.0
            endX : 0.0
            endY : 1.0
            stops: [
                Stop {
                    color : Color {
                        red:0.0
                        blue:0.0
                        green:0.0
                    }

                    offset: 0.0
                },
                Stop {
                    color : Color {
                        red:0.8
                        blue:0.8
                        green:0.8
                    }
                    offset: 1.0
                },

            ]
        }

    }//OuterRectangle
}

}

4

1 に答える 1

0

ブロック状の量は劇的ではありません。

1.0 の endX にシフトすると、ブロック状の結果の対角化により、より明白な変化が得られるようです。

仮説は、いくつかのことが起こっているということです。1. r/g/b カラーは連続ではなく、256 ステップあります。(8 ビット)。255 の 0.8 は 204 です。 2. 1 つの色の 0 から 0.8 を 600 ピクセルにマッピングすると、完全に滑らかにできないピクセルごとの増分が得られます。実際に実行すると、シーンのサイズは 792x566 です。したがって、グラデーションは、次の色にシフトする前に、1 つの色に対して 566/204 = 2.775 ピクセルを使用します。これにより、遷移が行われる場所に変動が生じます。

これは、ストップに (0.0 から 0.8 ではなく) 0.0 から 1.0 を使用すると、(少なくとも私の実行では) スムーズな遷移のように見える理由を説明していません。


フォローアップ: ofTheWayLinearGradient がおそらく補間に使用するメソッドがあります。コード例と結果...

for (v in [0.00..1.00 step 1.0/600]) {
   println("{%7.5f v} {Color.WHITE.ofTheWay(Color.BLACK,v)}");
}

印刷する

0.00000 javafx.scene.paint.Color[red=255,green=255,blue=255,opacity=1.0]
0.00167 javafx.scene.paint.Color[red=255,green=255,blue=255,opacity=1.0]
0.00333 javafx.scene.paint.Color[red=254,green=254,blue=254,opacity=1.0]
0.00500 javafx.scene.paint.Color[red=254,green=254,blue=254,opacity=1.0]
0.00667 javafx.scene.paint.Color[red=253,green=253,blue=253,opacity=1.0]
0.00833 javafx.scene.paint.Color[red=253,green=253,blue=253,opacity=1.0]
0.01000 javafx.scene.paint.Color[red=252,green=252,blue=252,opacity=1.0]
0.01167 javafx.scene.paint.Color[red=252,green=252,blue=252,opacity=1.0]
0.01333 javafx.scene.paint.Color[red=252,green=252,blue=252,opacity=1.0]
0.01500 javafx.scene.paint.Color[red=251,green=251,blue=251,opacity=1.0]
0.01667 javafx.scene.paint.Color[red=251,green=251,blue=251,opacity=1.0]
...
于 2009-06-01T18:23:30.850 に答える