3
私は円を描いて、セクションに分割してAndroid用に作成したカスタムビューを持っています。ここで Androidのキャンバスで描く角度が正しくありません
はonDrawのコードです:int w = Width;
int h = Height;
int pl = PaddingLeft;
int pr = PaddingRight;
int pt = PaddingTop;
int pb = PaddingBottom;
int usableWidth = w - (pl + pr);
int usableHeight = h - (pt + pb);
int radius = Math.Min(usableWidth, usableHeight)/2;
int cx = pl + (usableWidth/2);
int cy = pt + (usableHeight/2);
int lineLenght = radius - (pl * 2) - (pr * 2);
paint.Color = Color.Black;
paint.SetStyle(Paint.Style.Stroke);
canvas.DrawCircle(cx, cy, radius, paint);
//Move to top of the circle
float pointAngle = 360/noOfJoints;
for (float angle = 0; angle < 361; angle = angle + pointAngle)
{ //move round the circle to each point
float x = cx + ((float)Math.Cos(radians(angle)) * radius); //convert angle to radians for x and y coordinates
float y = cy + ((float)Math.Sin(radians(angle)) * radius);
canvas.DrawLine(cx, cy, x, y, paint); //draw a line from center point back to the point
}
しかし、私はこれを実行すると、それは次のようなビューを提供:、
私が欲しいものに近いですが、セクションの開始は中央から行う必要があります。どのようにして0から始めることができますか(最初の仕切りは上から下の直線から始める必要があります)。次のように
好ましい円である:
ありがとう、私は0の角度が上にあるべきだと思った。迅速な返信をありがとう – progrAmmar