v0.1.0
v9 is an Android library that provides the ability to dynamically resize Path objects as you would 9-patch bitmaps.
Slicing a Path gives you a PathResizer. The easiest way to slice is to use a single vertical and a single horizontal slice:
val pathResizer = path.slice(Slices(9.0f, 7.0f, 15.0f, 13.0f))
This syntax follows the rectangle convention on Android of passing the top, left, right, and bottom coordinates: there's a vertical slice from 9.0 to 15.0 and a horizontal slice from 7.0 to 13.0.
You can also explicitly declare a list of slices:
val pathResizer = path.slice(
Slices(
listOf(Slice(9.0f, 10.0f), Slice(14.0f, 15.0f)),
listOf(Slice(5.0f, 6.0f), Slice(18.0f, 19.0f))
)
)
Once you have a PathResizer, you can call the resize() method to create a new path derived from the original, at the desired size:
val resizedPath = pathResizer.resize(width, height)
For performance considerations, you can pass an existing path to resize(). This path will be rewound and returned:
val resizedPath = pathResizer.resize(width, height, destinationpath)
// resizedPath === destinationpath