ste
06/11/2021, 11:57 AMCanvas
: compose-like approach, very customizable solution but it will be a pain for complex icons (this is what I'm currently doing)
2. Ship N drawables with different line thickness: not very customizable, increases app size, feels like a waste
3. ???cb
06/11/2021, 12:00 PMste
06/11/2021, 12:45 PM@Composable
fun InvertIcon(modifier: Modifier = Modifier) {
Icon(modifier = modifier.fillMaxSize()) {
val diagonal = chosenSize * sqrt(2f)
val circleRadius = diagonal / 4f
val circle1Center = Offset(
x = circleRadius + lineSize / 2,
y = circleRadius + lineSize / 2
)
val circle2Center = Offset(
x = chosenSize - circleRadius - lineSize / 2,
y = chosenSize - circleRadius - lineSize / 2
)
val angle1 = (PI / 3f).toFloat()
val angle2 = angle1 / 2
val offset1 = Offset(x = circleRadius * sin(angle1), y = circleRadius * cos(angle1))
val offset2 = Offset(x = circleRadius * sin(angle2), y = circleRadius * cos(angle2))
drawCircle(radius = circleRadius, center = circle1Center)
drawCircle(radius = circleRadius, center = circle2Center)
drawLine(start = circle1Center + offset1, end = circle2Center - offset2)
drawLine(start = circle2Center - offset1, end = circle1Center + offset2)
}
}
This is the code for the following icon (Icon
is just a wrapper-helper, chosenSize
is the canvas width or height and lineSize
is the size (thickness) of the lineNader Jawad
06/11/2021, 8:15 PMste
06/12/2021, 9:48 AM