ugh that lab was fun but draining
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Ellipse;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class ShowElipse1 extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
// Create a scene and place it in the stage
|
||||
Scene scene = new Scene(new My32Ellipses(), 800, 600);
|
||||
primaryStage.setTitle("Show 32 Ellipses");
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
||||
class My32Ellipses extends Pane {
|
||||
private void paint32Ellipses() {
|
||||
getChildren().clear();
|
||||
// draw 32 rotated ellipses on top of each other
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
// Create an ellipse and add it to the pane
|
||||
Ellipse e1 = new Ellipse(
|
||||
getWidth() / 2, getHeight() / 2,
|
||||
getWidth() / 2 - 120, getHeight() / 2 - 120);
|
||||
e1.setStroke(Color.color(Math.random(),
|
||||
Math.random(),
|
||||
Math.random()
|
||||
)
|
||||
);
|
||||
e1.setFill(Color.WHITE);
|
||||
e1.setRotate(i * 180 / 32);
|
||||
getChildren().add(e1);
|
||||
}
|
||||
}
|
||||
@Override public void setWidth(double width) {
|
||||
super.setWidth(width);
|
||||
paint32Ellipses();
|
||||
}
|
||||
@Override public void setHeight(double height) {
|
||||
super.setHeight(height);
|
||||
paint32Ellipses();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user