@@ -14,7 +14,9 @@ import androidx.compose.ui.ExperimentalComposeUiApi
1414import androidx.compose.ui.Modifier
1515import androidx.compose.ui.composed
1616import androidx.compose.ui.draw.drawBehind
17+ import androidx.compose.ui.draw.drawWithContent
1718import androidx.compose.ui.geometry.Offset
19+ import androidx.compose.ui.graphics.BlendMode
1820import androidx.compose.ui.graphics.Color
1921import androidx.compose.ui.graphics.RectangleShape
2022import androidx.compose.ui.graphics.Shape
@@ -58,7 +60,8 @@ fun Modifier.unboundedClickable(
5860}
5961
6062
61- fun Modifier.debugBounds (color : Color = Color .Magenta , shape : Shape = RectangleShape ) = this .border(1 .dp, color, shape)
63+ fun Modifier.debugBounds (color : Color = Color .Magenta , shape : Shape = RectangleShape ) =
64+ this .border(1 .dp, color, shape)
6265
6366fun Modifier.rememberedClickable (
6467 enabled : Boolean = true,
@@ -155,9 +158,30 @@ fun Modifier.circleBackground(color: Color, padding: Dp): Modifier {
155158 // Assign the dimension and the center position
156159 layout(newDiameter, newDiameter) {
157160 // Place the composable at the calculated position
158- placeable.placeRelative((newDiameter - currentWidth) / 2 , (newDiameter - currentHeight) / 2 )
161+ placeable.placeRelative(
162+ (newDiameter - currentWidth) / 2 ,
163+ (newDiameter - currentHeight) / 2
164+ )
159165 }
160166 }
161167
162168 return this then backgroundModifier then layoutModifier
169+ }
170+
171+ fun Modifier.punchRectangle (color : Color ) = this .drawWithContent {
172+ drawRect(
173+ color,
174+ blendMode = BlendMode .Src
175+ )
176+
177+ drawContent()
178+ }
179+
180+ fun Modifier.punchCircle (color : Color ) = this .drawWithContent {
181+ drawCircle(
182+ color,
183+ blendMode = BlendMode .Src
184+ )
185+
186+ drawContent()
163187}
0 commit comments