TxImageSpriteBlock constructor
TxImageSpriteBlock({})
Implementation
TxImageSpriteBlock({
required TxSprite image,
required int spriteLineHeight,
bool progressiveRender = true,
bool updatable = true
}) : _image = image,
_spriteLineHeight = spriteLineHeight,
_progressiveRender = progressiveRender,
_updatable = updatable {
// process the full-sized sprite lines
for (int i = 0; i < image.height ~/ spriteLineHeight; i++) {
_spriteLines.add(
TxSprite(
width: image.width,
height: spriteLineHeight,
numColors: image.numColors,
paletteData: image.paletteData,
pixelData: image.pixelData.buffer.asUint8List(i * spriteLineHeight * image.width, spriteLineHeight * image.width)));
}
// if there is some final, shorter sprite line, process it too
int finalHeight = image.height % spriteLineHeight;
if (finalHeight > 0) {
_spriteLines.add(
TxSprite(
width: image.width,
height: finalHeight,
numColors: image.numColors,
paletteData: image.paletteData,
pixelData: image.pixelData.buffer.asUint8List(_spriteLines.length * spriteLineHeight * image.width, finalHeight * image.width)));
}
}