Lilly
08/22/2023, 8:05 PMleft
and top
is:
fun Modifier.shadow(
size: DpSize,
color: Color = DefaultShadowColor,
offsetX: Dp = 0.dp,
offsetY: Dp = 0.dp,
blurRadius: Dp = 0.dp,
) = then(
drawBehind {
drawIntoCanvas { canvas ->
val paint = Paint()
val frameworkPaint = paint.asFrameworkPaint()
if (blurRadius != 0.dp) {
frameworkPaint.maskFilter =
BlurMaskFilter(blurRadius.toPx(), BlurMaskFilter.Blur.NORMAL)
}
frameworkPaint.color = color.toArgb()
val leftPixel = offsetX.toPx()
val topPixel = offsetY.toPx()
val rightPixel = size.width.toPx()
val bottomPixel = size.height.toPx()
canvas.drawRect(
left = leftPixel,
top = topPixel,
right = rightPixel,
bottom = bottomPixel,
paint = paint,
)
}
}
)
romainguy
08/22/2023, 8:08 PMrightPixel
should be leftPixel + size.width.toPx()
in your case. Same for bottomPixel
Lilly
08/22/2023, 8:11 PM