X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=sixth-3d-demos.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fexamples%2Fgalaxy_demo%2FGalaxy.java;fp=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fexamples%2Fgalaxy_demo%2FGalaxy.java;h=73764a9334f789a80d79aa5944863ad008165b51;hp=30ea58dc7087bd65c0d134517b68744e1553cd40;hb=006585b5853331fe4e78699b5cdc70fd5fdccbc9;hpb=480d59637200df8010fe08533b8a1e4e4a651347 diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/galaxy_demo/Galaxy.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/galaxy_demo/Galaxy.java index 30ea58d..73764a9 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/galaxy_demo/Galaxy.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/galaxy_demo/Galaxy.java @@ -18,6 +18,15 @@ import static java.lang.Math.*; public class Galaxy extends AbstractCompositeShape { + /** + * The number of unique colors used in the galaxy. + */ + public static final int UNIQUE_COLORS_COUNT = 30; + + /** + * A list of all colors used in the galaxy. + * Used to reuse textures of glowing points of the same color. + */ private static List colors; public Galaxy(final int galaxySize, final int tailCount, final int starsCount, @@ -69,12 +78,16 @@ public class Galaxy extends AbstractCompositeShape { addShape(new GlowingPoint(starLocation, size, colors.get((int) (random() * colors.size())))); } + /** + * Initializes the list of colors used in the galaxy. + * Used to reuse textures of glowing points of the same color. + */ private synchronized void ensureColorsAreInitialized() { if (colors != null) return; colors = new ArrayList<>(); - for (int i = 0; i < 30; i++) + for (int i = 0; i < UNIQUE_COLORS_COUNT; i++) colors.add( new Color( random() + 0.5,