LNXSDK/leenkx/blender/lnx/logicnode/draw/LN_draw_curve.py
2025-01-22 16:18:30 +01:00

40 lines
1.9 KiB
Python

from lnx.logicnode.lnx_nodes import *
class DrawCurveNode(LnxLogicTreeNode):
"""Draws a cubic bezier curve with two control points.
@input Draw: Activate to draw the curve on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input Color: The color of the curve.
@input Strength: The line strength.
@input Segments: How many line segments should be used to draw the curve.
@input Start Point X/Y: The position of starting point of the curve, in pixels from the top left corner.
@input Control Point 1/2 X/Y: The position of control points of the curve, in pixels from the top left corner.
@input End Point X/Y: The position of end point of the curve, in pixels from the top left corner.
@output Out: Activated after the curve has been drawn.
@see [`kha.graphics2.GraphicsExtension.drawCubicBezier()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#drawCubicBezier).
"""
bl_idname = 'LNDrawCurveNode'
bl_label = 'Draw Curve'
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', 'Segments', default_value=20)
self.add_input('LnxFloatSocket', 'Start Point X')
self.add_input('LnxFloatSocket', 'Start Point Y')
self.add_input('LnxFloatSocket', 'Control Point 1 X')
self.add_input('LnxFloatSocket', 'Control Point 1 Y')
self.add_input('LnxFloatSocket', 'Control Point 2 X')
self.add_input('LnxFloatSocket', 'Control Point 2 Y')
self.add_input('LnxFloatSocket', 'End Point X')
self.add_input('LnxFloatSocket', 'End Point Y')
self.add_output('LnxNodeSocketAction', 'Out')