draw method
Renders this nine box as a rectangle at position
with size size
.
Implementation
void draw(Canvas c, Vector2 position, Vector2 size) {
// corners
_drawTile(c, _getDest(position), 0, 0);
final bottomLeft = position + Vector2(0, size.y - destTileSize);
_drawTile(c, _getDest(bottomLeft), 0, 2);
final topRight = position + Vector2(size.x - destTileSize, 0);
_drawTile(c, _getDest(topRight), 2, 0);
final bottomRight = Vector2(topRight.x, bottomLeft.y);
_drawTile(c, _getDest(bottomRight), 2, 2);
// horizontal sides
final mx = size.x - 2 * destTileSize;
final middleLeft = position + Vector2Extension.fromInts(destTileSize, 0);
_drawTile(c, _getDest(middleLeft, width: mx), 1, 0);
final middleRight = middleLeft + Vector2(0, size.y - destTileSize);
_drawTile(c, _getDest(middleRight, width: mx), 1, 2);
// vertical sides
final my = size.y - 2 * destTileSize;
final topCenter = position + Vector2Extension.fromInts(0, destTileSize);
_drawTile(c, _getDest(topCenter, height: my), 0, 1);
final bottomCenter = topCenter + Vector2(size.x - destTileSize, 0);
_drawTile(c, _getDest(bottomCenter, height: my), 2, 1);
// center
final center = position + Vector2.all(destTileSize.toDouble());
_drawTile(c, _getDest(center, width: mx, height: my), 1, 1);
}