parseTransform function

Matrix4 parseTransform(
  1. List<XmlAttribute> el
)

Parses AVD transform related attributes to a Matrix4.

Implementation

Matrix4 parseTransform(List<XmlAttribute> el) {
  final double rotation = parseDouble(
      getAttribute(el, 'rotation', def: '0', namespace: androidNS))!;
  final double pivotX =
      parseDouble(getAttribute(el, 'pivotX', def: '0', namespace: androidNS))!;
  final double pivotY =
      parseDouble(getAttribute(el, 'pivotY', def: '0', namespace: androidNS))!;
  final double? scaleX =
      parseDouble(getAttribute(el, 'scaleX', def: '1', namespace: androidNS));
  final double? scaleY =
      parseDouble(getAttribute(el, 'scaleY', def: '1', namespace: androidNS));
  final double translateX = parseDouble(
      getAttribute(el, 'translateX', def: '0', namespace: androidNS))!;
  final double translateY = parseDouble(
      getAttribute(el, 'translateY', def: '0', namespace: androidNS))!;

  return Matrix4.identity()
    ..translate(pivotX, pivotY)
    ..rotateZ(rotation * pi / 180)
    ..scale(scaleX, scaleY)
    ..translate(-pivotX + translateX, -pivotY + translateY);
}