Colton Idle
05/04/2023, 2:55 AMColton Idle
05/04/2023, 2:57 AM@Composable
private fun MyDot(modifier: Modifier) {
BoxWithConstraints(
modifier = modifier,
contentAlignment = Center
){
Box(Modifier.size(this.maxWidth).background(Color.Red, CircleShape))
Box(Modifier.size(this.maxWidth / 2).background(Color.White, CircleShape))
}
}
romainguy
05/04/2023, 3:02 AMromainguy
05/04/2023, 3:03 AMromainguy
05/04/2023, 3:03 AMColton Idle
05/04/2023, 3:03 AMColton Idle
05/04/2023, 3:08 AMCanvas(modifier = modifier, onDraw = {
drawCircle(Color.Red)
drawCircle(
color = Color.White,
radius = size.minDimension / 4,
)
})
Colton Idle
05/04/2023, 3:09 AMColton Idle
05/04/2023, 3:11 AMColton Idle
05/04/2023, 3:22 AMBox(
modifier
.graphicsLayer {
compositingStrategy = CompositingStrategy.Offscreen
}
.drawWithContent {
drawCircle(Color.Red)
drawCircle(
color = Color.Black,
radius = size.minDimension / 4,
blendMode = BlendMode.Clear
)
}
)
romainguy
05/04/2023, 3:25 AMephemient
05/04/2023, 3:46 AMCanvas(modifier = modifier) {
val path = Path()
val outer = Rect(center, size.minDimension / 2)
path.arcTo(outer, 0f, 180f, true)
path.arcTo(outer, 180f, 180f, false)
val inner = Rect(center, size.minDimension / 4)
path.arcTo(inner, 180f, -180f, true)
path.arcTo(inner, 0f, -180f, false)
drawPath(path, Color.Red)
}
you don't need any compositing strategyColton Idle
05/04/2023, 3:59 AMephemient
05/04/2023, 4:06 AMThis behaves the same as save(), but in addition it allocates and redirects drawing to an offscreen rendering target.
Note: this method is very expensive, incurring more than double rendering cost for contained content. Avoid using this method when possible and instead use ais effectively what it doeson a View to apply an xfermode, color filter, or alpha, as it will perform much better than this method.hardware layer
romainguy
05/04/2023, 4:15 AMromainguy
05/04/2023, 4:15 AMromainguy
05/04/2023, 4:16 AMromainguy
05/04/2023, 4:17 AMephemient
05/04/2023, 4:17 AMromainguy
05/04/2023, 4:17 AMephemient
05/04/2023, 4:17 AMromainguy
05/04/2023, 4:17 AMephemient
05/04/2023, 4:18 AMromainguy
05/04/2023, 4:19 AMColton Idle
05/04/2023, 4:37 AMromainguy
05/04/2023, 4:41 AMromainguy
05/04/2023, 4:41 AMromainguy
05/04/2023, 4:41 AMromainguy
05/04/2023, 4:42 AMephemient
05/04/2023, 4:42 AMOleksandr Balan
05/04/2023, 5:36 AMromainguy
05/04/2023, 5:40 AM