Colton Idle
07/29/2025, 7:15 AMdrawArc(
brush = brushBackground,
startAngle = 90f,
sweepAngle = PROGRESS_FULL_DEGREES ...
)
drawArc(
brush = brush,
startAngle = 270f,
sweepAngle = progressDegrees ...
)
Colton Idle
07/29/2025, 7:17 AMdrawIntoCanvas
and blendMode BloendMode.SrcOver, but it still had some aliasing going on.
As well as tried a few different combos of "withSaveLayer" and graphicsLayerromainguy
07/29/2025, 3:20 PMromainguy
07/29/2025, 3:20 PMephemient
07/29/2025, 3:41 PMdrawArc(
brush = brushBackground,
startAngle = progressDegrees - 90f,
sweepAngle = PROGRESS_FULL_DEGREES - progressDegrees
)
drawArc(
brush = brush,
startAngle = -90f,
sweepAngle = progressDegrees
)
romainguy
07/29/2025, 3:50 PMColton Idle
07/29/2025, 3:51 PMephemient
07/29/2025, 3:51 PMColton Idle
07/29/2025, 3:52 PMval drawStyle = remember { Stroke(width = 6.dp.value, cap = StrokeCap.Round) }
val brush = remember {
SolidColor(progressColor)
}
val brushBackground = remember { SolidColor(backgroundColor) }
val animateCurrentProgress = animateFloatAsState(
targetValue = progress,
animationSpec = tween(durationMillis = 100, easing = LinearEasing)
)
val progressDegrees = animateCurrentProgress.value * PROGRESS_FULL_DEGREES
Box(
modifier = modifier
.size(150.dp)
.padding(16.dp)
.drawBehind {
val strokeWidth = drawStyle.width
val radius = size.minDimension / 2
val arcBounds = size.toRect().deflate(strokeWidth / 2)
drawArc(
brush = brushBackground,
startAngle = 90f,
sweepAngle = PROGRESS_FULL_DEGREES,
useCenter = false,
topLeft = arcBounds.topLeft,
size = arcBounds.size,
style = drawStyle
)
drawArc(
brush = brush,
startAngle = -90f,
sweepAngle = -progressDegrees,
useCenter = false,
topLeft = arcBounds.topLeft,
size = arcBounds.size,
style = drawStyle
)
// Draw thumb at the end of arc
val angleRad = Math.toRadians((-90f - progressDegrees).toDouble())
val center = size.center
val thumbX = center.x + radius * kotlin.math.cos(angleRad).toFloat()
val thumbY = center.y + radius * kotlin.math.sin(angleRad).toFloat()
drawCircle(
color = progressColor,
radius = strokeWidth * 2,
center = androidx.compose.ui.geometry.Offset(thumbX, thumbY)
)
}
) {
Box(modifier = Modifier.align(Alignment.Center)) {
content()
}
}
romainguy
07/29/2025, 3:53 PMColton Idle
07/29/2025, 3:53 PMephemient
07/29/2025, 3:53 PMColton Idle
07/29/2025, 3:55 PMromainguy
07/29/2025, 3:57 PMColton Idle
07/29/2025, 3:59 PMephemient
07/29/2025, 3:59 PMephemient
07/29/2025, 3:59 PMColton Idle
07/29/2025, 4:00 PMromainguy
07/29/2025, 4:00 PMromainguy
07/29/2025, 4:01 PMColton Idle
07/29/2025, 4:02 PMephemient
07/29/2025, 4:03 PM+-------------+ +----+ +****+--------+
| | + | | = | | |
+-------------+ +----+ +****+--------+
+--------+ +----+ +----+--------+
| | + | | = | | |
+--------+ +----+ +----+--------+
Colton Idle
07/29/2025, 4:06 PMromainguy
07/29/2025, 4:07 PMColton Idle
07/29/2025, 4:07 PMromainguy
07/29/2025, 4:07 PMColton Idle
07/29/2025, 4:09 PMephemient
07/29/2025, 4:10 PMromainguy
07/29/2025, 4:10 PMColton Idle
07/29/2025, 4:11 PMColton Idle
07/29/2025, 4:11 PMephemient
07/29/2025, 4:12 PMromainguy
07/29/2025, 4:12 PMColton Idle
07/29/2025, 4:13 PMephemient
08/01/2025, 4:39 AMso only ever draw one color in a pixelbtw I wouldn't say that. it's fine to draw a pixel more than once, but for any shapes that aren't perfectly pixel-aligned, try to either keep at least 1px apart or have at least 1px of overlap, to avoid the edges blending unexpectedly
Colton Idle
08/02/2025, 3:49 PM