replay method
Implementation
void replay(RitoPrimitiveList list, RitoPrimitiveTarget target) {
var saveDepth = 0;
try {
for (final primitive in list.commands) {
switch (primitive) {
case RitoPrimitivePushState():
target.save();
saveDepth += 1;
case RitoPrimitivePopState():
if (saveDepth == 0) {
throw const FormatException(
'RITODL1 restore has no matching save.',
);
}
target.restore();
saveDepth -= 1;
case RitoPrimitiveTranslate():
target.translate(primitive);
case RitoPrimitiveOpacity():
target.opacity(primitive);
case RitoPrimitiveTransform():
target.transform(primitive);
case RitoPrimitiveClipPath():
target.clipPath(primitive);
case RitoPrimitiveFillRect():
target.fillRect(primitive);
case RitoPrimitiveFillPath():
target.fillPath(primitive);
case RitoPrimitiveStrokePath():
target.strokePath(primitive);
case RitoPrimitiveShadow():
target.shadow(primitive);
case RitoPrimitiveDrawImage():
target.drawImage(primitive);
case RitoPrimitiveText():
target.text(primitive);
case RitoPrimitiveRuby():
target.ruby(primitive);
}
}
if (saveDepth != 0) {
throw FormatException('RITODL1 leaves $saveDepth save states open.');
}
} finally {
while (saveDepth > 0) {
target.restore();
saveDepth -= 1;
}
}
}