不知道这里出现了什么错误。可以运行出来,但有错,望指正

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class JavaFXApplicationHeart extends Application {
@Override
public void start(Stage primaryStage) {
int width, height;
Canvas canvas = new Canvas(350, 350);
width = (int) canvas.getWidth();
height = (int) canvas.getHeight();
GraphicsContext gc = canvas.getGraphicsContext2D();
double x, y, r;
for (int i = 0; i <= 90; i++) {
for (int j = 0; j <= 90; j++) {
//转换为直角坐标系,设置偏移量,使图像居中
r = Math.PI / 45 * i * (1 - Math.sin(Math.PI / 45 * j)) * 19;
x = r * Math.cos(Math.PI / 45 * j) * Math.sin(Math.PI / 45 * i) + width / 2;
y = -r * Math.sin(Math.PI / 45 * j) + height / 4;
gc.setFill(Color.RED);
gc.fillOval(x, y, 2, 2);
gc.fillOval(x, y, 1, 1);
}
}
StackPane root = new StackPane();
root.getChildren().add(canvas);
Scene scene = new Scene(root, Color.BLACK);
primaryStage.setTitle("r=a(1-sinθ)");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}



李健钊
浏览 2228回答 4
4回答

WXLEO

楼主请贴报错的代码,看报错代码才能给你解决方案

hsbdbdjxjdb

请求报错截图

小冲_rdmxc

请问,报什么错?你就给段代码?

李健钊

请各位大神帮帮忙急用
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java
JavaScript