如何在颤动中绘制不同的图案? [英] How to draw different Pattern in flutter?

查看:86
本文介绍了如何在颤动中绘制不同的图案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想像这样在扑扑中绘制不同的图案

I want to draw the different pattern in the flutter like this

尽管此代码是javascript,此链接

Although this code is javascript is given in this link

推荐答案

我使用了ImageShader,并且使用了Paint Function
的shader属性device shift用于获取设备像素,以便可以渲染效果

I used ImageShader and used shader property of Paint Function device transform is used to get the device pixel so that it can render the effect This is my paint method look like...

 final double devicePixelRatio = ui.window.devicePixelRatio;
      @override
      void paint(Canvas canvas, Size size) {
        final Float64List deviceTransform = new Float64List(16)
          ..[0] = devicePixelRatio
          ..[5] = devicePixelRatio
          ..[10] = 1.0
          ..[15] = 2.0;
        Float64List matrix = new Float64List(16);
        print('matrix is $matrix');
        print('image is coming in paint    $image');
        Paint paint = new Paint()
          ..style = PaintingStyle.stroke
          ..strokeCap = StrokeCap.round
          ..shader = ImageShader(
              image, TileMode.repeated, TileMode.repeated, deviceTransform)
          ..strokeWidth = 40.2;
        paths.forEach((path) {
          canvas.drawPath(path, paint);
        });
        repaint = false;
      }

这篇关于如何在颤动中绘制不同的图案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆