飘扬的定制快船半径八根

发布于 2025-01-28 09:29:30 字数 1771 浏览 1 评论 0原文

我试图弄清快船的形状,但这是不可能的。我尝试使用路径。ARCTOPONT属性,但我认为我不太了解它如何在路径上添加半径。只有弧线属性?

我把我的快船课和代码打电话给快船:

ClipPath(
  clipper: Clipper(points: 8),
  child: Container(
    height: 150,
    width: 150,
    decoration: BoxDecoration(
      color: Color.red,
    ),
    child: Center(child: Text('1'),
  ),
);
class Clipper extends CustomClipper<Path> {

Clipper({this.points = 8});

/// The number of points of the star
 final int points;

@override
Path getClip(Size size) {
 double width = size.width;
 double halfWidth = width / 2;

 double bigRadius = halfWidth;

 double radius = halfWidth / 1.25;

 double degreesPerStep = _degToRad(360 / points);

 double halfDegreesPerStep = degreesPerStep / 2;

 var path = Path();

 double max = 2 * math.pi;

 path.moveTo(width, halfWidth);

 for (double step = 0; step < max; step += degreesPerStep) {
   path.lineTo(halfWidth + bigRadius * math.cos(step), halfWidth + bigRadius * math.sin(step));
   path.arcToPoint(
      Offset(
        halfWidth + bigRadius * math.cos(step),
        halfWidth + bigRadius * math.sin(step),
      ),
      radius: const Radius.circular(50));
  path.lineTo(halfWidth + radius * math.cos(step + halfDegreesPerStep), halfWidth + radius * math.sin(step + halfDegreesPerStep));
  path.arcToPoint(
      Offset(
        halfWidth + radius * math.cos(step + halfDegreesPerStep),
        halfWidth + radius * math.sin(step + halfDegreesPerStep),
      ),
      radius: const Radius.circular(50));
 }

 path.close();
 return path;
}

double _degToRad(num deg) => deg * (math.pi / 180.0);

@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
  Clipper oldie = oldClipper as Clipper;
  return points != oldie.points;
}
}

谢谢

I'm trying to round off the shapes of my clipper but it's impossible. I tried with the path.arcToPoint property but I think I don't really understand how it works to add radius on path. Only with arcToPoint property ?

I put my Clipper class and the code to call the clipper here :

ClipPath(
  clipper: Clipper(points: 8),
  child: Container(
    height: 150,
    width: 150,
    decoration: BoxDecoration(
      color: Color.red,
    ),
    child: Center(child: Text('1'),
  ),
);
class Clipper extends CustomClipper<Path> {

Clipper({this.points = 8});

/// The number of points of the star
 final int points;

@override
Path getClip(Size size) {
 double width = size.width;
 double halfWidth = width / 2;

 double bigRadius = halfWidth;

 double radius = halfWidth / 1.25;

 double degreesPerStep = _degToRad(360 / points);

 double halfDegreesPerStep = degreesPerStep / 2;

 var path = Path();

 double max = 2 * math.pi;

 path.moveTo(width, halfWidth);

 for (double step = 0; step < max; step += degreesPerStep) {
   path.lineTo(halfWidth + bigRadius * math.cos(step), halfWidth + bigRadius * math.sin(step));
   path.arcToPoint(
      Offset(
        halfWidth + bigRadius * math.cos(step),
        halfWidth + bigRadius * math.sin(step),
      ),
      radius: const Radius.circular(50));
  path.lineTo(halfWidth + radius * math.cos(step + halfDegreesPerStep), halfWidth + radius * math.sin(step + halfDegreesPerStep));
  path.arcToPoint(
      Offset(
        halfWidth + radius * math.cos(step + halfDegreesPerStep),
        halfWidth + radius * math.sin(step + halfDegreesPerStep),
      ),
      radius: const Radius.circular(50));
 }

 path.close();
 return path;
}

double _degToRad(num deg) => deg * (math.pi / 180.0);

@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
  Clipper oldie = oldClipper as Clipper;
  return points != oldie.points;
}
}

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文