title: How to draw a lines inside a circle angle wise?
body: <p>In android I have create custom view.I have first drawn circle and now I want to draw a line angle wise within a circle. I want like this with animation.
  <a href="https://drive.google.com/file/d/1Qx0MBu-77JIlQTByqGTyD-KtGKOB8naG/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1Qx0MBu-77JIlQTByqGTyD-KtGKOB8naG/view?usp=sharing</a></p>
  
  <p>I have used canvas to draw circle and lines.I have taken viewpager.If I swipe viewpager then pie graphics will rotate.</p>
  
  <p>What I have done uptill now. When animating it's always start from zero: 
  <a href="https://drive.google.com/file/d/12mmAUOeY77jAlj_GmM3Ymcx5m34vli3X/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/12mmAUOeY77jAlj_GmM3Ymcx5m34vli3X/view?usp=sharing</a></p>
  
  <p>I have done below code:       </p>
  
  <pre><code>    public class PieView : View
      {
          int w, h, pl, pr, pt, pb, usableWidth, usableHeight, radius, cx, cy, lineLenght;
          Paint paint;
          public Canvas canvas;
          public float firstLineangle = 0;
          public float secondLineangle = 40;
          public float thirdLineangle = 120;
          float currentAngle,maxAngle;
  
          public override void Draw(Canvas canvas)
          {
              base.Draw(canvas);
              w = Width;
              h = Height;
              pl = PaddingLeft;
              pr = PaddingRight;
              pt = PaddingTop;
              pb = PaddingBottom;
              this.canvas = canvas;
              usableWidth = w - (pl + pr);
              usableHeight = h - (pt + pb);
  
              radius = Math.Min(usableWidth, usableHeight) / 2;
              cx = pl + (usableWidth / 2);
              cy = pt + (usableHeight / 2);
  
              lineLenght = radius - (pl * 2) - (pr * 2);
              paint = new Paint();
              paint.Color = Android.Graphics.Color.White;
              paint.SetStyle(Paint.Style.Stroke);
              paint.StrokeWidth = 5;
              canvas.DrawCircle(cx, cy, radius - 5, paint);
  
              Drawline(canvas, firstLineangle);
              Drawline(canvas, secondLineangle);
              Drawline(canvas, thirdLineangle);
  
              PostInvalidateDelayed(500);
              Invalidate();
          }
  
          public void Drawline(Canvas canvas, float angle)
          {
              float displacedAngle = angle - 90;
              float x = cx + ((float)Math.Cos(degreesToRadians(displacedAngle)) * (radius - 5)); //convert angle to radians for x and y coordinates
              float y = cy + ((float)Math.Sin(degreesToRadians(displacedAngle)) * (radius - 5));
              canvas.DrawLine(cx, cy, x, y, paint); //draw a line from center point back to the point
          }
  
          public double degreesToRadians(double degrees)
          {
              return (degrees * Math.PI) / 180;
          }
      }
  
      public class PieAnimation  : Android.Views.Animations.Animation
      {
          private PieView pieView;
  
          private float firstLineangle;
          private float secondLineangle;
          private float thirdLineangle;
  
          public PieAnimation(PieView pieView, float firstLineangle,float secondLineangle,float thirdLineangle)
          {
              this.pieView = pieView;
              this.firstLineangle = firstLineangle;
              this.secondLineangle = secondLineangle;
              this.thirdLineangle = thirdLineangle;
          }
  
          protected override void ApplyTransformation(float interpolatedTime, Transformation t)
          {
              pieView.firstLineangle = 0 + ((firstLineangle) * interpolatedTime);
              pieView.secondLineangle = 0 + ((secondLineangle) * interpolatedTime);
              pieView.thirdLineangle = 0 + ((thirdLineangle) * interpolatedTime);
              pieView.RequestLayout();
          }
      }
  
  public class TourPager : Java.Lang.Object, ViewPager.IOnPageChangeListener, ViewPager.IPageTransformer
      {
  
          private ViewPager mViewPager;
  
          private float mLastOffset;
          public TourView _context;
  
          public TourPager(ViewPager viewpager, TourView context)
          {
              mViewPager = viewpager;
              viewpager.AddOnPageChangeListener(this);
              _context = context;
          }
  
          public void OnPageSelected(int position)
          {
  
              if (position == 0)
              {
                  PieAnimation animation = new PieAnimation(_context._pieView, 0, 40, 120);
                  animation.Duration = (1000);
                  _context._pieView.StartAnimation(animation);
              }
              if (position==1)
              {
                  PieAnimation animation = new PieAnimation(_context._pieView, 100, 140, 200);
                  animation.Duration=(1000);
                  _context._pieView.StartAnimation(animation);
              }
              if(position==2)
              {
                  PieAnimation animation = new PieAnimation(_context._pieView, 180, 270, 10);
                  animation.Duration = (1000);
                  _context._pieView.StartAnimation(animation);
              }
      }
  </code></pre>