toMatrix4 property

Matrix4? get toMatrix4

生成目标 Matrix4 对象,执行优先顺序为:transformscaletranslate

Implementation

Matrix4? get toMatrix4 {
  if (transform != null) {
    return transform;
  } else if (scale != null) {
    double x, y;
    if (scale is Iterable) {
      assert(
        scale.first is double? && scale.last is double?,
        'ElBoxStyle Error: scale List 参数写法必须为 double 或者 null 类型',
      );
      x = scale.first ?? 1.0;
      y = scale.last ?? 1.0;
    } else {
      assert(scale is double, 'ElBoxStyle Error: scale 参数必须为 double 类型');
      x = scale;
      y = x;
    }
    return Matrix4.diagonal3Values(x, y, 1.0);
  } else if (translate != null) {
    return Matrix4.translationValues(translate!.dx, translate!.dy, 0.0);
  }

  return null;
}