placeObject2 method
void
placeObject2({})
Implementation
void placeObject2({
required int depth,
int? characterId,
int? translateXPx,
int? translateYPx,
String? name,
}) {
final hasCharacter = characterId != null;
final hasMatrix = translateXPx != null || translateYPx != null;
final hasName = name != null;
final move = !hasCharacter;
var flags = 0;
if (move) flags |= 0x01;
if (hasCharacter) flags |= 0x02;
if (hasMatrix) flags |= 0x04;
if (hasName) flags |= 0x20;
final bw = BitWriter();
bw.writeUI8(flags);
bw.writeUI16(depth);
if (hasCharacter) bw.writeUI16(characterId);
if (hasMatrix) {
_writeMatrixTranslateOnly(
bw,
(translateXPx ?? 0) * _twipsPerPixel,
(translateYPx ?? 0) * _twipsPerPixel,
);
}
if (hasName) _writeSjisString(bw, name);
_writeTag(TagCode.placeObject2, bw.toBytes());
}