lottie-flutter icon indicating copy to clipboard operation
lottie-flutter copied to clipboard

Antialiasing issues

Open kkizlaitis opened this issue 5 years ago • 11 comments

First of all, thank you for this package!

I have downloaded a very simple animation (just an inflating red circle): Recording However, when I render it, it appears pixelated around the edges. Maybe it is because I show it very small? I specify width: 30 and height: 30.

Here is a screenshot of how it looks on an iPhone X: Screenshot 2020-07-08 at 17 21 23

Would love to hear what could be done to resolve the sharp edges of the circle.

kkizlaitis avatar Jul 08 '20 14:07 kkizlaitis

I had the same problem with my iPhone 11Pro, which worked well on Android

binqiiyuenan avatar Jul 23 '20 09:07 binqiiyuenan

I also saw that it doesn't matter what the size of the animation is. My device was iPhone X (not a simulator).

kkizlaitis avatar Jul 23 '20 09:07 kkizlaitis

Yes, it has nothing to do with size. Have you found a solution later

binqiiyuenan avatar Jul 23 '20 11:07 binqiiyuenan

Not yet, for now I left it like that... Input from @xvrh would be greatly appreciated 😊

kkizlaitis avatar Jul 23 '20 14:07 kkizlaitis

I covered the serrate with a line of the same color to solve this problem on the iPhone, I hope it helps you.

binqiiyuenan avatar Jul 29 '20 03:07 binqiiyuenan

I encountered the same aliasing problem on iPhone 11 devices with lottie 0.7.0+1. And I found that this happens only in iOS 14.

AndrewsXc avatar Oct 28 '20 03:10 AndrewsXc

I have same problem.but it cant find in Android. I see circle draw use path to do will have Antialiasing.

lifelikejuly avatar Nov 20 '20 09:11 lifelikejuly

In fill_content.dart I modify draw func,if is iOS and hasCircle use drawCircle instead of drawPath.

// canvas.drawPath(_path, _paint);
if(Platform.isIOS){
  if(hasCircle){
    var rect = _path.getBounds();
    canvas.drawCircle(rect.center,rect.width / 2,_paint);
  }else{
    canvas.drawPath(_path, _paint);
  }
}else{
  canvas.drawPath(_path, _paint);
}

It is not very well solution,but can solve my problem.Hope it can help you.

lifelikejuly avatar Nov 24 '20 02:11 lifelikejuly

In fill_content.dart I modify draw func,if is iOS and hasCircle use drawCircle instead of drawPath.

// canvas.drawPath(_path, _paint);
if(Platform.isIOS){
  if(hasCircle){
    var rect = _path.getBounds();
    canvas.drawCircle(rect.center,rect.width / 2,_paint);
  }else{
    canvas.drawPath(_path, _paint);
  }
}else{
  canvas.drawPath(_path, _paint);
}

It is not very well solution,but can solve my problem.Hope it can help you.

How do I know about hasCircle?

wzono avatar Nov 26 '20 07:11 wzono

In fill_content.dart I modify draw func,if is iOS and hasCircle use drawCircle instead of drawPath.

// canvas.drawPath(_path, _paint);
if(Platform.isIOS){
  if(hasCircle){
    var rect = _path.getBounds();
    canvas.drawCircle(rect.center,rect.width / 2,_paint);
  }else{
    canvas.drawPath(_path, _paint);
  }
}else{
  canvas.drawPath(_path, _paint);
}

It is not very well solution,but can solve my problem.Hope it can help you.

How do I know about hasCircle?

Find CircleShape and you can see EllipseContent. If fill_content has EllipseContent mean have circle.

lifelikejuly avatar Nov 26 '20 08:11 lifelikejuly

if(Platform.isIOS){
  final hasCircle = _path.any((path) {
    return path is EllipseContent;
  });
  if(hasCircle){
    var rect = _path.getBounds();
    canvas.drawCircle(rect.center,rect.width / 2,_paint);
  }else{
    canvas.drawPath(_path, _paint);
  }
}else{
  canvas.drawPath(_path, _paint);
}

This code may work but it needs some more tests

eggfly avatar Dec 02 '20 07:12 eggfly