Update Files

This commit is contained in:
2025-01-22 16:18:30 +01:00
parent ed4603cf95
commit a36294b518
16718 changed files with 2960346 additions and 0 deletions

View File

@ -0,0 +1,77 @@
from lnx.logicnode.lnx_nodes import *
class DrawTextAreaStringNode(LnxLogicTreeNode):
"""Draws a string.
@input Length: length of the text area string can be determined by the amount of lines desired or the amount of characters in a line.
@input Draw: Activate to draw the string on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input String: The string to draw as a text area.
@input Font File: The filename of the font (including the extension).
If empty and Zui is _enabled_, the default font is used. If empty
and Zui is _disabled_, nothing is rendered.
@length: value according to specified property above.
@line Spacing: changes the separation between lines.
@input Font Size: The size of the font in pixels.
@input Color Font: The color of the string, supports alpha.
@input Color Background: The color background of the text area, supports alpha, if no color is wanted used alpha 0.
@input X/Y: Position of the string, in pixels from the top left corner.
@input Angle: Rotation angle in radians. Rectangle will be rotated cloclwiswe
at the anchor point.
@see [`kha.graphics2.Graphics.drawString()`](http://kha.tech/api/kha/graphics2/Graphics.html#drawString).
"""
bl_idname = 'LNDrawTextAreaStringNode'
bl_label = 'Draw Text Area String'
lnx_section = 'draw'
lnx_version = 3
property0: HaxeEnumProperty(
'property0',
items = [('Lines', 'Length of Lines', 'Length of Lines'),
('Chars', 'Length of Characters', 'Chars'),],
name='', default='Lines')
property1: HaxeEnumProperty(
'property1',
items = [('TextLeft', 'Hor. Align. Left', 'Hor. Align. Left'),
('TextCenter', 'Hor. Align. Center', 'Hor. Align. Center'),
('TextRight', 'Hor. Align. Right', 'Hor. Align. Right'),],
name='', default='TextLeft')
property2: HaxeEnumProperty(
'property2',
items = [('TextTop', 'Ver. Align. Top', 'Ver. Align. Top'),
('TextMiddle', 'Ver. Align. Middle', 'Ver. Align. Middle'),
('TextBottom', 'Ver. Align. Bottom', 'Ver. Align. Bottom'),],
name='', default='TextTop')
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'Draw')
self.add_input('LnxStringSocket', 'String')
self.add_input('LnxStringSocket', 'Font File')
self.add_input('LnxIntSocket', 'Length', default_value=3)
self.add_input('LnxFloatSocket', 'Line Spacing', default_value=1.0)
self.add_input('LnxIntSocket', 'Font Size', default_value=16)
self.add_input('LnxColorSocket', 'Color Font', default_value=[1.0, 1.0, 1.0, 1.0])
self.add_input('LnxColorSocket', 'Color Background', default_value=[0.0, 0.0, 0.0, 1.0])
self.add_input('LnxFloatSocket', 'X')
self.add_input('LnxFloatSocket', 'Y')
self.add_input('LnxFloatSocket', 'Angle')
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxIntSocket', 'Lines')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
layout.prop(self, 'property1')
layout.prop(self, 'property2')
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
if self.lnx_version not in (0, 2):
raise LookupError()
return NodeReplacement.Identity(self)

View File

@ -0,0 +1,43 @@
from lnx.logicnode.lnx_nodes import *
class DrawArcNode(LnxLogicTreeNode):
"""Draws an arc (part of a circle).
@input Draw: Activate to draw the arc on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input Color: The color of the arc.
@input Filled: Whether the arc is filled or only the outline is drawn.
@input Strength: The line strength if the arc is not filled.
@input Segments: How many line segments should be used to draw the
arc. 0 (default) = automatic.
@input Center X/Y: The position of the arc's center, in pixels from the top left corner.
@input Radius: The radius of the arc in pixels.
@input Start Angle/End Angle: The angles in radians where the
arc starts/ends, starting right of the arc's center.
@input Exterior Angle: Whether the angles describe an Exterior angle.
@output Out: Activated after the arc has been drawn.
@see [`kha.graphics2.GraphicsExtension.drawArc()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#drawArc).
@see [`kha.graphics2.GraphicsExtension.fillArc()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#fillArc).
"""
bl_idname = 'LNDrawArcNode'
bl_label = 'Draw Arc'
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('LnxBoolSocket', 'Filled', default_value=False)
self.add_input('LnxFloatSocket', 'Strength', default_value=1.0)
self.add_input('LnxIntSocket', 'Segments')
self.add_input('LnxFloatSocket', 'Center X')
self.add_input('LnxFloatSocket', 'Center Y')
self.add_input('LnxFloatSocket', 'Radius', default_value=20.0)
self.add_input('LnxFloatSocket', 'Start Angle')
self.add_input('LnxFloatSocket', 'End Angle')
self.add_input('LnxBoolSocket', 'Exterior Angle', default_value=False)
self.add_output('LnxNodeSocketAction', 'Out')

View File

@ -0,0 +1,68 @@
from lnx.logicnode.lnx_nodes import *
class DrawCameraNode(LnxLogicTreeNode):
"""Renders the scene from the view of specified cameras and draws
the render targets to the screen.
@input Start: Evaluate the inputs and start drawing the camera render targets.
@input Stop: Stops the rendering and drawing of the camera render targets.
@input Camera: The camera from which to render.
@input X/Y: Position where the camera's render target is drawn, in pixels from the top left corner.
@input Width/Height: Size of the camera's render target in pixels.
@output On Start: Activated after the `Start` input has been activated.
@output On Stop: Activated after the `Stop` input has been activated.
"""
bl_idname = 'LNDrawCameraNode'
bl_label = 'Draw Camera'
lnx_section = 'draw'
lnx_version = 2
min_inputs = 7
num_choices: IntProperty(default=0, min=0)
def __init__(self):
super(DrawCameraNode, self).__init__()
array_nodes[str(id(self))] = self
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'Start')
self.add_input('LnxNodeSocketAction', 'Stop')
self.add_sockets()
self.add_output('LnxNodeSocketAction', 'On Start')
self.add_output('LnxNodeSocketAction', 'On Stop')
def add_sockets(self):
self.num_choices += 1
self.add_input('LnxNodeSocketObject', 'Camera ' + str(self.num_choices))
self.add_input('LnxIntSocket', 'X')
self.add_input('LnxIntSocket', 'Y')
self.add_input('LnxIntSocket', 'Width')
self.add_input('LnxIntSocket', 'Height')
def remove_sockets(self):
if self.num_choices > 1:
for _ in range(5):
self.inputs.remove(self.inputs.values()[-1])
self.num_choices -= 1
def draw_buttons(self, context, layout):
row = layout.row(align=True)
op = row.operator('lnx.node_call_func', text='Add Camera', icon='PLUS', emboss=True)
op.node_index = str(id(self))
op.callback_name = 'add_sockets'
column = row.column(align=True)
op = column.operator('lnx.node_call_func', text='', icon='X', emboss=True)
op.node_index = str(id(self))
op.callback_name = 'remove_sockets'
if len(self.inputs) == self.min_inputs:
column.enabled = False
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
if self.lnx_version not in (0, 1):
raise LookupError()
return NodeReplacement.Identity(self)

View File

@ -0,0 +1,31 @@
from lnx.logicnode.lnx_nodes import *
class DrawCameraTextureNode(LnxLogicTreeNode):
"""Renders the scene from the view of a specified camera and draws
its render target to the diffuse texture of the given material.
@input Start: Evaluate the inputs and start drawing the camera render target.
@input Stop: Stops the rendering and drawing of the camera render target.
@input Camera: The camera from which to render.
@input Object: Object of which to choose the material in the `Material Slot` input.
@input Material Slot: Index of the material slot of which the diffuse
texture is replaced with the camera's render target.
@output On Start: Activated after the `Start` input has been activated.
@output On Stop: Activated after the `Stop` input has been activated.
"""
bl_idname = 'LNDrawCameraTextureNode'
bl_label = 'Draw Camera to Texture'
lnx_section = 'draw'
lnx_version = 1
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'Start')
self.add_input('LnxNodeSocketAction', 'Stop')
self.add_input('LnxNodeSocketObject', 'Camera')
self.add_input('LnxNodeSocketObject', 'Object')
self.add_input('LnxIntSocket', 'Material Slot')
self.add_output('LnxNodeSocketAction', 'On Start')
self.add_output('LnxNodeSocketAction', 'On Stop')

View File

@ -0,0 +1,37 @@
from lnx.logicnode.lnx_nodes import *
class DrawCircleNode(LnxLogicTreeNode):
"""Draws a circle.
@input Draw: Activate to draw the circle on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input Color: The color of the circle.
@input Filled: Whether the circle is filled or only the outline is drawn.
@input Strength: The line strength if the circle is not filled.
@input Segments: How many line segments should be used to draw the
circle. 0 (default) = automatic.
@input Center X/Y: The position of the circle's center, in pixels from the top left corner.
@input Radius: The radius of the circle in pixels.
@output Out: Activated after the circle has been drawn.
@see [`kha.graphics2.GraphicsExtension.drawCircle()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#drawCircle).
@see [`kha.graphics2.GraphicsExtension.fillCircle()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#fillCircle).
"""
bl_idname = 'LNDrawCircleNode'
bl_label = 'Draw Circle'
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('LnxBoolSocket', 'Filled', default_value=False)
self.add_input('LnxFloatSocket', 'Strength', default_value=1.0)
self.add_input('LnxIntSocket', 'Segments')
self.add_input('LnxFloatSocket', 'Center X')
self.add_input('LnxFloatSocket', 'Center Y')
self.add_input('LnxFloatSocket', 'Radius')
self.add_output('LnxNodeSocketAction', 'Out')

View File

@ -0,0 +1,39 @@
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')

View File

@ -0,0 +1,41 @@
from lnx.logicnode.lnx_nodes import *
class DrawEllipseNode(LnxLogicTreeNode):
"""Draws an ellipse.
@input Draw: Activate to draw the ellipse on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input Color: The color of the ellipse.
@input Filled: Whether the ellipse is filled or only the outline is drawn.
@input Strength: The line strength if the ellipse is not filled.
@input Segments: How many line segments should be used to draw the
ellipse. 0 (default) = automatic.
@input Center X/Y: The position of the ellipse's center in pixels.
@input Width: Width of the ellipse in pixels.
@input Height: Height of the ellipse in pixels.
@input Angle: Rotation angle in radians. Rotation is clockwise.
@output Out: Activated after the circle has been drawn.
@see [`kha.graphics2.GraphicsExtension.drawCircle()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#drawCircle).
@see [`kha.graphics2.GraphicsExtension.fillCircle()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#fillCircle).
"""
bl_idname = 'LNDrawEllipseNode'
bl_label = 'Draw Ellipse'
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('LnxBoolSocket', 'Filled', default_value=False)
self.add_input('LnxFloatSocket', 'Strength', default_value=1.0)
self.add_input('LnxIntSocket', 'Segments')
self.add_input('LnxFloatSocket', 'Center X')
self.add_input('LnxFloatSocket', 'Center Y')
self.add_input('LnxFloatSocket', 'Width')
self.add_input('LnxFloatSocket', 'Height')
self.add_input('LnxFloatSocket', 'Angle')
self.add_output('LnxNodeSocketAction', 'Out')

View File

@ -0,0 +1,52 @@
from lnx.logicnode.lnx_nodes import *
class DrawImageNode(LnxLogicTreeNode):
"""Draws an image.
@input Draw: Activate to draw the image on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input Image: The filename of the image.
@input Color: The color that the image's pixels are multiplied with.
@input Left/Center/Right: Horizontal anchor point of the image.
0 = Left, 1 = Center, 2 = Right
@input Top/Middle/Bottom: Vertical anchor point of the image.
0 = Top, 1 = Middle, 2 = Bottom
@input X/Y: Position of the anchor point in pixels.
@input Width/Height: Size of the image in pixels.
@input Angle: Rotation angle in radians. Image will be rotated cloclwiswe
at the anchor point.
@output Out: Activated after the image has been drawn.
@see [`kha.graphics2.Graphics.drawImage()`](http://kha.tech/api/kha/graphics2/Graphics.html#drawImage).
"""
bl_idname = 'LNDrawImageNode'
bl_label = 'Draw Image'
lnx_section = 'draw'
lnx_version = 2
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'Draw')
self.add_input('LnxStringSocket', 'Image File')
self.add_input('LnxColorSocket', 'Color', default_value=[1.0, 1.0, 1.0, 1.0])
self.add_input('LnxIntSocket', '0/1/2 = Left/Center/Right', default_value=0)
self.add_input('LnxIntSocket', '0/1/2 = Top/Middle/Bottom', default_value=0)
self.add_input('LnxFloatSocket', 'X')
self.add_input('LnxFloatSocket', 'Y')
self.add_input('LnxFloatSocket', 'Width')
self.add_input('LnxFloatSocket', 'Height')
self.add_input('LnxFloatSocket', 'Angle')
self.add_output('LnxNodeSocketAction', 'Out')
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
if self.lnx_version not in (0, 1):
raise LookupError()
return NodeReplacement(
"LNDrawImageNode", self.lnx_version,
"LNDrawImageNode", 2,
in_socket_mapping={0:0, 1:1, 2:2, 3:5, 4:6, 5:7, 6:8},
out_socket_mapping={0:0},
)

View File

@ -0,0 +1,67 @@
from lnx.logicnode.lnx_nodes import *
class DrawImageSequenceNode(LnxLogicTreeNode):
"""Draws a sequence of image (images changing over time). The file names
of images used in a sequence need to follow a certain pattern:
`<prefix><frame-index>.<extension>`, `<prefix>` is an arbitrary filename
that must be constant for the entire sequence, `<frame-index>`
corresponds to the frame number of the image in the sequence.
`<extension>` is the file extension (without a period ".").
Image file names for a valid 2-frame sequence would for example
look like this:
```
myImage1.png
myImage2.png
```
@input Start: Evaluate the image filenames and start the sequence.
If the sequence is currently running, nothing happens. If the
sequence has finished and `Loop` is false, this input restarts
the sequence.
@input Stop: Stops the sequence and its drawing.
@input Image File Prefix: See `<prefix>` above.
@input Image File Extension: See `<extension>` above.
@input Color: The color that the pixels of the images are multiplied with.
@input X/Y: Position of the images, in pixels from the top left corner.
@input Width/Height: Size of the images in pixels. The images
grow towards the bottom right corner.
@input Start Index: The first `<frame-index>` of the sequence (inclusive).
@input End Index: The last `<frame-index>` of the sequence (inclusive).
@input Frame Duration: Duration of a frame in seconds.
@input Loop: Whether the sequence starts again from the first frame after the last frame.
@input Wait For Load: If true, start the sequence only after all
image files have been loaded. If false, the sequence starts immediately,
but images that are not yet loaded are not rendered.
@output On Start: Activated after the sequence has started. This output
is influenced by the `Wait For Load` input.
@output On Stop: Activated if the sequence ends or the `Stop` input
is activated. This is not activated when the sequence restarts
due to looping.
"""
bl_idname = 'LNDrawImageSequenceNode'
bl_label = 'Draw Image Sequence'
lnx_section = 'draw'
lnx_version = 1
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'Start')
self.add_input('LnxNodeSocketAction', 'Stop')
self.add_input('LnxStringSocket', 'Image File Prefix')
self.add_input('LnxStringSocket', 'Image File Extension')
self.add_input('LnxColorSocket', 'Color', default_value=[1.0, 1.0, 1.0, 1.0])
self.add_input('LnxFloatSocket', 'X')
self.add_input('LnxFloatSocket', 'Y')
self.add_input('LnxFloatSocket', 'Width')
self.add_input('LnxFloatSocket', 'Height')
self.add_input('LnxIntSocket', 'Start Index')
self.add_input('LnxIntSocket', 'End Index', default_value=1)
self.add_input('LnxFloatSocket', 'Frame Duration', default_value=1.0)
self.add_input('LnxBoolSocket', 'Loop', default_value=True)
self.add_input('LnxBoolSocket', 'Wait For Load', default_value=True)
self.add_output('LnxNodeSocketAction', 'On Start')
self.add_output('LnxNodeSocketAction', 'On Stop')

View File

@ -0,0 +1,31 @@
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')

View File

@ -0,0 +1,72 @@
from lnx.logicnode.lnx_nodes import *
class DrawPolygonNode(LnxLogicTreeNode):
"""Draws a polygon.
@input Draw: Activate to draw the polygon on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input Color: The color of the polygon.
@input Filled: Whether the polygon is filled or only the outline is drawn.
@input Strength: The line strength if the polygon is not filled.
@input Origin X/Origin Y: The origin position of the polygon, in pixels
from the top left corner. This position is added to all other
points, so they are defined relative to this position.
@input Xn/Yn: The position of polygon's points, in pixels from `Origin X`/`Origin Y`.
@output Out: Activated after the polygon has been drawn.
@see [`kha.graphics2.GraphicsExtension.drawPolygon()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#drawPolygon).
@see [`kha.graphics2.GraphicsExtension.fillPolygon()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#fillPolygon).
"""
bl_idname = 'LNDrawPolygonNode'
bl_label = 'Draw Polygon'
lnx_section = 'draw'
lnx_version = 2
min_inputs = 6
num_choices: IntProperty(default=1, min=0)
def __init__(self):
super(DrawPolygonNode, self).__init__()
array_nodes[str(id(self))] = self
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('LnxBoolSocket', 'Filled', default_value=False)
self.add_input('LnxFloatSocket', 'Strength', default_value=1.0)
self.add_input('LnxFloatSocket', 'Origin X')
self.add_input('LnxFloatSocket', 'Origin Y')
self.add_output('LnxNodeSocketAction', 'Out')
def add_sockets(self):
self.add_input('LnxFloatSocket', 'X' + str(self.num_choices))
self.add_input('LnxFloatSocket', 'Y' + str(self.num_choices))
self.num_choices += 1
def remove_sockets(self):
if self.num_choices > 1:
self.inputs.remove(self.inputs.values()[-1])
self.inputs.remove(self.inputs.values()[-1])
self.num_choices -= 1
def draw_buttons(self, context, layout):
row = layout.row(align=True)
op = row.operator('lnx.node_call_func', text='Add Point', icon='PLUS', emboss=True)
op.node_index = str(id(self))
op.callback_name = 'add_sockets'
column = row.column(align=True)
op = column.operator('lnx.node_call_func', text='', icon='X', emboss=True)
op.node_index = str(id(self))
op.callback_name = 'remove_sockets'
if len(self.inputs) == self.min_inputs:
column.enabled = False
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
if self.lnx_version not in (0, 1):
raise LookupError()
return NodeReplacement.Identity(self)

View File

@ -0,0 +1,35 @@
from lnx.logicnode.lnx_nodes import *
class DrawPolygonFromArrayNode(LnxLogicTreeNode):
"""Draws a polygon.
@input Draw: Activate to draw the polygon on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input Color: The color of the polygon.
@input Filled: Whether the polygon is filled or only the outline is drawn.
@input Strength: The line strength if the polygon is not filled.
@input Origin X/Origin Y: The origin position of the polygon, in pixels
from the top left corner. This position is added to all other
points, so they are defined relative to this position.
@input Xn/Yn: The position of polygon's points, in pixels from `Origin X`/`Origin Y`.
@output Out: Activated after the polygon has been drawn.
@see [`kha.graphics2.GraphicsExtension.drawPolygon()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#drawPolygon).
@see [`kha.graphics2.GraphicsExtension.fillPolygon()`](http://kha.tech/api/kha/graphics2/GraphicsExtension.html#fillPolygon).
"""
bl_idname = 'LNDrawPolygonFromArrayNode'
bl_label = 'Draw Polygon From Array'
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('LnxBoolSocket', 'Filled', default_value=False)
self.add_input('LnxFloatSocket', 'Strength', default_value=1.0)
self.add_input('LnxFloatSocket', 'Origin X')
self.add_input('LnxFloatSocket', 'Origin Y')
self.add_input('LnxNodeSocketArray', 'Array (X, Y)')
self.add_output('LnxNodeSocketAction', 'Out')

View File

@ -0,0 +1,55 @@
from lnx.logicnode.lnx_nodes import *
class DrawRectNode(LnxLogicTreeNode):
"""Draws a rectangle.
@input Draw: Activate to draw the rectangle on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input Color: The color of the rectangle.
@input Filled: Whether the rectangle is filled or only the outline is drawn.
@input Strength: The line strength if the rectangle is not filled.
@input Left/Center/Right: Horizontal anchor point of the rectangel.
0 = Left, 1 = Center, 2 = Right
@input Top/Middle/Bottom: Vertical anchor point of the rectangel.
0 = Top, 1 = Middle, 2 = Bottom
@input X/Y: Position of the anchor point in pixels.
@input Width/Height: Size of the rectangle in pixels.
@input Angle: Rotation angle in radians. Rectangle will be rotated cloclwiswe
at the anchor point.
@output Out: Activated after the rectangle has been drawn.
@see [`kha.graphics2.Graphics.drawRect()`](http://kha.tech/api/kha/graphics2/Graphics.html#drawRect).
@see [`kha.graphics2.Graphics.fillRect()`](http://kha.tech/api/kha/graphics2/Graphics.html#fillRect).
"""
bl_idname = 'LNDrawRectNode'
bl_label = 'Draw Rect'
lnx_section = 'draw'
lnx_version = 2
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('LnxBoolSocket', 'Filled', default_value=False)
self.add_input('LnxFloatSocket', 'Strength', default_value=1.0)
self.add_input('LnxIntSocket', '0/1/2 = Left/Center/Right', default_value=0)
self.add_input('LnxIntSocket', '0/1/2 = Top/Middle/Bottom', default_value=0)
self.add_input('LnxFloatSocket', 'X')
self.add_input('LnxFloatSocket', 'Y')
self.add_input('LnxFloatSocket', 'Width')
self.add_input('LnxFloatSocket', 'Height')
self.add_input('LnxFloatSocket', 'Angle')
self.add_output('LnxNodeSocketAction', 'Out')
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
if self.lnx_version not in (0, 1):
raise LookupError()
return NodeReplacement(
"LNDrawRectNode", self.lnx_version,
"LNDrawRectNode", 2,
in_socket_mapping={0:0, 1:1, 2:2, 3:3, 4:6, 5:7, 6:8, 7:9},
out_socket_mapping={0:0},
)

View File

@ -0,0 +1,48 @@
from lnx.logicnode.lnx_nodes import *
class DrawRoundedRectNode(LnxLogicTreeNode):
"""Draws a rectangle.
@input Draw: Activate to draw the rectangle on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input Color: The color of the rectangle.
@input Filled: Whether the rectangle is filled or only the outline is drawn.
@input Strength: The line strength if the rectangle is not filled.
@input Left/Center/Right: Horizontal anchor point of the rectangel.
0 = Left, 1 = Center, 2 = Right
@input Top/Middle/Bottom: Vertical anchor point of the rectangel.
0 = Top, 1 = Middle, 2 = Bottom
@input Segments: number of points to consider for rounded rect corners.
@input Radius: radius of the rounded rect.
@input X/Y: Position of the anchor point in pixels.
@input Width/Height: Size of the rectangle in pixels.
@input Angle: Rotation angle in radians. Rectangle will be rotated cloclwiswe
at the anchor point.
@output Out: Activated after the rectangle has been drawn.
@see [`kha.graphics2.Graphics.drawRect()`](http://kha.tech/api/kha/graphics2/Graphics.html#drawRect).
@see [`kha.graphics2.Graphics.fillRect()`](http://kha.tech/api/kha/graphics2/Graphics.html#fillRect).
"""
bl_idname = 'LNDrawRoundedRectNode'
bl_label = 'Draw Rounded Rect'
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('LnxBoolSocket', 'Filled', default_value=False)
self.add_input('LnxFloatSocket', 'Strength', default_value=1.0)
self.add_input('LnxIntSocket', '0/1/2 = Left/Center/Right', default_value=0)
self.add_input('LnxIntSocket', '0/1/2 = Top/Middle/Bottom', default_value=0)
self.add_input('LnxIntSocket', 'Segments', default_value=10)
self.add_input('LnxFloatSocket', 'Radius')
self.add_input('LnxFloatSocket', 'X')
self.add_input('LnxFloatSocket', 'Y')
self.add_input('LnxFloatSocket', 'Width')
self.add_input('LnxFloatSocket', 'Height')
self.add_input('LnxFloatSocket', 'Angle')
self.add_output('LnxNodeSocketAction', 'Out')

View File

@ -0,0 +1,48 @@
from lnx.logicnode.lnx_nodes import *
class DrawStringNode(LnxLogicTreeNode):
"""Draws a string.
@input Draw: Activate to draw the string on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input String: The string to draw.
@input Font File: The filename of the font (including the extension).
If empty and Zui is _enabled_, the default font is used. If empty
and Zui is _disabled_, nothing is rendered.
@input Font Size: The size of the font in pixels.
@input Color: The color of the string.
@input X/Y: Position of the string, in pixels from the top left corner.
@input Angle: Rotation angle in radians. Rectangle will be rotated cloclwiswe
at the anchor point.
@output Out: Activated after the string has been drawn.
@output Height: String Height.
@output Width: String Width.
@see [`kha.graphics2.Graphics.drawString()`](http://kha.tech/api/kha/graphics2/Graphics.html#drawString).
"""
bl_idname = 'LNDrawStringNode'
bl_label = 'Draw String'
lnx_section = 'draw'
lnx_version = 2
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'Draw')
self.add_input('LnxStringSocket', 'String')
self.add_input('LnxStringSocket', 'Font File')
self.add_input('LnxIntSocket', 'Font Size', default_value=16)
self.add_input('LnxColorSocket', 'Color', default_value=[1.0, 1.0, 1.0, 1.0])
self.add_input('LnxFloatSocket', 'X')
self.add_input('LnxFloatSocket', 'Y')
self.add_input('LnxFloatSocket', 'Angle')
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxFloatSocket', 'Height')
self.add_output('LnxFloatSocket', 'Width')
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
if self.lnx_version not in (0, 1):
raise LookupError()
return NodeReplacement.Identity(self)

View File

@ -0,0 +1,39 @@
from lnx.logicnode.lnx_nodes import *
class DrawToMaterialImageNode(LnxLogicTreeNode):
"""Sets the image render target to draw to. The render target must be created using the `Create Render Target Node` first.
@seeNode Create Render Target Node
@input In: Executes a 2D draw sequence connected to this node
@input Object: Object whose material image should be drawn to.
Use `Get Scene Root` node to draw globally (all objects that share this image, and not per-object).
@input Material: Material whose image to be drawn to.
@input Node: Name of the parameter.
@input Clear Image: Clear the image before drawing to it
@output Out: Action output to be connected to other Draw Nodes
@output Width: Width of the image
@output Height: Height of the image
"""
bl_idname = 'LNDrawToMaterialImageNode'
bl_label = 'Draw To Material Image'
lnx_section = 'draw'
lnx_version = 1
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxNodeSocketObject', 'Object')
self.add_input('LnxDynamicSocket', 'Material')
self.add_input('LnxStringSocket', 'Node')
self.add_input('LnxBoolSocket', 'Clear Image')
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxIntSocket', 'Width')
self.add_output('LnxIntSocket', 'Height')

View File

@ -0,0 +1,35 @@
from lnx.logicnode.lnx_nodes import *
class DrawTriangleNode(LnxLogicTreeNode):
"""Draws a triangle.
@input Draw: Activate to draw the triangle on this frame. The input must
be (indirectly) called from an `On Render2D` node.
@input Color: The color of the triangle.
@input Filled: Whether the triangle is filled or only the outline is drawn.
@input Strength: The line strength if the triangle is not filled.
@input X/Y: Positions of the vertices of the triangle, in pixels from the top left corner.
@output Out: Activated after the triangle has been drawn.
@see [`kha.graphics2.Graphics.fillTriangle()`](http://kha.tech/api/kha/graphics2/Graphics.html#fillTriangle).
"""
bl_idname = 'LNDrawTriangleNode'
bl_label = 'Draw Triangle'
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('LnxBoolSocket', 'Filled', default_value=False)
self.add_input('LnxFloatSocket', 'Strength', default_value=1.0)
self.add_input('LnxFloatSocket', 'X1')
self.add_input('LnxFloatSocket', 'Y1')
self.add_input('LnxFloatSocket', 'X2')
self.add_input('LnxFloatSocket', 'Y2')
self.add_input('LnxFloatSocket', 'X3')
self.add_input('LnxFloatSocket', 'Y3')
self.add_output('LnxNodeSocketAction', 'Out')

View File

@ -0,0 +1,3 @@
from lnx.logicnode.lnx_nodes import add_node_section
add_node_section(name='default', category='draw')