Compare commits

..

1 Commits

Author SHA1 Message Date
Shadowfacts c79b93a4f9
Add NinePatchTexture and NinePatchView 2019-06-23 20:09:52 -04:00
2 changed files with 14 additions and 0 deletions

View File

@ -1,7 +1,17 @@
package net.shadowfacts.cacao.util
/**
* Helper class that represents a texture that can be divided into nine pieces (4 corners, 4 edges, and the center)
* and can be drawn at any size by combining and repeating those pieces.
*
* It also provides convenience [Texture] objects that represent the different patches.
*
* @author shadowfacts
* @param texture The base [Texture] object.
* @param cornerWidth The width of each corner (and therefore the width of the vertical edges).
* @param cornerHeight The height of each corner (and therefore the height of the horizontal edges.)
* @param centerWidth The width of the center patch.
* @param centerHeight The height of the center patch.
*/
data class NinePatchTexture(val texture: Texture, val cornerWidth: Int, val cornerHeight: Int, val centerWidth: Int, val centerHeight: Int) {

View File

@ -6,7 +6,11 @@ import net.shadowfacts.cacao.util.NinePatchTexture
import net.shadowfacts.cacao.util.RenderHelper
/**
* A helper class for drawing a [NinePatchTexture] in a view.
* `NinePatchView` will draw the given nine patch texture filling its bounds.
*
* @author shadowfacts
* @param ninePatch The nine patch texture that this view will draw.
*/
class NinePatchView(val ninePatch: NinePatchTexture): View() {