From 89e0367fdecf2092a0eafcd670b114b9f8333ebe Mon Sep 17 00:00:00 2001 From: Sam Carlberg Date: Thu, 30 Mar 2017 01:26:23 -0400 Subject: [PATCH] Change to dark color theme. Should probably depend on #832 Small improvements to hex grid placement, no more weird boders --- .../edu/wpi/grip/preloader/GripPreloader.java | 65 +++++++++---------- .../edu/wpi/grip/preloader/Preloader.css | 3 +- .../edu/wpi/grip/preloader/Preloader.fxml | 4 ++ 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/ui/preloader/src/main/java/edu/wpi/grip/preloader/GripPreloader.java b/ui/preloader/src/main/java/edu/wpi/grip/preloader/GripPreloader.java index 48561ff6c4..b0d0ba21bb 100644 --- a/ui/preloader/src/main/java/edu/wpi/grip/preloader/GripPreloader.java +++ b/ui/preloader/src/main/java/edu/wpi/grip/preloader/GripPreloader.java @@ -5,27 +5,27 @@ import javafx.animation.Animation; import javafx.animation.FillTransition; +import javafx.application.Platform; import javafx.application.Preloader; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; -import javafx.stage.Screen; import javafx.stage.Stage; import javafx.stage.StageStyle; import javafx.util.Duration; public final class GripPreloader extends Preloader { - private static final Color primaryColor = Color.color(0.5, 0.8, 0.5); - private static final Color secondaryColor = primaryColor.deriveColor(1, 1, 0.75, 1); + private static final Color primaryColor = Color.gray(0.075); + private static final Color secondaryColor = Color.gray(0.1); // Animation timings - private static final double minTime = 0.25; - private static final double maxTime = 0.50; + private static final double minTime = 1 / 3.0; + private static final double maxTime = 2 / 3.0; - private static final double HEXAGON_RADIUS = 16; + private static final double HEXAGON_RADIUS = 12; private Stage preloaderStage; @@ -37,35 +37,32 @@ public static void main(String[] args) { public void start(Stage preloaderStage) throws IOException { final StackPane root = FXMLLoader.load(GripPreloader.class.getResource("Preloader.fxml")); - Screen screen = Screen.getPrimary(); - // Animated hexagon grid background - - Random random = new Random(System.currentTimeMillis() ^ (System.currentTimeMillis() >> 16)); - HexagonGrid hexagonGrid = new HexagonGrid( - (int) ((screen.getBounds().getWidth() / 4) / HEXAGON_RADIUS), - (int) ((screen.getBounds().getHeight() / 4) / HEXAGON_RADIUS), - HEXAGON_RADIUS, - 2); - // animate the hexagons - hexagonGrid.hexagons() - .stream() - .map(h -> new FillTransition( - Duration.seconds( - clamp(random.nextGaussian() + 1, 0, 2) * (maxTime - minTime) + minTime), - h, primaryColor, secondaryColor)) - .peek(t -> t.setCycleCount(Animation.INDEFINITE)) - .peek(t -> t.setAutoReverse(true)) - .forEach(t -> t.playFrom(Duration.seconds(random.nextDouble() * maxTime * 16))); - Pane backgroundContainer = new Pane(hexagonGrid); - - // bring the hexagons to the top and left edges to avoid weird blank spots - hexagonGrid.setTranslateX(-HEXAGON_RADIUS * 2); - hexagonGrid.setTranslateY(-HEXAGON_RADIUS * 2); - - // make the background as small as possible (avoids whitespace on bottom and right edges) - backgroundContainer.setPrefSize(0, 0); - root.getChildren().add(0, backgroundContainer); + // wrap in runLater so we can get the size of the scene + Platform.runLater(() -> { + Random random = new Random(System.currentTimeMillis() ^ (System.currentTimeMillis() >> 16)); + HexagonGrid hexagonGrid = new HexagonGrid( + (int) (preloaderStage.getScene().getWidth() / HEXAGON_RADIUS), + (int) (preloaderStage.getScene().getHeight() / HEXAGON_RADIUS), + HEXAGON_RADIUS, + 0); + // animate the hexagons + hexagonGrid.hexagons() + .stream() + .map(h -> new FillTransition( + Duration.seconds( + clamp(random.nextGaussian() + 1, 0, 2) * (maxTime - minTime) + minTime), + h, primaryColor, secondaryColor)) + .peek(t -> t.setCycleCount(Animation.INDEFINITE)) + .peek(t -> t.setAutoReverse(true)) + .forEach(t -> t.playFrom(Duration.seconds(random.nextDouble() * maxTime * 16))); + Pane backgroundContainer = new Pane(hexagonGrid); + + // bring the hexagons to the top edge to avoid weird blank spots + backgroundContainer.setTranslateY(-HEXAGON_RADIUS); + + root.getChildren().add(0, backgroundContainer); + }); Scene scene = new Scene(root); diff --git a/ui/preloader/src/main/resources/edu/wpi/grip/preloader/Preloader.css b/ui/preloader/src/main/resources/edu/wpi/grip/preloader/Preloader.css index b71134056e..a0237ede1d 100644 --- a/ui/preloader/src/main/resources/edu/wpi/grip/preloader/Preloader.css +++ b/ui/preloader/src/main/resources/edu/wpi/grip/preloader/Preloader.css @@ -1,4 +1,3 @@ .root { - -fx-padding: 25; - -fx-background-color: darkseagreen; + -fx-background-color: #111111; } diff --git a/ui/preloader/src/main/resources/edu/wpi/grip/preloader/Preloader.fxml b/ui/preloader/src/main/resources/edu/wpi/grip/preloader/Preloader.fxml index ff07fbd74a..86ed782a0c 100644 --- a/ui/preloader/src/main/resources/edu/wpi/grip/preloader/Preloader.fxml +++ b/ui/preloader/src/main/resources/edu/wpi/grip/preloader/Preloader.fxml @@ -6,6 +6,7 @@ + @@ -17,6 +18,9 @@ + + +