Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * bem10jfx.blogspot.com
- laps inds efects
- */
- package pensa;
- import java.util.Random;
- import javafx.animation.Interpolator;
- import javafx.animation.Timeline;
- import javafx.animation.TranslateTransition;
- import javafx.application.Application;
- import javafx.event.EventHandler;
- import javafx.scene.Group;
- import javafx.scene.Scene;
- import javafx.scene.input.MouseEvent;
- import javafx.scene.layout.VBox;
- import javafx.scene.paint.Color;
- import javafx.scene.shape.Rectangle;
- import javafx.scene.text.Text;
- import javafx.stage.Stage;
- import javafx.util.Duration;
- /**
- * speeds
- */
- public class pensa extends Application {
- int vlh,vlw;
- int vlHpres,vlWpres;
- @Override
- public void start(Stage stage) {
- final Group go=new Group();
- final Scene scene=new Scene(go,400,400, Color.BLACK);
- stage.setScene(scene);
- final Text txh,txw,txhpres,txwpres,txflux;
- VBox vbox=new VBox();
- go.getChildren().add(vbox);
- txh=new Text ("h :"+vlw);
- txw=new Text ("w :"+vlh);
- txhpres=new Text("hpress :"+vlWpres);
- txwpres=new Text("wpress :"+vlHpres);
- txflux=new Text("Event:");
- final Text txColor = new Text("CorRand:");
- txh.setFill(Color.BLUE);
- txw.setFill(Color.BLUE);
- txhpres.setFill(Color.BLUE);
- txwpres.setFill(Color.BLUE);
- txflux.setFill(Color.BLUE);
- txColor.setFill(Color.BLUE);
- vbox.getChildren().addAll(txh,txw,txhpres,txwpres,txflux,txColor);
- scene.setOnMouseDragged(new EventHandler<MouseEvent>() {
- @Override
- public void handle(MouseEvent event) {
- int cont =1;
- cont++;
- vlh=(int) event.getY();
- vlw=(int) event.getX();
- txh.setText("h :"+vlh);
- txw.setText("w :"+vlw);
- txflux.setText("Event :"+cont+"");
- String strEntry1 = "'=')";
- txColor.setText("CorRand:"+ strEntry1);
- //cor rando atual
- Random randOne[]=new Random[112];
- Random randsamir[]=new Random[112];
- Rectangle rectcolors[] = new Rectangle[1000] ;
- Timeline tl[]=new Timeline[1000];
- for (int i = 0; i < 1000; i++) {
- randOne[i]=new Random(System.nanoTime());
- randsamir[i]=new Random(System.nanoTime());
- rectcolors[i]=new Rectangle();
- rectcolors[i].setHeight(5);
- rectcolors[i].setWidth(5);
- int c = randOne[i].nextInt((int )252),
- o = randsamir[i].nextInt((int) 5.6 ),
- r = 250;
- rectcolors[i].setFill(Color.rgb( o,r,c));
- rectcolors[i].setX(vlw);
- rectcolors[i].setY(vlh-20);
- TranslateTransition tt=new TranslateTransition(Duration.millis(10000), rectcolors[i]);
- tt.setCycleCount(Timeline.INDEFINITE);
- tt.setDelay(Duration.millis(10000));
- tt.setFromX(vlw);
- tt.setFromY(vlh-20);
- tt.toXProperty().bind(rectcolors[i].xProperty().divide(rectcolors[i].xProperty()).subtract(30));
- tt.toYProperty().bind(rectcolors[i].yProperty().divide(rectcolors[i].yProperty()).subtract(30));
- // tt.setToX (( rectcolors[i].getX())+randsamir[i].nextInt());
- //tt.setToY(( rectcolors[i].getY())+randsamir[i].nextInt());
- tt.setByX(vlw);
- tt.setByY(vlw-20);
- tt.play();
- go.getChildren().add(rectcolors[i]);
- txColor.setText("CorRand:"+ rectcolors[i].fillProperty().getValue().toString());
- txColor.setFill(Color.web(rectcolors[i].fillProperty().getValue().toString()));
- System.out.println("x"+i);
- }
- }
- });
- scene.setOnMouseReleased(new EventHandler<MouseEvent>() {
- @Override
- public void handle(MouseEvent event) {
- vlHpres=(int) event.getY();
- vlWpres=(int) event.getY();
- txhpres.setText("h :"+vlw);
- txwpres.setText("w :"+vlh);
- }
- });
- stage.show();
- }
- public static void main(String[] args) {
- launch(args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment