def hsl_slide(hsl1, hsl2, ratio):
    if (abs(hsl2['h'] - hsl1['h']) > 180):
        if (hsl1['h'] > hsl2['h']):
            hsl1['h'] -= 360
        else:
            hsl1['h'] += 360
    
    # Find location of two colors on the H/S color circle
    p1x = math.cos(math.radians(hsl1['h']))*hsl1['s']
    p1y = math.sin(math.radians(hsl1['h']))*hsl1['s']
    p2x = math.cos(math.radians(hsl2['h']))*hsl2['s']
    p2y = math.sin(math.radians(hsl2['h']))*hsl2['s']
    
    # Slide part of the way from tint to base color
    avg_x = p1x + ratio*(p1x-p2x)
    avg_y = p1y + ratio*(p2y-p1y)
    avg_h = math.atan(avg_y/avg_x)
    avg_s = avg_y/math.sin(avg_h)
    avg_l = hsl1['l'] + ratio*(hsl2['l']-hsl1['l'])
    avg_h = math.degrees(avg_h)
    
    #print('tint: %s base: %s avg: %s %s %s' % (tint,final_color,avg_h,avg_s,avg_l))
    return {'h':avg_h, 's':avg_s, 'l':avg_l}


# From http://www.easyrgb.com/index.php?X=MATH&H=19#text19
dataset/ETHPy150Open twoolie/NBT/examples/map.py/hsl_slide/swapped operands of `-`