Created
February 13, 2015 21:35
-
-
Save deniscostadsc/a7323284d1acf66ba120 to your computer and use it in GitHub Desktop.
Desenhando texto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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