1

I am building a Flutter app that allows you to draw pixel art on a canvas using CustomPainter. My Paint() method looks like so:

final paint = Paint()
      ..color = Colors.deepPurple
      ..style = PaintingStyle.fill
      ..isAntiAlias = false
      ..strokeWidth = 1;

Which gives me something like this (zoomed in): App Canvas

After testing this I realized that that strokeWidth = 1 does not mean 1 pixel. I can change it to .1 or something, but that then seems to be doing sub-pixel painting. How can I get my stroke width to be exactly 1 pixel?

I looked through the documentation and I'm not understanding why this is happening.

4

1 回答 1

0

您可以使用:

Paint paint = Paint() ..color = Colors.red ..strokeWidth = 2 ..style = PaintingStyle.stroke ..strokeJoin = StrokeJoin.round ;
于 2021-10-31T15:07:39.807 回答