Using 2D shape nodes¶
Use 2D shape nodes to draw vector shapes in 2D space.
These 2D shape nodes are available in Kanzi Shapes:
Line 2D node to draw straight lines. See Using the Line nodes.
Oval 2D node to draw arcs, ellipses, circles, circle sectors, and segments. See Using the Oval nodes.
Path 2D node to draw arbitrary shapes. See Using the Path nodes.
Rectangle 2D node to draw rectangles. See Using the Rectangle nodes.
Composite Shape 2D node to combine 2D shape nodes using Boolean operations on the geometry of the nodes. See Using the Composite Shape nodes.
Filling a 2D shape node¶
Use a brush to fill the shape in a 2D shape node.
To fill a 2D shape:
In the Library > Materials and Textures > Brushes create the brush that you want to use to fill a 2D shape node.
For example, create a Color Brush.
Create or select a 2D shape node that you want to fill.
For example, in the Node Tree create a Path 2D node and in the Properties set the Path Commands property to
M (120, 20) L (62, 200) (216, 90) (24, 90) (178, 200) Z
When you create a closed 2D shape, that shape by default has a white fill and no stroke.
In the Properties add the Foreground Brush property, and set it to the brush that you created.
(Optional) To set the appearance of the outline of the 2D shape, add and set the Stroke Brush and Stroke Thickness properties. See Using stroke.
Kanzi renders the outline on top of the fill and blends the two brushes.
Setting the stroke of a 2D shape¶
To set the style of the stroke of a 2D shape:
In the Library > Materials and Textures > Brushes create the brush that you want to use to define the appearance of a line or outline of a shape.
For example, create a Color Brush.
Create or select a shape node whose stroke you want to set.
For example, in the Node Tree create an Oval 2D node.
When you create a closed 2D shape, that shape by default has a white fill and no stroke.
In the Properties add and set:
Stroke Brush to the brush that you created
Stroke Thickness to the width that you want for the outline of the shape
(Optional) Foreground Brush to the brush that you want to use to fill the shape
To draw the shape using only the stroke and no fill, set Foreground Brush to < No Brush >.
Setting the input area for a 2D shape node¶
When you enable hit testing for a node with the Input > Hit Testable property, the entire area of that node receives input by default.
To make only the area formed by the composited geometry of the shapes in a 2D shape node receive input, in the Node Tree or Prefabs select that node and in the Properties add and enable the Shape > Exact Hit Test property.
To learn about handling user input in Kanzi, in the Kanzi framework documentation see Working with > Input.