A nebula generator written with libgdx
Ensure that you have jitpack dependencies source in your build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}Then, add this dependency:
dependencies {
implementation 'com.github.alyrow:Nebula-Generator:v1.1.0'
}A generator is defined by:
NebulaGenerator generator = new NebulaGenerator(width, height, noise_type, seed, octave,
color, alpha, offset);Where width and height are the size of the nebula, noise_type, seed and octave are settings wich define how the nebula looks. color defines the color of the nebula and alpha the level of alpha of the nebula. offset defines the displacement of the nebula.
After that you can generate the nebula to a pixmap or a texture with:
generator.generatePixmapNebula()
// Or
generator.generateTextureNebula()If you want to combine multiple nebula, use NebulasGenerator:
NebulasGenerator nebulasGenerator = new NebulasGenerator(width, height);
nebulasGenerator.addGenerator(generator1);
nebulasGenerator.addGenerator(generator2);Where width and height are the size of nebulas and generator1 and generator2 are NebulaGenerator.
After that you can generate nebulas to a pixmap or a texture with:
nebulasGenerator.generatePixmapNebulas()
// Or
nebulasGenerator.generateTextureNebulas()You can also combine your nebula with another pixmap for exemple with stars, with or without gamma correction:
generator.generatePixmapNebulaBlendedWithAPixmap(your_pixmap_ex_stars);
// Or
generator.generateTextureNebulaBlendedWithAPixmap(your_pixmap_ex_stars);generator.generatePixmapNebulaBlendedWithAPixmapGammaCorrection(your_pixmap_ex_stars);
// Or
generator.generateTextureNebulaBlendedWithAPixmapGammaCorrection(your_pixmap_ex_stars);nebulasGenerator.generatePixmapNebulasBlendedWithAPixmap(your_pixmap_ex_stars);
// Or
nebulasGenerator.generateTextureNebulasBlendedWithAPixmap(your_pixmap_ex_stars);nebulasGenerator.generatePixmapNebulasBlendedWithAPixmapGammaCorrection(your_pixmap_ex_stars);
// Or
nebulasGenerator.generateTextureNebulasBlendedWithAPixmapGammaCorrection(your_pixmap_ex_stars);NebulaGenerator generator1 = new NebulaGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), DEFAULT, 12955341, 8,
new Color(0.1f,0.1f,1f,1), 1f, new Vector2(0,180));
NebulaGenerator generator2 = new NebulaGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), HONEY_NOISE, 78912345, 9,
new Color(0.8f,0.4f,0.6f,1), 1f, new Vector2(0,0));
NebulasGenerator nebulasGenerator = new NebulasGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
nebulasGenerator.addGenerator(generator1);
nebulasGenerator.addGenerator(generator2);
Pixmap nebula = nebulasGenerator.generatePixmapNebulasBlendedWithAPixmap(new Pixmap(Gdx.files.absolute("path to stars background")));NebulaGenerator generator1 = new NebulaGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), DEFAULT, 12955341, 8,
new Color(0.1f,0.1f,1f,1), 3f, new Vector2(0,180));
NebulaGenerator generator2 = new NebulaGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), HONEY_NOISE, 78912345, 9,
new Color(0.8f,0.4f,0.6f,1), 3f, new Vector2(0,0));
NebulasGenerator nebulasGenerator = new NebulasGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
nebulasGenerator.addGenerator(generator1);
nebulasGenerator.addGenerator(generator2);
Pixmap nebula = nebulasGenerator.generatePixmapNebulasBlendedWithAPixmap(new Pixmap(Gdx.files.absolute("path to stars background")));NebulaGenerator generator1 = new NebulaGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), DEFAULT, 12955341, 8,
new Color(0.1f,0.1f,1f,1), 1f, new Vector2(0,180));
NebulaGenerator generator2 = new NebulaGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), HONEY_NOISE, 78912345, 9,
new Color(0.8f,0.4f,0.6f,1), 1f, new Vector2(0,0));
NebulasGenerator nebulasGenerator = new NebulasGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
nebulasGenerator.addGenerator(generator1);
nebulasGenerator.addGenerator(generator2);
Pixmap nebula = nebulasGenerator.generatePixmapNebulasBlendedWithAPixmapGammaCorrection(new Pixmap(Gdx.files.absolute("path to stars background")));NebulaGenerator generator1 = new NebulaGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), DEFAULT, 12955341, 8,
new Color(0.1f,0.1f,1f,1), 3f, new Vector2(0,180));
NebulaGenerator generator2 = new NebulaGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), HONEY_NOISE, 78912345, 9,
new Color(0.8f,0.4f,0.6f,1), 3f, new Vector2(0,0));
NebulasGenerator nebulasGenerator = new NebulasGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
nebulasGenerator.addGenerator(generator1);
nebulasGenerator.addGenerator(generator2);
Pixmap nebula = nebulasGenerator.generatePixmapNebulasBlendedWithAPixmapGammaCorrection(new Pixmap(Gdx.files.absolute("path to stars background")));Yes nebula can be used for other things than nebulas! Not perfect but a good start.
NebulaGenerator generator1 = new NebulaGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), DEFAULT, 12955341, 8,
new Color(0.8f,0.8f,0.8f,1), 1f, new Vector2(0,-380));
NebulaGenerator generator2 = new NebulaGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), HONEY_NOISE, 78912345, 9,
new Color(0.8f,0.8f,0.8f,1), 1f, new Vector2(0,-1000));
NebulasGenerator nebulasGenerator = new NebulasGenerator(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
nebulasGenerator.addGenerator(generator1);
nebulasGenerator.addGenerator(generator2);
Pixmap nebula = nebulasGenerator.generatePixmapNebulasBlendedWithAPixmap(new Pixmap(Gdx.files.absolute("path to forest.png")));