What is N-Slicing?
Rive’s N-Slice feature is inspired by the 9-slicing technique commonly used in game design. A 9-slice is typically applied to an image to prevent the four corner segments from scaling when resized. Meanwhile, the remaining five inner segments stretch or tile to allow raster artwork to scale up and change ratio without distorting. N-Slicing takes things a step further; allowing you to create any number of segments, to both raster and vector artwork within Rive.Creating an N-Slice
There are two types of N-Slice — those applied to images and those applied to vector objects in the form of a group. Whilst much of the functionality between them is shared, there are some subtle differences, starting with the way you apply them. Image/Raster N-Slice1
Select the image you want to apply an N-Slice to.
2
Select the add action within the Deform section of the inspector and choose the N-Slice option. Alternatively, right-click the image on the stage or in the hierarchy and navigate to the N-Slice option within the Deform submenu.”
3
Upon creation, the N-Slice will enter edit mode. Here you can set up the axes and tile modes that define the scale behaviour of the image. Start by positioning and/or creating the axes as desired. Once completed, select the ‘Done’ action in the inspector or stage prompt. Learn more about how to best setup your N-Slice in the ‘Setting up an N-Slice’ section below.
4
To return to the edit mode, select the ‘Edit N-Slice’ action in the inspector or right-click menu.
1
If your selection is already contained within a group, select the group on the stage or in the hierarchy and use the ‘Convert to N-Slice’ action in the inspector. Alternatively, select the stage objects you’d like to wrap in an N-Slice group and choose the ‘N-Slice selection’ action in the inspector. You can also reach this option by right-clicking on the items within the stage or the hierarchy and navigating to the ‘Wrap in’ submenu.
2
With the N-Slice group selected, use the ‘Edit N-Slice’ option in the inspector (or press
enter
) to enable the edit mode. From here, you can setup your axes and tile modes. Once completed, select the ‘Done’ action in the inspector or stage prompt. Learn more about how to best setup your N-Slice in the ‘Setting up an N-Slice’ section below.Setting up an N-Slice
With your image or N-Slice item selected, use the inspector action, right-click menu, orenter
key to enter the edit mode. The edit mode allows you to change the configuration of your axes and tile modes to define how your image or group scales.
We recommend setting up your N-Slice before scaling the image or changing the size of the group. While it’s possible to adjust the axes on an already-scaled image, accurately positioning new ones can be more difficult.
command
/ control
before dragging the new axis.
Hold
command
/ control
while dragging a new axis to prevent a mirrored counterpart being created at the same time.Tile modes can only be changed on image/raster based n-slices.
- Stretch: Stretches the segment as the image is resized.
- Repeat: Tiles the segment repeatedly as the image is resized.
- Hidden: Hides the segment, not rendering it at all.
Tile modes other than ‘hidden’ won’t have any effect on a fixed segment.
1
With the image or it’s N-Slice selected, use the ‘Edit N-Slice’ option in the inspector (or press
enter
) to enable the edit mode.2
Identify the segment you want to change by selecting it on the stage. The corresponding tile will be highlighted in the inspector.
3
Set the tile mode via the dropdown menu in the inspector.