galaxy = Galaxy(10000) galaxy.reset(13000, 4000, 0.0004, 0.90, 0.90, 0.5, 200, 300) # coldest and hottest temperatures of out galaxy t0, t1 = 200.0, 10000.0 # total number of discrete colors between t0 and t1 n = 1000 dt = (t1 - t0) / n # maps [0, n) -> colors # generate a linear interpolation of temperatures # then map the temperatures to colors using black body # color predictions colors = np.zeros(n, dtype=(np.float32, 3)) for i in range(n): temperature = t0 + i * dt x, y, z = galaxy_specrend.spectrum_to_xyz(galaxy_specrend.bb_spectrum, temperature) r, g, b = galaxy_specrend.xyz_to_rgb(galaxy_specrend.SMPTEsystem, x, y, z) r = min((max(r, 0), 1)) g = min((max(g, 0), 1)) b = min((max(b, 0), 1)) colors[i] = galaxy_specrend.norm_rgb(r, g, b) # load the PNG that we use to blend the star with # to provide a circular look to each star. def load_galaxy_star_image(): fname = io.load_data_file('galaxy/star-particle.png') raw_image = io.read_png(fname) return raw_image
galaxy = Galaxy(10000) galaxy.reset(13000, 4000, 0.0004, 0.90, 0.90, 0.5, 200, 300) # coldest and hottest temperatures of out galaxy t0, t1 = 200.0, 10000.0 # total number of discrete colors between t0 and t1 n = 1000 dt = (t1 - t0) / n # maps [0, n) -> colors # generate a linear interpolation of temperatures # then map the temperatures to colors using black body # color predictions colors = np.zeros(n, dtype=(np.float32, 3)) for i in range(n): temperature = t0 + i * dt x, y, z = galaxy_specrend.spectrum_to_xyz(galaxy_specrend.bb_spectrum, temperature) r, g, b = galaxy_specrend.xyz_to_rgb(galaxy_specrend.SMPTEsystem, x, y, z) r = min((max(r, 0), 1)) g = min((max(g, 0), 1)) b = min((max(b, 0), 1)) colors[i] = galaxy_specrend.norm_rgb(r, g, b) # load the PNG that we use to blend the star with # to provide a circular look to each star. def load_galaxy_star_image(): fname = io.load_data_file('galaxy/star-particle.png') raw_image = io.read_png(fname) return raw_image