Closed rustamsmax closed 2 years ago
Could you please provide code snippet that manifests bad behavior?
Also note that signature of drawArc
is
fun drawArc(
left: Float,
top: Float,
right: Float,
bottom: Float,
startAngle: Float,
sweepAngle: Float,
useCenter: Boolean,
paint: Paint
)
and doesn't have size
parameter.
I used second option
Which version of Compose is that? Don't see method with such signature in 0.3.1 or 0.3.2.
Is it actually DrawScope.drawArc
?
Works for me with code like that:
val infiniteTransition = rememberInfiniteTransition()
val radius by infiniteTransition.animateFloat(
initialValue = 1f,
targetValue = 600f,
animationSpec = infiniteRepeatable(
animation = tween(5000),
repeatMode = RepeatMode.Restart
)
)
Canvas(modifier = Modifier.fillMaxSize()) {
drawArc(
color = Color.Black, topLeft = Offset.Zero, size = Size(radius, radius),
startAngle = 0f, sweepAngle = -180f, useCenter = false,
style = Stroke(width = 1f), alpha = 1.0f
)
}
I'm using 0.4.0-build168 I'm not animating radius. I'm sharing full code snippet
https://gist.github.com/rustamsmax/a8083c6c3f330b18f8d4673052d33f1e
Indeed, we use Skija
public Canvas drawArc(float left, float top, float width, float height, float startAngle, float sweepAngle, boolean includeCenter, @NotNull Paint paint)
as
override fun drawArc(
left: Float,
top: Float,
right: Float,
bottom: Float,
startAngle: Float,
sweepAngle: Float,
useCenter: Boolean,
paint: Paint
) {
skija.drawArc(
left,
top,
right,
bottom,
startAngle,
sweepAngle,
useCenter,
paint.skija
)
}
`
Thank you for the report! The fix is on the go! :)
Should be fixed in 0.4.0-build171
, please check.
Still not fixed
@rustamsmax Sharing a reproducer that can be copy pasted (not a screenshot) should help maintainers check it's fixed 😉.
I'm using 0.4.0-build168 I'm not animating radius. I'm sharing full code snippet
https://gist.github.com/rustamsmax/a8083c6c3f330b18f8d4673052d33f1e
@LouisCAD I've already shared gist
@rustamsmax I've just checked with 0.4.0-build173
and it looks like this:
It looks correct, right?
Hi @prepor Yes exactly. Did you uncomment the drawArc function call? In the code snippet the drawPath was a workaround
@rustamsmax yes, I did :)
@rustamsmax so does it fix it for you?
Not sure if it is related to this but i noticed that drawArc works not as expected when you define an offset. In this case it behaves differently. E.g. to get an Arc in center i have to use following code: Tested on 0.4.0-build171
fun main() = Window {
Canvas(Modifier.fillMaxSize()) {
val d = size.minDimension
val r = d / 2f
val offset = Offset((size.width / 2f - r), size.height / 2f - r)
drawArc(
color = Color.Green,
size = Size(d - offset.x, d - offset.y), // minus offset.x/y is the workaround and is not necessary in Android.
topLeft = offset,
startAngle = -90f,
sweepAngle = 270f,
useCenter = true
)
}
}
Ok it is fixed in build: 0.4.0-build173 :+1:
Closing, as it is fixed.
Canvas.drawArc
is ignoringsize
parameter The issue is specific to desktop app. Android app is working as expected.A workaround was to draw path with
Path.addArcRad