Reputation: 104
Actually i am reading this article . I am so confuse about the working of startAngle , and direction of arc in drawArc() , can anyone explain this ?
I have read many answers in jetpack compose . i have wasted about 2 to 3 hours to try to understand this function .
In below code why half circle is on left side . as both angles are positive so it should be on right side ?
Preview(showBackground = true)
@Composable
fun PreviewAnimatedRectComposable() {
GooglePhotosIcon()
}
@Composable
private fun GooglePhotosIcon() {
Canvas(
modifier = Modifier
.size(100.dp)
.padding(16.dp)
.border(1.dp , Color.Magenta)
) {
drawArc(
color = Color(0xFFf04231),
startAngle = 270f,
sweepAngle = 180f,
useCenter = true,
size = Size(size.width * .50f, size.height * .50f),
topLeft = Offset(size.width * .25f, 0f)
)
}
}
Upvotes: 2
Views: 142
Reputation: 104
Actually i get diagram random from google image
So in android y axis is opposite that of the cartesian coordinate system . Means The negative y-axis is above the origin, while the positive y-axis is below it.
so StartAngle : indicate starting position of arc sweepAngle : indicate extent of arc If any those angle is negative then direction of arc is anticlockwise otherwise clockwise . From startAngle we decide where arc go either clockwise or anticlockwise depending upon either startAngle or sweepAngle is positive or negative .
So in my code start angle is on top of circle and so all angle are positive so it draw arc in clockwise direction .
Upvotes: 1