0
私は2つのSVGパスに異なる色を設定しようとしています。しかし、SVGパスの1つは、2番目のものと同じプロパティを取得するようです。ここでは、コードは次のとおりです。異なる色をsvgパスに設定する
public class MainApp extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Drawing Operations Test");
Group root = new Group();
Canvas canvas = new Canvas(400, 400);
GraphicsContext gc = canvas.getGraphicsContext2D();
gc.setFill(Color.YELLOW);
gc.setStroke(Color.YELLOW);
gc.appendSVGPath("M 50 50 L 150 50 L 100 150 z");
//gc.fill(); //If I uncomment these two lines, the second
//gc.stroke(); //path won't appear
gc.setFill(Color.RED);
gc.setStroke(Color.BLUE);
gc.appendSVGPath("M 200 50 L 300 50 L 250 150 z");
gc.fill();
gc.stroke();
root.getChildren().add(canvas);
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
私は黄色であることを最初のパスを期待していた2番目は赤であることを、私はこの結果を持っている代わりに
私が間違って何をしているのですか? ありがとうございます。