from yta_editor_nodes.processor.video.base import _VideoNodeProcessor
from yta_editor_parameters.specifications import ParameterSpecification
from typing import Union


class WavingFrameVideoNodeProcessor(_VideoNodeProcessor):
    """
    The frame but as if it is moving like a wave.

    Mandatory inputs:
    - `base_input`

    Optional inputs:
    - `None`
       
    Parameters:
    - `*amplitude`
    - `*frequency`
    - `*speed`
    - `*do_use_transparent_pixels`

    The parameters above are the accepted by this
    node, where `*` means that the parameter is
    mandatory.
    """

    mandatory_inputs = ['base_input']
    optional_inputs = []
    parameters_specifications = [
        ParameterSpecification(
            name = 'amplitude',
            type = float,
            is_required = True,
            default = 0.05,
            min = 0.001,
            max = 0.5
        ),
        ParameterSpecification(
            name = 'frequency',
            type = float,
            is_required = True,
            default = 10.0,
            min = 0.1,
            max = 100.0
        ),
        ParameterSpecification(
            name = 'speed',
            type = float,
            is_required = True,
            default = 2.0,
            min = 0.1,
            max = 10.0
        ),
        ParameterSpecification(
            name = 'do_use_transparent_pixels',
            type = bool,
            is_required = True,
            default = False,
            min = None,
            max = None
        )
    ]

    def __init__(
        self,
        opengl_context: 'moderngl.Context'
    ):
        super().__init__(
            opengl_context = opengl_context
        )

    def _instantiate_cpu_and_gpu_processors(
        self,
        opengl_context: Union['moderngl.Context', None]
    ):
        """
        *For internal use only*

        Instantiate the CPU and GPU procesors and return 
        them in that order.

        This method must be implemented by each class.
        """
        from yta_editor_nodes_cpu.processor.video.waving_frame import WavingFrameVideoNodeProcessorCPU
        from yta_editor_nodes_gpu.processor.video.waving_frame import WavingFrameVideoNodeProcessorGPU

        node_cpu = WavingFrameVideoNodeProcessorCPU()
        node_gpu = WavingFrameVideoNodeProcessorGPU(
            opengl_context = opengl_context
        )

        return node_cpu, node_gpu