解释JavaFX中3D形状的绘制模式面属性
例
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.shape.DrawMode;
import javafx.scene.shape.Sphere;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
public class DrawModeProperty extends Application {
public void start(Stage stage) {
//绘制球体
Sphere sphere1 = new Sphere(100);
sphere1.setTranslateX(80.0);
sphere1.setTranslateY(180.0);
sphere1.setTranslateZ(150.0);
//Setting the property "draw mode"
sphere1.setDrawMode(DrawMode.LINE);
//绘制球体
Sphere sphere2 = new Sphere(100);
sphere2.setTranslateX(380.0);
sphere2.setTranslateY(180.0);
sphere2.setTranslateZ(150.0);
//Setting the property "draw mode"
sphere2.setDrawMode(DrawMode.FILL);
//设置透视相机
PerspectiveCamera cam = new PerspectiveCamera();
cam.setTranslateX(-50);
cam.setTranslateY(50);
cam.setTranslateZ(0);
Font font = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 15);
Text label1 = new Text("Draw Mode: LINE");
label1.setFont(font);
label1.setX(40);
label1.setY(300);
Text label2 = new Text("Draw Mode: FILL");
label2.setFont(font);
label2.setX(280);
label2.setY(300);
//设置场景
Group root = new Group(sphere1, sphere2, label1, label2);
Scene scene = new Scene(root, 595, 300, Color.BEIGE);
scene.setCamera(cam);
stage.setTitle("3D Shape Property: Draw Mode");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]){
launch(args);
}
}输出结果
热门推荐
1 潜能开发训练狗狗
2 狗狗多会训练好
3 扣篮训练狗狗
5 狗狗不训练
6 少儿柔术训练狗狗
8 训练好狗狗
9 训练狗狗怎么训
10 狗狗训练猫咪
11 狗狗训练地点
12 两个多月的狗狗怎么训练
13 怎么训练狗狗去厕所拉屎
14 狗狗怎样训练大小便
15 训练狗狗母
16 怎么训练狗狗坐下和握手
17 近视训练狗狗
18 狗狗倒的训练