Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8096577

RadialGradient renders bad when elliptical

    Details

      Description

      Apparently RadialGradient has issue computing the proper radii when applied to non square/circular surface.

      The gradient rendered on screen is not what it is supposed to be. Take the following example:

      public class Test extends Application {

          @Override
          public void start(Stage primaryStage) {
              final Rectangle rectangle = new Rectangle(100, 100, 150, 100);
              rectangle.setFill(new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop(0, Color.RED), new Stop(0.5, Color.GREEN), new Stop(1, Color.BLUE)));
              final Pane root = new Pane();
              root.getChildren().add(rectangle);
              final Scene scene = new Scene(root, 600, 600);
              primaryStage.setTitle("Test");
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              launch(args);
          }
      }

      As of u_20 and under Windows, the blue color is barely present on screen. In fact, the green color which is set to be at the middle of the gradient overpasses all 4 borders of the rectangle on both the X and Y axis. It should not do that.

      Now take a look at http://www.w3schools.com/css/tryit.asp?filename=trycss3_gradient-radial where a similar gradient is rendered in HTML (requires IE version > 9).

      Here, the blue color sits on the very edge of the rectangle on the X and Y axis. The blue color is fully visible within the 4 corners (as those areas are beyond the radii of the ellipse).
      This is how the JavaFX radial gradient should be rendered. Currently it is not.

        Attachments

          Activity

            People

            • Assignee:
              flar Jim Graham
              Reporter:
              fbouyajfx Fabrice Bouyé (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: