Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

dart - How to draw different Pattern in flutter?

I want to draw the different pattern in the flutter like this enter image description here

Although this code is javascript is given in this link

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;
      }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...