from panda3d.core import Vec4, Material

color_vectors = {
    'dark orange': Vec4(.162, .107, .004, 1),
    'dark green': Vec4(.141, .159, .004, 1),
    'dark blue': Vec4(.010, .006, .076, 1),
    'dark purple': Vec4(.083, .035, .107, 1),
    'light orange': Vec4(.775, .617, .205, 1),
    'light green': Vec4(.708, .753, .201, 1),
    'light blue': Vec4(.274, .250, .485, 1),
    'light purple': Vec4(.238, .093, .309, 1),
}

materials = {name: Material() for name in color_vectors.keys()}
for name, material in materials.items():
    descriptor, color = name.split(' ')
    dark_vector = color_vectors['dark ' + color]
    light_vector = color_vectors['light ' + color]
    vector = color_vectors[name]
    emission_vector = Vec4(dark_vector)
    emission_vector.w = 0.6 if descriptor == 'light' else 0.3

    material.set_base_color(vector)
    material.set_ambient(dark_vector)
    material.set_diffuse(vector)
    material.set_emission(emission_vector)
    material.set_shininess(12.5)
    material.set_specular(Vec4(0.6, 0.6, 0.6, 1))


def tweak_material(material, name):
    template = materials[name]
    material.set_ambient(template.get_ambient())
    material.set_diffuse(template.get_diffuse())
    material.set_emission(template.get_emission())
    material.set_specular(template.get_specular())
