Given a JavaFX application with the following start() method:
public void start(Stage primaryStage) {
Group mainGroup = new Group();
Rectangle r = new Rectangle(0, 0, 200, 200);
Stop[] stops = new Stop[] { new Stop(0, new Color(0.0, 0.0, 1.0, 1.0)),
new Stop(1, new Color(1.0, 1.0, 1.0, 0.0)) };
LinearGradient lg = new LinearGradient(0, 0, 200, 200, false,
CycleMethod.NO_CYCLE,
stops);
r.setFill(lg);
mainGroup.getChildren().addAll(r);
Scene scene = new Scene(mainGroup, 200, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
This renders as shown in the left window in the attached screenshot. It looks like the opacity is not properly interpolated between the two Stop's. When using the deprecated j2d rendering pipeline with "-Dprism.order=j2d" the output looks as shown in the right window in the attached screenshot, which is the expected output.
Actually, when we retrieve the center pixels of the image like
...
WritableImage image = scene.snapshot(null);
PixelReader pixelReader = image.getPixelReader();
System.out.println("Color: " + pixelReader.getColor((int)image.getWidth()/2, (int)image.getHeight()/2));
...
we get the same value for the alpha channel (seems like opacity is properly interpolated), but different values for the red and green channels:
Default pipeline: Color: 0x0000ff7f
-Dprism.order=j2d pipeline: Color: 0x7e7eff7f
So the issue seems to be that the RGB values are not properly interpolated.
public void start(Stage primaryStage) {
Group mainGroup = new Group();
Rectangle r = new Rectangle(0, 0, 200, 200);
Stop[] stops = new Stop[] { new Stop(0, new Color(0.0, 0.0, 1.0, 1.0)),
new Stop(1, new Color(1.0, 1.0, 1.0, 0.0)) };
LinearGradient lg = new LinearGradient(0, 0, 200, 200, false,
CycleMethod.NO_CYCLE,
stops);
r.setFill(lg);
mainGroup.getChildren().addAll(r);
Scene scene = new Scene(mainGroup, 200, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
This renders as shown in the left window in the attached screenshot. It looks like the opacity is not properly interpolated between the two Stop's. When using the deprecated j2d rendering pipeline with "-Dprism.order=j2d" the output looks as shown in the right window in the attached screenshot, which is the expected output.
Actually, when we retrieve the center pixels of the image like
...
WritableImage image = scene.snapshot(null);
PixelReader pixelReader = image.getPixelReader();
System.out.println("Color: " + pixelReader.getColor((int)image.getWidth()/2, (int)image.getHeight()/2));
...
we get the same value for the alpha channel (seems like opacity is properly interpolated), but different values for the red and green channels:
Default pipeline: Color: 0x0000ff7f
-Dprism.order=j2d pipeline: Color: 0x7e7eff7f
So the issue seems to be that the RGB values are not properly interpolated.