info = {
    'icon': 'AUTO',
    'description': 'Setup things to make the precomp roll and rock'
}

import bpy
import os, subprocess
import re, fnmatch, glob
from pathlib import Path
from os.path import join, dirname, basename, exists, isfile, isdir, splitext
from mathutils import Vector, Matrix
from math import radians, degrees

C = bpy.context
D = bpy.data
scn = bpy.context.scene

## v0.1
## - Setup layer colors

## TODO
# - Update libraries
# - Import Fx3D (or render from Fx3D file... maybe easier consifering the number)


## tried to make color that fit in White theme
## (difficult for readability since this text color is not the same)


prefix_color = {
    # 'MA_': (0.09, 0.08, 0.46), # Vivid blue
    'MA_': (0.65, 0.4, 0.6), # Pink Light

    'FX_': (0.12, 0.33, 0.58), # (0.3, 0.49, 0.63) # Blue Light
    # 'CO_': (0.35, 0.0085, 0.25),
    'CO_': (0.5,0.1,0.5), # Clear Pink
    # 'CU': (0.092070, 0.177356, 0.447959), # Blue clear
    'CU_': (0.02, 0.27, 0.27), # Indigo
}

## UW -> TO (here used fo CU): (0.015996, 0.246201, 0.246201) # Indigo

## invisible (close to violet light) in UW: (0.246201, 0.132868, 0.496933)


def set_layer_colors():
    for ob in scn.objects:
        if ob.type != 'GPENCIL':
            continue
        for l in ob.data.layers:
            # if l.info.startswith(prefix_color.keys()):
            color = prefix_color.get(l.info[:3])
            if not color:
                continue
            print(l.info, '->', color)
            l.channel_color = color

    C.preferences.edit.use_anim_channel_group_colors = True





set_layer_colors()

## update libraries
bpy.ops.gadget.update_libraries()