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 Width: String Width. @output Height: String Height. @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 = 3 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', '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', 'Width') self.add_output('LnxFloatSocket', 'Height') def draw_buttons(self, context, layout): 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, 1, 2): raise LookupError() return NodeReplacement.Identity(self)