digrach

ParticleCanvas1

Mar 28th, 2014
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.70 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import javafx.animation.AnimationTimer;
  4. import javafx.scene.Scene;
  5. import javafx.scene.canvas.Canvas;
  6. import javafx.scene.canvas.GraphicsContext;
  7. import javafx.scene.layout.FlowPane;
  8. import javafx.scene.paint.Color;
  9. import javafx.scene.paint.CycleMethod;
  10. import javafx.scene.paint.Paint;
  11. import javafx.scene.paint.RadialGradient;
  12. import javafx.scene.paint.Stop;
  13. import javafx.stage.Stage;
  14.  
  15. public class ParticleCanvas extends Stage {
  16.  
  17.     // Constant data members.
  18.     private final String STAGE_TITLE = "Particle Stage";
  19.     private final double SCENE_WIDTH = 800;
  20.     private final double SCENE_HEIGHT = 600;
  21.  
  22.     // Variable data members.
  23.  
  24.     private FlowPane root;
  25.     private Scene scene;
  26.     private Canvas canvas;
  27.  
  28.     private  Paint[] colors = null;
  29.     private GraphicsContext graphicsContext;
  30.     private static AnimationTimer timer = null;
  31.  
  32.     private int countDownTillNextParticle = 40;
  33.  
  34.     private int particleWidth = 5;
  35.     private int particleHeight = 5;
  36.     private int buffer = 0;
  37.  
  38.     private final List<Particle> particles = new ArrayList<Particle>();
  39.     private List<Particle>[] checkList;
  40.  
  41.  
  42.     public ParticleCanvas() {
  43.  
  44.     }
  45.  
  46.     private void AddParticle() {
  47.  
  48.     }
  49.  
  50.     private void drawParticles(GraphicsContext gc) {
  51.  
  52.     }
  53.  
  54.     public void updateParticles() {
  55.  
  56.     }
  57.  
  58.     public boolean checkForColision(Particle p) {
  59.         return false;
  60.     }
  61.  
  62.     private int makeMinXCoord() {
  63.         return 0;
  64.     }
  65.  
  66.     private int makeMinYCoord() {
  67.         return 0;
  68.     }
  69.  
  70.     private int makeMaxXCoord() {
  71.         return 0;
  72.     }
  73.  
  74.     private int makeMaxYCoord() {
  75.         return 0;
  76.     }
  77.  
  78.     private int makeRandomNumInRange(int min, int max) {
  79.         return 0;
  80.     }
  81.  
  82.     public void makeColors() {
  83.         // create a color palette of 180 colors
  84.         colors = new Paint[181];
  85.         colors[0] = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE,
  86.                 new Stop(0, Color.WHITE),
  87.                 new Stop(0.2, Color.hsb(59, 0.38, 1)),
  88.                 new Stop(0.6, Color.hsb(59, 0.38, 1,0.1)),
  89.                 new Stop(1, Color.hsb(59, 0.38, 1,0))
  90.                 );
  91.         for (int h=0;h<360;h+=2) {
  92.             colors[1+(h/2)] = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE,
  93.                     new Stop(0, Color.WHITE),
  94.                     new Stop(0.2, Color.hsb(h, 1, 1)),
  95.                     new Stop(0.6, Color.hsb(h, 1, 1,0.1)),
  96.                     new Stop(1, Color.hsb(h, 1, 1,0))
  97.                     );
  98.         }
  99.     }
  100.  
  101.     private void initialiseMyStage() {
  102.  
  103.         this.setResizable(false);
  104.         this.setTitle(STAGE_TITLE);
  105.  
  106.         root = new FlowPane();
  107.         root.setStyle("-fx-background-color: #336699;");
  108.         root.setPrefSize(SCENE_WIDTH, SCENE_HEIGHT);
  109.  
  110.         canvas = new Canvas(SCENE_WIDTH, SCENE_HEIGHT);
  111.  
  112.         root.getChildren().add(canvas);
  113.  
  114.         scene = new Scene(root, SCENE_WIDTH, SCENE_HEIGHT, Color.PINK);
  115.  
  116.         this.setScene(scene);
  117.     }
  118.  
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment