Skip to content

Instantly share code, notes, and snippets.

@deniscostadsc
Created February 13, 2015 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deniscostadsc/a7323284d1acf66ba120 to your computer and use it in GitHub Desktop.
Save deniscostadsc/a7323284d1acf66ba120 to your computer and use it in GitHub Desktop.
Desenhando texto
import java.util.Random;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class DesenhandoTexto extends Application {
@Override
public void start(Stage primaryStage){
Group root = new Group();
Scene scene = new Scene(root, 300, 250, Color.WHITE);
Random rand = new Random(System.currentTimeMillis());
for (int i = 0; i < 100; i++) {
int x = rand.nextInt((int) scene.getWidth());
int y = rand.nextInt((int) scene.getHeight());
int red = rand.nextInt(255);
int green = rand.nextInt(255);
int blue = rand.nextInt(255);
Text text = new Text(x, y, "JavaFX 2.0");
int rot = rand.nextInt(360);
text.setFill(Color.rgb(red, green, blue, .99));
text.setRotate(rot);
root.getChildren().add(text);
}
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args){
launch(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment