Using stroke

Use stroke to define the appearance of a line or outline of a shape.

Setting the stroke of a 2D shape

To set the style of the stroke of a 2D shape:

  1. 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.

    ../_images/stroke-color-brush1.png
  2. Create or select a shape node whose stroke you want to set.

    For example, in the Node Tree, create an Ellipse 2D node.

    When you create a closed 2D shape, that shape by default has a white fill and no stroke.

    ../_images/ellipse-2d-in-node-tree.png ../_images/ellipse-2d-in-preview.png
  3. 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 >.

    ../_images/properties-ellipse-2d-with-stroke.png ../_images/preview-ellipse-2d-with-stroke.png

Setting the stroke of a 3D shape

To set the style of the stroke of a 3D shape:

  1. In the Library > Materials and Textures, create the material that you want to use to define the appearance of a line or outline of a shape.

    For example, create a material that uses the VertexPhong material type.

    Tip

    If your project does not contain the VertexPhong material type, in the Library > Materials and Textures, press Alt and right-click Material Types, and select VertexPhong.

    ../_images/stroke-material1.png
  2. Create or select a 3D shape node whose stroke you want to set.

    For example, in the Node Tree, create an Ellipse 3D node.

    When you create a closed 3D shape, that shape by default has a black fill and no stroke.

    ../_images/ellipse-3d-in-node-tree.png ../_images/ellipse-3d-in-preview.png
  3. In the Properties, add and set:

    • Stroke Material to the material that you created

    • Stroke Thickness to the width that you want for the outline of the shape

    • (Optional) Fill Material to the material that you want to use to fill the shape

      To draw the shape using only the stroke and no fill, set Fill Material to < Unassigned >.

    ../_images/properties-ellipse-3d-with-stroke.png ../_images/preview-ellipse-3d-with-stroke.png

Setting dashed stroke

To set a dashed stroke:

  1. Create or select a shape node that uses stroke.

    For example, in the Node Tree, create a Rectangle 2D node and set its stroke. See Using the Rectangle nodes.

    ../_images/properties-rectangle-2d-with-stroke.png ../_images/preview-rectangle-2d-with-stroke.png
  2. In the Properties, add and set the Stroke Dash Pattern property to set the length of the alternating dashes and gaps in the stroke.

    Enter a list of values separated by spaces or commas, where the first value is the length of a dash and the second value is the length of a gap.

    If you enter an odd number of values, Kanzi Shapes repeats the list to yield an even number of values.

    Stroke Dash Pattern

    Result

    5

    ../_images/dash-pattern-5.png

    10 5

    ../_images/dash-pattern-10-5.png

    20 5 10 5

    ../_images/dash-pattern-20-5-10-5.png

    20 5 5 5 5 5

    ../_images/dash-pattern-20-5-5-5-5-5.png

    Kanzi Shapes by default scales the dash pattern to fit such that it repeats at least once and always in multiples of the complete pattern. The center of the first dash is aligned to the corners and end points of the shape.

    ../_images/stroke-dash-pattern.png ../_images/stroke-dash-pattern-in-preview.png
  3. (Optional) To not scale and align the dash pattern, in the Properties, disable the Align Stroke Dash property.

    ../_images/properties-disable-align-stroke-dash.png ../_images/preview-align-stroke-dash-disabled.png
  4. (Optional) To define the position along the SVG path where the dash of the stroke begins, in the Properties, add and set the Stroke Dash Offset property.

    ../_images/properties-stroke-dash-offset.png ../_images/preview-stroke-dash-offset.png

Setting the shape of the stroke at the ends of a path

You can use the Stroke Cap property to set the shape of the stroke at the ends of a path. For example, in a dashed stroke the shape that you set is visible at the ends of each dash.

To set the shape of the stroke at the ends of a path:

  1. Create or select a shape node that uses stroke and shows a shape with open paths.

    For example, in the Node Tree, create a Line 2D node and set its stroke. See Using the Line nodes.

    ../_images/line-2d-with-stroke.png ../_images/line-2d-in-preview1.png
  2. In the Properties, add and set the Stroke Cap property to:

    Butt to not extend the stroke beyond its endpoints.

    This is the default value.

    ../_images/stroke-cap-butt.png

    Rectangle to extend the stroke by a rectangle whose width is half of the stroke thickness.

    ../_images/stroke-cap-rectangle.png

    Round to extend the stroke by a half circle whose diameter is equal to the stroke thickness.

    ../_images/stroke-cap-round.png

    For example, to turn a thick stroke into a series of circles, set:

    • Stroke Cap to Round

    • Stroke Dash Pattern to 0 followed by the distance that you want between the centers of the circles

    ../_images/stroke-cap-property.png ../_images/stroke-circular-dash-properties.png

Setting the shape of corners

You can use the Stroke Join property to set the shape of the corner that is formed when the ends of two strokes meet or overlap.

To set the shape of the corners in a shape:

  1. Create or select a shape node that uses stroke and shows a shape with sharp corners.

    For example, in the Node Tree, create an Ellipse 2D node that draws the outline of a circle sector. See Using the Ellipse nodes.

    ../_images/ellipse-2d-sector.png ../_images/circle-sector-in-preview.png
  2. In the Properties, add the Stroke Join property and set it to:

    Miter to use a sharp corner.

    This is the default value.

    ../_images/stroke-join-miter.png

    Round to use a round corner.

    ../_images/stroke-join-round.png

    Bevel to use a bevelled corner.

    ../_images/stroke-join-bevel.png
    ../_images/stroke-join-property.png ../_images/stroke-join-round-in-preview.png
  3. (Optional) When two line segments meet at a sharp angle, the miter can extend far beyond the thickness of the stroke. You can use the Stroke Miter Limit property to set a limit on the ratio of the miter length to the Stroke Thickness. When the limit is exceeded, Kanzi converts the join to a bevelled join.

Setting the alignment of the stroke

You can use the Stroke Alignment property to align the stroke in a closed path to the inside or outside of the shape boundary. Closed paths use center alignment by default. Open paths always use center alignment.

When you align the stroke so that it is inside or outside the shape boundary, the value of the Fill Rule property can affect the result. The Fill Rule property determines which regions in a shape are inside and which regions are outside. See Setting the fill rule.

To set the alignment of the stroke:

  1. Create or select a shape node that uses stroke and shows a shape with closed paths.

    For example, in the Node Tree, create an Ellipse 2D node that draws the translucent outline of a filled circle. See Using the Ellipse nodes.

    ../_images/filled-stroked-ellipse-2d.png ../_images/filled-stroked-ellipse-2d-in-preview.png
  2. In the Properties, add and set the Stroke Alignment property to:

    Center to align the centerline of the stroke to the path.

    This is the default value.

    ../_images/stroke-alignment-center.png

    Inside to align the outer edge of the stroke to the shape boundary, so that the stroke is inside the shape boundary.

    The value of the Fill Rule property can affect the result.

    ../_images/stroke-alignment-inside.png

    Outside to align the inner edge of the stroke to the shape boundary, so that the stroke is inside the shape boundary.

    The value of the Fill Rule property can affect the result.

    ../_images/stroke-alignment-outside.png
    ../_images/properties-stroke-alignment.png

See also

Filling a shape

Gradients

Using the Line nodes

Using the Ellipse nodes