generated from Eddie/Backend-Boilerplate
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.0 KiB
30 lines
1.0 KiB
import os, random |
|
from PIL import Image |
|
|
|
light_directory = os.fsencode(str(os.getcwd() + "/planets/light")) |
|
noise_directory = os.fsencode(str(os.getcwd() + "/planets/noise")) |
|
sphere_directory = os.fsencode(str(os.getcwd() + "/planets/sphere")) |
|
|
|
amount_lights = len(os.listdir(light_directory)) |
|
amount_noise = len(os.listdir(noise_directory)) |
|
amount_sphere = len(os.listdir(sphere_directory)) |
|
|
|
|
|
|
|
def blendPlanetParts(light, noise, sphere, alpha): |
|
blended = Image.blend(sphere, light, alpha) |
|
blended2 = Image.blend(blended, noise, alpha) |
|
return blended2 |
|
|
|
|
|
def getRandomPlanet(): |
|
light = Image.open("planets/light/light" + str(random.randrange(0,amount_lights)) + ".png").convert('RGBA') |
|
noise = Image.open("planets/noise/noise" + str(random.randrange(0,amount_noise)) + ".png").convert('RGBA') |
|
sphere = Image.open("planets/sphere/sphere" + str(random.randrange(0,amount_sphere)) + ".png").convert('RGBA') |
|
|
|
planet = blendPlanetParts(light, noise, sphere, 0.1) |
|
|
|
return planet |
|
|
|
planet = getRandomPlanet() |
|
planet.save('planet1.png') |