49 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| 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)
 |