from lnx.logicnode.lnx_nodes import *


class DrawLineNode(LnxLogicTreeNode):
    """Draws a line.

    @input Draw: Activate to draw the line on this frame. The input must
        be (indirectly) called from an `On Render2D` node.
    @input Color: The color of the line.
    @input Strength: The line strength.
    @input X1/Y1/X2/Y2: The position of line's two end points, in pixels from the top left corner.

    @output Out: Activated after the line has been drawn.

    @see [`kha.graphics2.Graphics.drawLine()`](http://kha.tech/api/kha/graphics2/Graphics.html#drawLine).
    """
    bl_idname = 'LNDrawLineNode'
    bl_label = 'Draw Line'
    lnx_section = 'draw'
    lnx_version = 1

    def lnx_init(self, context):
        self.add_input('LnxNodeSocketAction', 'Draw')
        self.add_input('LnxColorSocket', 'Color', default_value=[1.0, 1.0, 1.0, 1.0])
        self.add_input('LnxFloatSocket', 'Strength', default_value=1.0)
        self.add_input('LnxIntSocket', 'X1')
        self.add_input('LnxIntSocket', 'Y1')
        self.add_input('LnxIntSocket', 'X2')
        self.add_input('LnxIntSocket', 'Y2')

        self.add_output('LnxNodeSocketAction', 'Out')