How to make the stroke width 1px in flutter's customPainter
you can use:
Paint paint = Paint() ..color = Colors.red ..strokeWidth = 2 ..style = PaintingStyle.stroke ..strokeJoin = StrokeJoin.round ;
Zach Russell
I am a Philadelphia based WordPress Developer & SEO who runs ProTech Internet Group. I have been doing SEO for over 5 years where i've helped countless businesses reach top ranks on search engines. I have developed on WordPress for about two years where I have build countless sites and am looking to make some outside-the-box web applications with in the near future. I am currently a Software Engineering Student at the University of Phoenix where I'd like to concentrate diversify my programming palette. I plan on learning Ruby (Rails), Python, and advanced shell scripting in the near future. Keep on the lookout for my WordPress plugins and themes
Updated on December 22, 2022Comments
-
Zach Russell over 1 year
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):
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.
-
JRamos29 almost 4 yearsDid you tried to set the isAntiAlias for true? I believe that this flag change the pixelate of the draw.
-
pskink almost 4 yearsdevicePixelRatio maybe?
-
Zach Russell almost 4 years@JRamos29 the anti-aliasing was the first thing I tried.
-
Zach Russell almost 4 years@pskink this may be on the right track, but I'm not sure how this relates to stroke width. Would you mind expounding on how I would approach converting this?
-
pskink almost 4 yearsuse
1 / devicePixelRatio
as a stroke width
-