import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.scene.paint.CycleMethod; import javafx.scene.paint.LinearGradient; import javafx.scene.paint.Stop; import javafx.stage.Stage; public class PolyTransformFlushBug extends Application { public static double xpoints[] = { 10, 70, 10, 70 }; public static double ypoints[] = { 10, 10, 70, 70 }; @Override public void start(Stage stage) { Canvas cv1 = makeCanvas(false); Canvas cv2 = makeCanvas(true); HBox box = new HBox(cv1, cv2); stage.setScene(new Scene(box)); stage.show(); } public Canvas makeCanvas(boolean workaround) { Canvas cv = new Canvas(400, 400); GraphicsContext gc = cv.getGraphicsContext2D(); gc.setFill(Color.WHITE); gc.fillRect(0, 0, 400, 400); gc.scale(5, 5); if (workaround) { gc.fillRect(0, 0, 1, 1); } gc.setLineWidth(10); LinearGradient lg = new LinearGradient(0.0, 0.0, 70.0, 70.0, false, CycleMethod.REFLECT, new Stop(0.0, Color.BLUE), new Stop(1.0, Color.GREEN)); gc.setStroke(lg); gc.strokePolygon(xpoints, ypoints, xpoints.length); return cv; } }