NineTileBox.withGrid constructor
NineTileBox.withGrid(})
Creates a nine-box instance with the specified grid size
A nine-box is a grid with 3 rows and 3 columns. The outer-most columns,
leftWidth
and rightWidth
, are a fixed-width. As the nine-box is
resized, those columns remain fixed-width and the center column stretches
to take up the remaining space. In the same way, the outer-most rows,
topHeight
and bottomHeight
, are a fixed-height. As the nine-box is
resized, those rows remain fixed-height and the center row stretches
to take up the remaining space.
Implementation
NineTileBox.withGrid(
this.sprite, {
double leftWidth = 0.0,
double rightWidth = 0.0,
double topHeight = 0.0,
double bottomHeight = 0.0,
}) : tileSize = sprite.src.width ~/ 3 {
destTileSize = tileSize;
center = Rect.fromLTWH(0, 0, sprite.src.width, sprite.src.height);
_dst = Rect.fromLTWH(0, 0, sprite.src.width, sprite.src.height);
setGrid(
leftWidth: leftWidth,
rightWidth: rightWidth,
topHeight: topHeight,
bottomHeight: bottomHeight,
);
}