Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...