Skip to content

Releases: romainguy/v9

v0.3.0

13 Dec 02:07
Compare
Choose a tag to compare
  • Updates Kotlin and other dependencies
  • Reduced library size with new version of pathway

v0.2.0

24 Apr 12:53
Compare
Choose a tag to compare
  • Support API 33+ properly

v0.1.1

07 Sep 17:56
Compare
Choose a tag to compare
  • Upgrade to pathway 0.7.0 to benefit from an optimization

v0.1.0

29 Aug 20:06
Compare
Choose a tag to compare

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