我想用灰色填充一定比例的绿色圆圈。我试图让灰色弧线占据60%的圆,但是它不起作用:
import javafx.application.Application;
import javafx.geometry.Orientation;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
public class CircleArc extends Application {
@Override
public void start(Stage applicationStage) {
ScrollPane scrollPane = new ScrollPane();
scrollPane.setFitToWidth(true);
FlowPane flowPane = new FlowPane();
flowPane.setOrientation(Orientation.HORIZONTAL);
Circle circle = new Circle(100);
circle.setFill(Color.GREEN);
Arc arc = new Arc(0, 0, 100, 100,
-360 * 0.6, Math.toDegrees(0.6 * Math.PI));
arc.setType(ArcType.ROUND);
arc.setFill(Color.GRAY);
Group group = new Group();
group.getChildren().add(circle);
group.getChildren().add(arc);
flowPane.getChildren().add(group);
scrollPane.setContent(flowPane);
Scene scene = new Scene(scrollPane);
applicationStage.setScene(scene);
applicationStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
我做错什么了?
1条答案
按热度按时间6rqinv9w1#
我想出来了。正确方法:
因此,灰色是圆圈的60%,绿色是40%。