원형 경로를 구축하고 이미지를 그릴 때 클립으로 사용 :
이
@Override
public void start(Stage primaryStage) {
Image image = new Image("https://i.stack.imgur.com/zEoW1.jpg");
double w = image.getWidth();
double h = image.getHeight();
Canvas canvas = new Canvas(w, h);
GraphicsContext gc = canvas.getGraphicsContext2D();
// draw background
gc.setFill(Color.BLACK);
gc.fillRect(0, 0, w, h);
double r = Math.min(h, w) * 2/5;
double cx = w/2;
double cy = h/2;
// create circular path
gc.beginPath();
gc.moveTo(cx - r, cy); // to first point on the circle
gc.arc(cx, cy, r, r, 180, 360);
gc.closePath();
gc.clip();
gc.drawImage(image, 0, 0);
StackPane root = new StackPane();
root.getChildren().add(canvas);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
내가 이것을 사용합니다,하지만 불행히도 나는 게임을하고, 그래서 캔버스 – MCMastery
@MCMastery을 사용하고 있습니다 Fabian의 방법이 선호되지만 GraphicsContext는 [BlendMode]를 지원합니다 (http://docs.oracle.com/javase/8/javafx/api/javafx/scene/canvas/GraphicsContext.html#setGlobalBlendMode-javafx.scene.effect .BlendMode-). 당신이 해결책을 찾지 못했다면, 당신은 그것을 살펴볼 수 있습니다. – Jai