import numpy as np

from sierpinski_config import SierpinskiConfig
from sierpinski_config_ext0 import SierpinskiConfigExt0
from sierpinski_config_ext1 import SierpinskiConfigExt1
from sierpinski_config_ext2 import SierpinskiConfigExt2
from sierpinski_config_ext3 import SierpinskiConfigExt3


class SierpinskiLibrary:

    _sierpinski_configs_list = [

        SierpinskiConfig(
            'triangle',
            np.array([
                [0.05, 0.05],
                [0.50, 0.95],
                [0.95, 0.05]
            ]),
            20000,
            1, 0, 1, 0,
            500,
            (1, 1, 1, 0.4),
            'random'
        ),

        SierpinskiConfig(
            'square 1',
            np.array([
                [0.05, 0.05],
                [0.05, 0.95],
                [0.95, 0.05],
                [0.95, 0.95]
            ]),
            20000,
            1, 0, 1, 0,
            500,
            (1, 1, 1, 0.4),
            'random'
        ),

        SierpinskiConfig(
            'square 2',
            np.array([
                [0.05, 0.05],
                [0.05, 0.95],
                [0.95, 0.05],
                [0.95, 0.95]
            ]),
            20000,
            1, 0, 1.414, 0,
            1500,
            (1, 1, 1, 0.4),
            'random'
        ),

        SierpinskiConfig(
            'square 3',
            np.array([
                [0.05, 0.05],
                [0.05, 0.95],
                [0.95, 0.05],
                [0.95, 0.95]
            ]),
            20000,
            1.4142, 0, 1, 0,
            500,
            (1, 1, 1, 0.4),
            'random'
        ),

        SierpinskiConfig(
            'triangle mover',
            np.array([
                [0.05, 0.05],
                [0.50, 0.95],
                [0.95, 0.05]
            ]),
            20000,
            1, 0, 0, 0.01,
            500,
            (1, 1, 1, 0.4),
            'random'
        ),

        SierpinskiConfig(
            'square mover',
            np.array([
                [0.05, 0.05],
                [0.05, 0.95],
                [0.95, 0.05],
                [0.95, 0.95],
            ]),
            8000,
            1, 0, 0, 0.01,
            500,
            (1, 1, 1, 0.4),
            'random'
        ),

        SierpinskiConfig(
            'pentagon tree',
            np.array([
                [0.05, 0.05],
                [0.05, 0.95],
                [0.50, 0.50],
                [0.95, 0.05],
                [0.95, 0.95],
            ]),
            20000,
            1, 0, 1, 0,
            500,
            (1, 1, 1, 0.4),
            'random'
        ),

        SierpinskiConfig(
            'square color',
            np.array([
                [0.05, 0.05],
                [0.05, 0.95],
                [0.95, 0.05],
                [0.95, 0.95],
            ]),
            40000,
            1, 0, 1.2, 0,
            2000,
            'linear',
            'random'
        ),

        SierpinskiConfig(
            'square center',
            np.array([
                [0.05, 0.05],
                [0.05, 0.95],
                [0.95, 0.05],
                [0.95, 0.95],
            ]),
            40000,
            1, 0, 1.2, 0,
            2000,
            (1, 1, 1, 0.4),
            'line'
        ),

        SierpinskiConfig(
            'square color line',
            np.array([
                [0.05, 0.05],
                [0.05, 0.95],
                [0.95, 0.05],
                [0.95, 0.95],
            ]),
            40000,
            1, 0, 1.2, 0,
            2000,
            "linear",
            'line'
        ),

        SierpinskiConfig(
            'square color box',
            np.array([
                [0.05, 0.05],
                [0.05, 0.95],
                [0.95, 0.05],
                [0.95, 0.95],
            ]),
            40000,
            1, 0, 1.2, 0,
            2000,
            "linear",
            'box'
        ),

        SierpinskiConfig(
            'triangle color box',
            np.array([
                [0.05, 0.05],
                [0.50, 0.95],
                [0.95, 0.05]
            ]),
            40000,
            1, 0, 1.2, 0,
            2000,
            "linear",
            'box 2'
        ),

        SierpinskiConfig(
            'triangle color box 2',
            np.array([
                [0.05, 0.05],
                [0.50, 0.95],
                [0.95, 0.05]
            ]),
            40000,
            1, 0, 1.2, 0,
            2000,
            "linear",
            'box 3'
        ),

        SierpinskiConfig(
            'triangle color',
            np.array([
                [0.05, 0.05],
                [0.50, 0.95],
                [0.95, 0.05]
            ]),
            10000,
            1, 0, 1, 0,
            1000,
            'radial',
            'random'
        ),

        SierpinskiConfigExt0(
            'triangle ext 0',
            np.array([
                [0.05, 0.05],
                [0.50, 0.95],
                [0.95, 0.05]
            ]),
            20000,
            1, 0, 1, 0,
            500,
            (1, 1, 1, 0.4),
            'random'
        ),

        SierpinskiConfigExt0(
            'triangle ext 1',
            np.array([
                [0.05, 0.05],
                [0.50, 0.95],
                [0.95, 0.05]
            ]),
            4000,
            1, 0, 1, 0,
            200,
            (1, 1, 1, 0.4),
            'random'
        ),

        SierpinskiConfigExt3(
            'triangle ext 3',
            np.array([
                [0.05, 0.05],
                [0.50, 0.95],
                [0.95, 0.05],
            ]),
            4000,
            1, 0, 1, 0,
            200,
            (1, 1, 1, 0.4),
            'random'
        ),

        SierpinskiConfigExt1(
            'andromeda 1',
            np.array([
                [0.5, 0.5]
            ]),
            20000,
            0, 0.01, 1, 0.003,
            1000,
            "andromeda",
            'random'
        ),

        SierpinskiConfigExt2(
            '<NAME>',
            np.array([
                [0.50, 0.95],
                [0.05, 0.15],
                [0.95, 0.05],
                [0.50, 0.10],
                [0.05, 0.75],
                [0.95, 0.75],
            ]),
            40000,
            1, 0, 1, 0,
            1400,
            "emerge",
            'random'
        ),
    ]

    def __init__(self):

        sierpinski_configs = dict()
        for sc in SierpinskiLibrary._sierpinski_configs_list:
            sierpinski_configs[sc.name] = sc

        self._sierpinski_configs = sierpinski_configs

    def __getitem__(self, key: str):
        return self._sierpinski_configs[key]