Mahmoo
01/24/2024, 9:00 AMMahmoo
01/24/2024, 9:01 AMCanvas(
modifier = Modifier
.fillMaxSize()
.align(Alignment.Center)
.clip(CircleShape)
.background(Color.Yellow)
.clipToBounds()
.pointerInput(Unit) {
detectDragGestures { change, dragAmount ->
clickCoordinate = Offset(change.position.x, change.position.y)
}
detectTapGestures {
clickCoordinate = it
}
}
) {
val size = this.size
val centerX = size.width * 0.5f
val centerY = size.height * 0.5f
val radius = size.width * 0.5f
val angle = calculateAngle(
center = Offset(x = centerX, y = centerY),
point = Offset(x = clickCoordinate.x, y = clickCoordinate.y)
)
val pointOnCircle = calculatePointOnCircumference(
Offset(x = centerX, y = centerY),
radius,
angle
)
for (i in 0 until 12) {
val angle2 = (i * 30).toFloat()
val pointOnCircumference =
calculatePointOnCircumference2(center, radius, angle2)
drawLine(
color = Color.Gray,
start = center,
end = pointOnCircumference
)
}
for (i in 0 until 60) {
val minute = (i * 6).toFloat()
val pointOnCircumference =
calculatePointOnCircumference2(center, radius, minute)
val isMultipleOf5 = (i % 5 == 0)
drawLine(
color = Color.Gray,
start = pointOnCircumference,
end = calculatePointOnCircumference2(
center,
radius - if (isMultipleOf5) 24f else 16f,
minute
),
strokeWidth = if (isMultipleOf5) 8f else 4f
)
}
}
Mahmoo
01/24/2024, 9:02 AMSean Proctor
01/24/2024, 9:45 AMMahmoo
01/24/2024, 9:55 AMMahmoo
01/24/2024, 9:56 AMSean Proctor
01/24/2024, 10:01 AMMahmoo
01/24/2024, 10:02 AMSean Proctor
01/24/2024, 10:06 AM