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