├── Examples ├── Generative-Space-Flat-1280w-720h.png ├── Generative-Space-Flat-2000w-1000h.png ├── Generative-Space-Flat-2000w-2000h.png ├── Generative-Space-Flat-2000w-3000h.png ├── Generative-Space-Flat-3000w-1001h.png ├── Generative-Space-Flat-3000w-1002h.png ├── Generative-Space-Flat-3000w-1201h.png ├── Generative-Space-Flat-3000w-1501h.png ├── Generative-Space-Flat-3000w-1502h.png ├── Generative-Space-Flat-3000w-2001h.png ├── Generative-Space-Texture-1280w-720h.png ├── Generative-Space-Texture-2000w-1000h.png ├── Generative-Space-Texture-2000w-2000h.png ├── Generative-Space-Texture-2000w-3000h.png ├── Generative-Space-Texture-3000w-1001h.png ├── Generative-Space-Texture-3000w-1002h.png ├── Generative-Space-Texture-3000w-1201h.png ├── Generative-Space-Texture-3000w-1501h.png ├── Generative-Space-Texture-3000w-1502h.png └── Generative-Space-Texture-3000w-2001h.png ├── Generative-Space-System.py └── README.md /Examples/Generative-Space-Flat-1280w-720h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Flat-1280w-720h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Flat-2000w-1000h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Flat-2000w-1000h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Flat-2000w-2000h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Flat-2000w-2000h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Flat-2000w-3000h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Flat-2000w-3000h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Flat-3000w-1001h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Flat-3000w-1001h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Flat-3000w-1002h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Flat-3000w-1002h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Flat-3000w-1201h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Flat-3000w-1201h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Flat-3000w-1501h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Flat-3000w-1501h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Flat-3000w-1502h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Flat-3000w-1502h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Flat-3000w-2001h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Flat-3000w-2001h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Texture-1280w-720h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Texture-1280w-720h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Texture-2000w-1000h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Texture-2000w-1000h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Texture-2000w-2000h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Texture-2000w-2000h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Texture-2000w-3000h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Texture-2000w-3000h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Texture-3000w-1001h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Texture-3000w-1001h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Texture-3000w-1002h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Texture-3000w-1002h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Texture-3000w-1201h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Texture-3000w-1201h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Texture-3000w-1501h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Texture-3000w-1501h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Texture-3000w-1502h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Texture-3000w-1502h.png -------------------------------------------------------------------------------- /Examples/Generative-Space-Texture-3000w-2001h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/erdavids/Generative-Space-System/f0228da23668b108a4a2e6a9d78a18c0e80fa383/Examples/Generative-Space-Texture-3000w-2001h.png -------------------------------------------------------------------------------- /Generative-Space-System.py: -------------------------------------------------------------------------------- 1 | import cairo, PIL, argparse, math, random 2 | from PIL import Image, ImageDraw 3 | 4 | list_of_colors = [(145, 185, 141), (229, 192, 121), (210, 191, 88), (140, 190, 178), (255, 183, 10), (189, 190, 220), 5 | (221, 79, 91), (16, 182, 98), (227, 146, 80), (241, 133, 123), (110, 197, 233), (235, 205, 188), (197, 239, 247), (190, 144, 212), 6 | (41, 241, 195), (101, 198, 187), (255, 246, 143), (243, 156, 18), (189, 195, 199), (243, 241, 239)] 7 | 8 | float_gen = lambda a, b: random.uniform(a, b) 9 | 10 | def draw_orbit(cr, line, x, y, radius, r, g, b): 11 | cr.set_line_width(line) 12 | cr.arc(x, y, radius, 0, 2*math.pi) 13 | cr.stroke() 14 | 15 | def draw_circle_fill(cr, x, y, radius, r, g, b): 16 | cr.set_source_rgb(r, g, b) 17 | cr.arc(x, y, radius, 0, 2*math.pi) 18 | cr.fill() 19 | 20 | def draw_border(cr, size, r, g, b, width, height): 21 | cr.set_source_rgb(r, g, b) 22 | cr.rectangle(0, 0, size, height) 23 | cr.rectangle(0, 0, width, size) 24 | cr.rectangle(0, height-size, width, size) 25 | cr.rectangle(width-size, 0, size, height) 26 | cr.fill() 27 | 28 | def draw_background(cr, r, g, b, width, height): 29 | cr.set_source_rgb(r, g, b) 30 | cr.rectangle(0, 0, width, height) 31 | cr.fill() 32 | 33 | def main(): 34 | parser = argparse.ArgumentParser() 35 | parser.add_argument("--width", help="Specify Width", default=3000, type=int) 36 | parser.add_argument("--height", help="Specify Height", default=2000, type=int) 37 | parser.add_argument("-o", "--orbit", help="Actual Orbits", action="store_true") 38 | parser.add_argument("-l", "--line", help=".", action="store_true") 39 | parser.add_argument("-s", "--sunsize", help=".", default=random.randint(200, 400), type=int) 40 | parser.add_argument("-bs", "--bordersize", help=".", default=50, type=int) 41 | parser.add_argument("-n", "--noise", help="Texture", default=.4, type=float) 42 | args = parser.parse_args() 43 | 44 | width, height = args.width, args.height 45 | border_size = args.bordersize 46 | sun_size = args.sunsize 47 | 48 | sun_center = height - border_size 49 | 50 | ims = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) 51 | cr = cairo.Context(ims) 52 | 53 | draw_background(cr, .3, .3, .3, width, height) 54 | 55 | sun_color = random.choice(list_of_colors) 56 | sun_r, sun_g, sun_b = sun_color[0]/255.0, sun_color[1]/255.0, sun_color[2]/255.0 57 | 58 | draw_circle_fill(cr, width/2, sun_center, sun_size, sun_r, sun_g, sun_b) 59 | 60 | distance_between_planets = 20 61 | last_center = sun_center 62 | last_size = sun_size 63 | last_color = sun_color 64 | 65 | min_size = 5 66 | max_size = 70 67 | 68 | for x in xrange(1, 20): 69 | next_size = random.randint(min_size, max_size) 70 | next_center = last_center - last_size - (next_size * 2) - distance_between_planets 71 | 72 | if not(next_center - next_size < border_size): 73 | if(args.orbit): 74 | draw_orbit(cr, 4, width/2, sun_center, height - next_center - border_size, .6, .6, .6) 75 | elif(args.line): 76 | cr.move_to(border_size * 2, next_center) 77 | cr.line_to(width-(border_size*2), next_center) 78 | cr.stroke() 79 | 80 | draw_circle_fill(cr, width/2, next_center, next_size*1.3, .3, .3, .3) 81 | 82 | rand_color = random.choice(list_of_colors) 83 | while (rand_color is last_color): 84 | rand_color = random.choice(list_of_colors) 85 | 86 | last_color = rand_color 87 | 88 | r, g, b = rand_color[0]/255.0, rand_color[1]/255.0, rand_color[2]/255.0 89 | 90 | draw_circle_fill(cr, width/2, next_center, next_size, r, g, b) 91 | 92 | last_center = next_center 93 | last_size = next_size 94 | 95 | min_size += 5 96 | max_size += 5 * x 97 | 98 | draw_border(cr, border_size, sun_r, sun_g, sun_b, width, height) 99 | 100 | ims.write_to_png('Examples/Generative-Space-Flat-' + str(width) + 'w-' + str(height) + 'h.png') 101 | 102 | pil_image = Image.open('Examples/Generative-Space-Flat-' + str(width) + 'w-' + str(height) + 'h.png') 103 | pixels = pil_image.load() 104 | 105 | for i in range(pil_image.size[0]): 106 | for j in range(pil_image.size[1]): 107 | r, g, b = pixels[i, j] 108 | 109 | noise = float_gen(1.0 - args.noise, 1.0 + args.noise) 110 | pixels[i, j] = (int(r*noise), int(g*noise), int(b*noise)) 111 | pil_image.save('Examples/Generative-Space-Texture-' + str(width) + 'w-' + str(height) + 'h.png') 112 | 113 | if __name__ == "__main__": 114 | main() 115 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Randomly Generated Solar Systems 2 | 3 | A few different choices for customization that result in neat looking, poster-ready images. 4 | 5 | Everything is extremely simple right now, but I would like to add a few improvements in the future: 6 | 7 | * Planets of different shapes 8 | * Orbiting moons 9 | * Asteroid belts 10 | * Vector designs 11 | * Better texture 12 | 13 | For a tutorial on the basic process, check out [this video](https://www.youtube.com/watch?v=XSgerkCVbFc). 14 | 15 | ![](https://github.com/erdavids/Generative-Space-System/blob/master/Examples/Generative-Space-Texture-3000w-1501h.png) 16 | ![](https://github.com/erdavids/Generative-Space-System/blob/master/Examples/Generative-Space-Texture-3000w-1502h.png) 17 | 18 | --------------------------------------------------------------------------------