美文网首页
flutter RSTransform

flutter RSTransform

作者: liboxiang | 来源:发表于2020-06-11 22:46 被阅读0次
RSTransform(double scos, double ssin, double tx, double ty) {
    _value
      ..[0] = scos
      ..[1] = ssin
      ..[2] = tx
      ..[3] = ty;
  }

举例:偏移Offset(200, 100)之后以自身坐标系的(0,0)点为圆点顺时针旋转pi/8,同时放大两倍

RSTransform(math.cos(math.pi/8) * 2, math.sin(math.pi/8) * 2, 200, 100)

RSTransform.fromComponents

偏移Offset(translateX - anchorX, translateY - anchorY)后以自身坐标系的(anchorX,anchorY)点为圆点顺时针旋转,同时放大scale倍

factory RSTransform.fromComponents({
    double rotation,
    double scale,
    double anchorX,
    double anchorY,
    double translateX,
    double translateY
  }) {
    final double scos = math.cos(rotation) * scale;
    final double ssin = math.sin(rotation) * scale;
    final double tx = translateX + -scos * anchorX + ssin * anchorY;
    final double ty = translateY + -ssin * anchorX - scos * anchorY;
    return RSTransform(scos, ssin, tx, ty);
  }

备注:放大都是往旋转中心点四周放大,也就是假设放大之前点A离旋转中心点为Offset(1,1),那放大两倍后,离旋转中心点就是Offset(2,2),放大不会影响旋转中心点位置

相关文章

网友评论

      本文标题:flutter RSTransform

      本文链接:https://www.haomeiwen.com/subject/eszitktx.html